barcelona-rent.fyiDevelopers

Quickstart

A key is free and takes one request. No account, no card, no waiting for approval.

1. Get a key

Press the button. The key is shown once — copy it now, because it is stored hashed and cannot be shown again.

Or from the terminal:

bash
curl -X POST https://www.barcelona-rent.fyi/api/keys \
  -H "Content-Type: application/json" \
  -d '{"label": "my-project"}'

label is optional and only helps you recognise the key later.

json
{
  "key": "brf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "tier": "free",
  "daily_limit": 500
}

2. Make a request

Press Run and this calls the live API from your browser, using the key above. It spends one request from your own quota.

GET/api/data/latest.json

Every district and neighbourhood, current quarter.

Or from a terminal:

bash
curl -H "Authorization: Bearer $BRF_KEY" \
     https://www.barcelona-rent.fyi/api/data/latest.json

Every district and neighbourhood, current quarter:

json
{
  "areas": [
    {
      "type": "district",
      "code": 1,
      "name": "Ciutat Vella",
      "url": "https://www.barcelona-rent.fyi/district/ciutat-vella",
      "rentEurPerSqmMonth": 18.41,
      "salePriceEurPerSqm": 4647.32,
      "grossYieldPct": 4.75
    }
  ]
}

3. Check what you have left

GET/api/keys/status

Free — this one does not count against your quota.

bash
curl -H "Authorization: Bearer $BRF_KEY" \
     https://www.barcelona-rent.fyi/api/keys/status

{"tier":"free","daily_limit":500,"used_today":1,"remaining":499,"linked_to_account":false}

In Python

python
import os, urllib.request, json

req = urllib.request.Request(
    "https://www.barcelona-rent.fyi/api/data/latest.json",
    headers={"Authorization": f"Bearer {os.environ['BRF_KEY']}"},
)
data = json.load(urllib.request.urlopen(req))

for a in data["areas"]:
    if a["type"] == "neighbourhood" and a.get("grossYieldPct"):
        print(f"{a['name']:<28} {a['rentEurPerSqmMonth']:>6} €/m²  {a['grossYieldPct']:>5}%")

In JavaScript

js
const res = await fetch("https://www.barcelona-rent.fyi/api/data/latest.json", {
  headers: {Authorization: `Bearer ${process.env.BRF_KEY}`},
});
if (res.status === 429) throw new Error(`rate limited until ${res.headers.get("Retry-After")}`);
const {areas} = await res.json();
NextAuthentication