projects→price-to-rent-map-how-i-found-the-house-i-bought-with-an-api

Price-to-Rent Map / How I Found the House I Bought with an API

The map told me where to look. The rest I did on foot.

How Python, a Jupyter notebook and Idealista data (via RapidAPI) mapped price-to-rent ratios across Las Palmas, and pointed me to the house I bought.

Old treasure map with a grid and a red X on a saffron background
Status: done Type: Data & ML Stack:
  • Folium
  • Idealista API
  • Jupyter
  • matplotlib
  • pandas
  • Python
  • RapidAPI

The question

After ten years of gravitating around Las Palmas (see my stops here), I decided it was time to buy a house. But where? In ten years, prices had risen fast in the most popular areas, with no sign of slowing down. And for me it wasn’t just a place to stay: I wanted to keep travelling from time to time, so it also had to be a good investment, and possibly a great deal!

So, how do you find a great deal? My studies in Python and data came in handy, and early AI (it was late 2023) helped me with some of the code and some financial concepts. One of them was the PRR, or price-to-rent ratio, which isn’t exactly something you pick up at school or in most walks of life. In other words: in which areas are sale prices lowest compared to rents? That’s what my Jupyter notebook set out to answer, using several downloads of listings from Idealista, a popular property website in Spain, Italy and Portugal.

The data

I pulled the listings through an Idealista API available on RapidAPI. A script downloads every page of listings, both for sale and for rent, and saves them as JSON files. Older downloads are archived with their date, so nothing gets overwritten.

Then the cleaning:

The map

I split the city into a grid and tried several sizes (10×10, 20×20…). Smaller cells show more detail, but each one holds fewer listings, so the averages get less reliable. For each cell, the notebook takes the average price per m² of the homes for sale and of the homes for rent, and keeps only the cells that have both.

Then the key number: the price-to-rent ratio, which is the sale price per m² divided by a year’s rent per m². Put simply, it’s roughly how many years of rent it takes to pay back the purchase price, before taxes and other costs like renovation, furniture and maintenance. In any case, the lower the ratio, the more convenient it is to buy there.

Finally, the grid is drawn over a map of Las Palmas (OpenStreetMap). Each cell shows its ratio, and the outline gets a darker red as the ratio rises. At a glance, the pale cells are where to start looking.

From map to house

The map didn’t pick the house. It told me where to look. I took the most promising cells and zoomed in:

That’s how I found the house I bought in spring 2024.

Limits

It’s a compass, not a valuation:

Today, an AI could read every ad and flag those cases. I didn’t have that at the time, but there were few enough listings that I could check them myself.

contact

Let's talk.

Need help with something? Looking for a professional who's reliable and believes in karma*?

Tell me about it here, or send me an email. I reply within two working days.

* which means value and integrity come first; reward follows.