# Iberian Real Estate API - Idealista, Imovirtual, Fotocasa (`pintostudio/iberian-real-estate-api`) Actor

Real estate data API for Portugal, Spain, Italy and France. Search live listings from Idealista, Imovirtual, Fotocasa and Casa Sapo, get full details, price per m2 stats, rental yield, valuations and a deal finder. Support: Telegram @pintoflow.

- **URL**: https://apify.com/pintostudio/iberian-real-estate-api.md
- **Developed by:** [Pinto Studio](https://apify.com/pintostudio) (community)
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 api requests

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Iberian Real Estate API (Apify Actor)

> ## 💬 Need faster support? Message us on Telegram: [**@pintoflow**](https://t.me/pintoflow)

Search live property listings across Portugal, Spain, Italy and France, pull full listing
details, and get computed market intelligence — price-per-square-meter stats, a rental-yield
estimate, a comparables-based price **valuation**, and a **deal finder** that ranks listings
against the local market — all from one API, across multiple real-estate portals at once.

You can use this Actor **two ways**:

1. **Run it from the Apify Console (no code).** Pick an **Operation** in the input form, fill in the
   fields it needs, and click **Start**. The Actor makes one API call, saves the response in the
   run's dataset (and in the `OUTPUT` record), and finishes. This also works from the Apify API,
   schedules, tasks, and integrations such as Make, Zapier and n8n.
2. **Standby HTTP API.** The Actor is also an always-on HTTP API (Standby mode) that you call like
   any REST API and that responds immediately — best for apps and high volume. See
   [Calling this Actor](#calling-this-actor).

This guide is for **using** the API. If you're looking for setup/deployment/architecture notes
instead, see [EXPLANATION.md](EXPLANATION.md).

### What this API does

Normally, checking the property market in Lisbon or Madrid means visiting several different
listing websites by hand, each with its own layout, its own filters, and no way to compare them
side by side. This API does that work for you:

- **Search** — one call searches every major portal for a country at once and returns a single,
  consistently-shaped list of listings.
- **Listing detail** — pull the full detail of a specific listing (photos, description,
  features, energy rating, advertiser, etc.) by the ID returned from search.
- **Area market stats** — ask "what does an apartment in this neighborhood actually cost right
  now, per square meter, to buy or to rent?" and get a real answer computed from live listings.
- **Valuation** — describe a property (area + size + bedrooms) and get a comparables-based price
  estimate, the same approach real-estate portals call an "automated valuation."
- **Deal finder** — ask "which listings in this area look like the best deals right now?" and
  get them ranked.

### Coverage

| Country | `country` value | Sources searched |
|---|---|---|
| Portugal | `pt` *(default)* | Imovirtual, Casa Sapo, Idealista |
| Spain | `es` | Fotocasa, Idealista |
| Italy | `it` | Idealista |
| France | `fr` | Idealista |

You can narrow any multi-source request to specific source(s) with the `source` parameter, e.g.
`source=imovirtual` or `source=fotocasa,idealista`.

> **Availability note:** Idealista actively blocks automated access in Spain and Italy more
> aggressively than the other sources do (see [Dos and don'ts](#dos-and-donts) below). When a
> source is temporarily unreachable, this API doesn't fail your whole request — it tells you
> which source(s) failed in the response and still gives you results from the ones that worked.
> Always check the `sources` array in the response.

### Every response has the same shape

```json
{ "error": null, "data": { "...": "..." }, "message": "A human-readable summary." }
```

- **Success**: `error` is `null`, `data` holds the actual payload, `message` is a short
  human-readable description of what happened.
- **Failure**: `data` is `null`, and `error`/`message` both hold the same error string.

This is consistent across *every* endpoint, so you only need one response-handling code path.

### Run it from the Apify Console (no code)

Choose an **Operation**, fill in only the fields that operation uses, and press **Start**. Each
successful run makes one API call and is billed as one `api-request` event. You do **not** need an
API key for this mode.

| Operation | What it returns | Fields it uses |
|---|---|---|
| Search listings | Live listings from all sources | country, location, type, propertyType, minPrice, maxPrice, bedrooms, page, source |
| Search summary | Counts and price stats for a search | same as Search listings |
| Search facets | Facet counts for a search | same as Search listings |
| List sources for a country | Which portals cover a country | country |
| Get listing details | Full detail of one listing | id |
| Get listing media / features / location / advertiser / pricing | One detail section of a listing | id |
| Area statistics | Price-per-m², rental yield, sample size | area, propertyType, country, source |
| Area deals | Listings priced below the local market | area, propertyType, transaction, country, source, limit |
| Property valuation | Estimated value from comparables | area, areaSquareMeters, bedrooms, propertyType, transaction, country, source |
| Idealista: search / totals | Idealista-only search and result totals | country, location, type, propertyType (search also: minPrice, maxPrice, bedrooms, page) |
| Idealista: location lookup | Idealista location IDs | searchField, country |
| Idealista: listing by country and ID | One Idealista listing | country, id |

**Example input** — apartments for sale in Lisbon:

```json
{
  "operation": "searchListings",
  "country": "pt",
  "location": "Lisboa",
  "type": "sale",
  "propertyType": "apartment",
  "maxPrice": 400000,
  "bedrooms": 2
}
```

**Output** — one dataset item with the same `{ error, data, message }` envelope described below,
plus `operation` and the HTTP `status`. A failed call fails the run and is not charged.

### Calling this Actor

Once deployed, an Apify Standby Actor is reachable at its own always-on URL, shaped like:

```
https://<your-apify-username>--iberian-real-estate-api.apify.actor
```

(Find the exact URL on the Actor's own page in Apify Console, under the "Standby" tab.)

Every request needs **two separate credentials**, which are not the same thing:

1. **An Apify API token** — gates access to the Actor's Standby URL itself (Apify's own layer).
   Send it as `Authorization: Bearer <your Apify token>`.
2. **This API's own key** — gates access to the actual endpoints (this project's own layer, same
   as the non-Apify version of this API). Send it as `X-API-Key: <key set in Apify Console>`.

```bash
curl \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "X-API-Key: YOUR_API_KEY" \
  "https://<your-apify-username>--iberian-real-estate-api.apify.actor/listings/search?location=lisboa"
```

`GET /health` and `GET /` don't require the `X-API-Key` (they're exempt the same way they are in
the non-Apify version), but still go through the Apify Standby URL, so the Apify token is still
required to reach them at all.

### Quickstart

```bash
BASE="https://<your-apify-username>--iberian-real-estate-api.apify.actor"
AUTH=(-H "Authorization: Bearer YOUR_APIFY_TOKEN" -H "X-API-Key: YOUR_API_KEY")

## 1. Search for apartments for sale in Lisbon
curl "${AUTH[@]}" "$BASE/listings/search?location=lisboa&type=sale&propertyType=apartment"

## 2. Pull the full detail of one listing from the results above, using its own "id"
curl "${AUTH[@]}" "$BASE/listings/imovirtual:t2-renovado-buraca-pronto-a-habitar-ID1iSo6"

## 3. Get price-per-m² and rental-yield stats for the whole area
curl "${AUTH[@]}" "$BASE/areas/lisboa/stats"

## 4. Estimate what an 80m², 2-bedroom apartment in that area is worth
curl "${AUTH[@]}" "$BASE/valuation?area=lisboa&areaSquareMeters=80&bedrooms=2"

## 5. Find the best-priced listings in the area right now
curl "${AUTH[@]}" "$BASE/areas/lisboa/deals?limit=5"
```

***

### The listing object

Search and detail endpoints return listings shaped like this (fields vary slightly by how much
detail the endpoint returns — see each endpoint below):

```json
{
  "id": "imovirtual:t2-renovado-buraca-pronto-a-habitar-ID1iSo6",
  "source": "imovirtual",
  "title": "T2 Renovado | Buraca | Pronto a Habitar",
  "url": "https://www.imovirtual.com/pt/anuncio/t2-renovado-buraca-pronto-a-habitar-ID1iSo6",
  "transaction": "sale",
  "propertyType": "apartment",
  "price": { "amount": 298000, "currency": "EUR" },
  "pricePerSquareMeter": { "amount": 4966.67, "currency": "EUR" },
  "areaSquareMeters": 60,
  "bedrooms": 2,
  "location": { "district": "Lisboa", "council": "Amadora", "parish": "Águas Livres", "neighborhood": "Buraca", "fullName": "Buraca, Águas Livres, Amadora, Lisboa" },
  "agency": { "name": "ZOME PR1ME", "type": "agency" },
  "isPrivateOwner": false,
  "postedAt": "2026-09-14T10:51:02Z"
}
```

| Field | Meaning |
|---|---|
| `id` | **This API's own ID** — `<source>:<slug>`. Always use this exact string (never a raw portal URL or numeric ad ID) to fetch the listing's detail later. |
| `source` | Which portal the listing came from: `imovirtual`, `casasapo`, `fotocasa`, or `idealista`. |
| `transaction` | `sale` or `rent`. |
| `propertyType` | `apartment` or `house`. |
| `price` | Asking price. For `rent` listings, this is the **monthly** rent. |
| `pricePerSquareMeter` | Price ÷ floor area — either the source's own figure, or computed by this API when the source doesn't expose it. |
| `bedrooms` | Number of bedrooms, normalized across every source's own convention — see [Dos and don'ts](#dos-and-donts). |
| `location` | Structured place names (not coordinates) — availability varies by source. |
| `isPrivateOwner` | `true`/`false` when known, `null` when the source doesn't expose a reliable signal (see caveats in `EXPLANATION.md`). |

Listing **detail** (`GET /listings/:id` and the section endpoints) adds richer fields on top of
this: `description`, `images`, `characteristics` (raw source-specific key/value pairs), plus a
normalized set of fields where available — `bathrooms`, `floor`, `totalFloors`,
`usableAreaSquareMeters`, `plotAreaSquareMeters`, `constructionYear`, `condition`, `orientation`,
`reference`, `updatedAt`, `coordinates`, `address`, `advertiser`, `amenities`, `hasElevator`,
`isFurnished`, `isNewConstruction`, `isTemporaryRental`, `hasVirtualTour`, `media`, and `energy`.
Not every source exposes every field — an unavailable scalar is `null`, an unavailable list is
`[]`, never a guessed value.

***

### Endpoints

#### `GET /health`

No `X-API-Key` required (the Apify token is still required to reach the Standby URL at all).

```bash
curl -H "Authorization: Bearer YOUR_APIFY_TOKEN" "$BASE/health"
```

```json
{ "error": null, "data": { "status": "up", "uptimeSeconds": 42 }, "message": "iberian-real-estate-api is healthy" }
```

#### `GET /listings/search`

Search for listings across every source for a country (or the one(s) you name), merged into one
result list.

| Param | Values | Notes |
|---|---|---|
| `location` | free text, e.g. `lisboa` | Not a fuzzy geocoder — see [Location names](#location-names-what-to-pass) below. |
| `type` | `sale` *(default)*, `rent` | |
| `propertyType` | `apartment` *(default)*, `house` | |
| `minPrice`, `maxPrice` | numbers (EUR) | Monthly rent for `type=rent`. |
| `bedrooms` | a number | `6` means "6 or more". |
| `country` | `pt` *(default)*, `es`, `it`, `fr` | |
| `source` | comma-separated, e.g. `imovirtual,casasapo` | Must be valid for the chosen `country`. |
| `page` | 1-based page number | Same page number is requested from every source; they don't share one unified page sequence. |

```bash
curl "${AUTH[@]}" \
  "$BASE/listings/search?location=lisboa&type=sale&minPrice=150000&maxPrice=350000&bedrooms=2"
```

```json
{
  "error": null,
  "message": "Found 21 listing(s) across 2/2 source(s).",
  "data": {
    "query": { "location": "lisboa", "minPrice": 150000, "maxPrice": 350000, "type": "sale", "bedrooms": 2, "propertyType": "apartment", "country": "pt", "page": 1 },
    "count": 21,
    "sources": [
      { "source": "imovirtual", "count": 37, "error": null },
      { "source": "casasapo", "count": 11, "error": null }
    ],
    "listings": [ { "...": "...(one listing object per result, see above)..." } ]
  }
}
```

`sources[].count` is each source's raw contribution *before* filters are applied; the top-level
`count` is what's left after `propertyType`/location/`bedrooms`/price filtering. A source that
errors shows `count: 0` and a non-null `error` — the request still succeeds with whatever other
source(s) returned (see [Dos and don'ts](#dos-and-donts)).

#### `GET /listings/search/summary`

Same parameters as `/listings/search`, but instead of the listings themselves, returns price and
price-per-m² statistics (average, median, min, max) for just the current search page — a quick
"what does this search look like on average" without paging through every result yourself.

```bash
curl "${AUTH[@]}" "$BASE/listings/search/summary?location=lisboa"
```

#### `GET /listings/search/facets`

Same parameters as `/listings/search`. Returns observed value counts (by `source`,
`propertyType`, `transaction`, `bedrooms`) for the current search page — useful for building a
"results breakdown" view without re-counting the listings yourself.

#### `GET /listings/sources`

Lists which sources are available per country, which detail "sections" exist (see below), and
the maximum batch size.

```bash
curl "${AUTH[@]}" "$BASE/listings/sources?country=es"
```

```json
{ "error": null, "data": { "countries": { "es": ["fotocasa", "idealista"] }, "sections": ["media", "features", "location", "advertiser", "pricing"], "maxBatchSize": 20 }, "message": "Listing source capabilities." }
```

#### `GET /listings/:id`

Full detail for one listing, by the `id` exactly as returned from search (never a raw portal URL
or numeric ad ID — see [Dos and don'ts](#dos-and-donts)).

```bash
curl "${AUTH[@]}" \
  "$BASE/listings/imovirtual:t2-renovado-buraca-pronto-a-habitar-ID1iSo6"
```

Returns the listing object plus `description`, `images`, `characteristics`, and the normalized
detail fields listed under [The listing object](#the-listing-object) above.

A listing that's expired, removed, or never existed returns a plain `404` in the standard error
envelope — not a `500`.

> **Fotocasa IDs contain slashes** (e.g. `fotocasa:es/comprar/vivienda/madrid-capital/piso-ejemplo/301002/d`).
> This is expected — pass the ID exactly as returned, raw or URL-encoded; both work.

#### Listing detail sections

Instead of fetching the full detail every time, these return just one slice of it (same caching,
same ID rules as `/listings/:id`):

| Endpoint | Returns |
|---|---|
| `GET /listings/media/:id` | Images, typed media, virtual-tour availability. |
| `GET /listings/features/:id` | Property features, amenities, energy rating, raw source characteristics. |
| `GET /listings/location/:id` | Location, address, coordinates. |
| `GET /listings/advertiser/:id` | Agency/advertiser info, private-owner flag, reference. |
| `GET /listings/pricing/:id` | Price, price per m², price reduction, posting/update dates. |

```bash
curl "${AUTH[@]}" "$BASE/listings/features/idealista:pt:35410511"
```

#### `POST /listings/batch`

Fetch up to 20 listings' detail in one call (up to 4 fetched concurrently).

```bash
curl -X POST "${AUTH[@]}" -H "Content-Type: application/json" \
  -d '{"ids":["idealista:pt:35410511","imovirtual:listing-slug-from-search"]}' \
  "$BASE/listings/batch"
```

```json
{
  "error": null,
  "message": "Batch listing results.",
  "data": {
    "count": 2,
    "succeeded": 1,
    "results": [
      { "id": "idealista:pt:35410511", "listing": { "...": "..." }, "error": null, "status": 200 },
      { "id": "imovirtual:listing-slug-from-search", "listing": null, "error": "...", "status": 404 }
    ]
  }
}
```

One failing ID never fails the whole batch — the top-level HTTP status is still `200`; check
each result's own `error`/`status`. Results preserve the order you sent the IDs in.

#### `GET /areas/:area/stats`

The current price-per-m² for sale and rent listings in an area, plus a derived gross
rental-yield estimate — computed live from what's actually listed right now.

| Param | Values | Notes |
|---|---|---|
| `:area` | free text, e.g. `cascais` | Resolved the same way as `location` — see [Location names](#location-names-what-to-pass). |
| `propertyType` | `apartment` *(default)*, `house` | |
| `country` | `pt` *(default)*, `es`, `it`, `fr` | |
| `source` | comma-separated | |

```bash
curl "${AUTH[@]}" "$BASE/areas/cascais/stats"
```

```json
{
  "error": null,
  "message": "Area stats for \"cascais\".",
  "data": {
    "area": "cascais",
    "country": "pt",
    "resolvedLocation": "lisboa/cascais",
    "propertyType": "apartment",
    "sources": [ { "source": "imovirtual", "error": null }, { "source": "casasapo", "error": null } ],
    "sale": { "sampleSize": 108, "avgPricePerSquareMeter": 7622.84, "medianPricePerSquareMeter": 6947.48, "minPrice": 245000, "maxPrice": 3500000, "avgPrice": 816828.7 },
    "rent": { "sampleSize": 111, "avgPricePerSquareMeter": 53.49, "medianPricePerSquareMeter": 27.63, "minPrice": 1000, "maxPrice": 9742, "avgPrice": 3143.37 },
    "grossRentalYieldPercent": 4.77
  }
}
```

**What these numbers mean, in plain terms:**

- `avgPricePerSquareMeter` / `medianPricePerSquareMeter` are computed across every listing
  currently found for that area (combining every source in scope). `sampleSize` tells you how
  many listings that's actually based on — **check it before trusting the numbers for a small or
  less-searched area.**
- `grossRentalYieldPercent` answers "if a typical square meter here costs this much to buy, and
  rents for this much per month, what would the annual return be?" — `(medianRentPerM² × 12) ÷
  medianSalePricePerM² × 100`. It's an **area-level estimate** from today's asking prices, not a
  calculation for any specific property (this API has no way to know what one particular unit
  would rent for), and it doesn't account for vacancy, taxes, condo fees, or maintenance. See
  [Dos and don'ts](#dos-and-donts).

#### `GET /valuation`

A price estimate for a specific property, based on comparable listings currently on the market
in the same area.

| Param | Values | Notes |
|---|---|---|
| `area` | free text — **required** | Same resolution as `location`. |
| `areaSquareMeters` | a positive number — **required** | The property's floor area. |
| `bedrooms` | a number | Optional — narrows the comparable set when given. |
| `propertyType` | `apartment` *(default)*, `house` | |
| `transaction` | `sale` *(default)*, `rent` | |
| `country` | `pt` *(default)*, `es`, `it`, `fr` | |
| `source` | comma-separated | |

```bash
curl "${AUTH[@]}" \
  "$BASE/valuation?area=lisboa&areaSquareMeters=80&bedrooms=2"
```

```json
{
  "error": null,
  "message": "Estimated sale price: 386666.8 EUR (medium confidence, 4 comparable(s)).",
  "data": {
    "area": "lisboa",
    "country": "pt",
    "transaction": "sale",
    "propertyType": "apartment",
    "input": { "areaSquareMeters": 80, "bedrooms": 2 },
    "estimate": {
      "price": 386666.8,
      "priceRange": { "low": 370000.2, "high": 419440 },
      "pricePerSquareMeter": 4833.34,
      "confidence": "medium",
      "sampleSize": 4,
      "comparableCriteria": { "bedrooms": 2, "bedroomsMatched": true, "sizeWindowPercent": 30 }
    },
    "areaMarket": {
      "sale": { "sampleSize": 9, "avgPricePerSquareMeter": 4842.85, "medianPricePerSquareMeter": 5000 },
      "rent": { "sampleSize": 8, "avgPricePerSquareMeter": 21.76, "medianPricePerSquareMeter": 22.19 }
    },
    "sources": [ { "source": "imovirtual", "error": null }, { "source": "casasapo", "error": null }, { "source": "idealista", "error": null } ],
    "method": "comparables-median-price-per-sqm",
    "disclaimer": "Derived from currently listed asking prices for comparable units in the area; not an automated valuation model (AVM) and not a substitute for a professional appraisal."
  }
}
```

**In plain terms:** this looks at listings currently on the market that are a close match in
size and bedroom count, and prices your property at their *median* price per m². It is **not** a
trained machine-learning model — it's the same "comparables" approach a human appraiser (or a
real-estate portal's own "estimate" feature) uses, just automated and run live. `areaMarket`
gives you the same average/median price-per-m² that `/areas/:area/stats` reports, so you get that
context in the same response.

Always check `estimate.confidence` and `estimate.sampleSize`:

| `confidence` | Meaning |
|---|---|
| `high` | ≥ 8 comparable listings found. |
| `medium` | ≥ 3 comparable listings. |
| `low` | 1–2 comparable listings — treat the number as a rough indication only. |
| `none` | 0 comparable listings — `estimate` is `null`; only `areaMarket` is returned. |

If there aren't enough close matches, the search automatically widens (bedroom count is relaxed
first, then the size window goes from ±30% → ±50% → any size) rather than returning nothing —
`comparableCriteria` tells you exactly how wide it had to go.

#### `GET /areas/:area/deals`

Ranks an area's own currently-active listings by how far *below* the area's median price per m²
each one is — a "which of today's listings look like the best deals right now" view.

| Param | Values | Notes |
|---|---|---|
| `:area` | free text | Same resolution as `location`. |
| `propertyType` | `apartment` *(default)*, `house` | |
| `transaction` | `sale` *(default)*, `rent` | |
| `country` | `pt` *(default)*, `es`, `it`, `fr` | |
| `source` | comma-separated | |
| `limit` | 1–50 *(default 10)* | How many results to return; doesn't change how many are scored. |

```bash
curl "${AUTH[@]}" "$BASE/areas/lisboa/deals?limit=5"
```

```json
{
  "error": null,
  "message": "Found 5 potential deal(s) in \"lisboa\" out of 9 scored listing(s).",
  "data": {
    "area": "lisboa",
    "country": "pt",
    "transaction": "sale",
    "propertyType": "apartment",
    "benchmark": { "sampleSize": 9, "avgPricePerSquareMeter": 4842.85, "medianPricePerSquareMeter": 5000 },
    "scoredListings": 9,
    "unscored": 0,
    "count": 5,
    "deals": [
      { "id": "imovirtual:t3-benfica-com-garagem-ID005", "...": "...(full listing object)...", "pricePerSquareMeter": { "amount": 3591, "currency": "EUR" }, "dealScorePercent": 28.18, "benchmarkPricePerSquareMeter": 5000 }
    ],
    "sources": [ { "source": "imovirtual", "error": null }, { "source": "casasapo", "error": null }, { "source": "idealista", "error": null } ],
    "method": "percent-below-area-median-price-per-sqm",
    "disclaimer": "A heuristic ranking against currently listed asking prices in the area, not a predictor of achieved sale price or an indicator that a listing is a scam, overpriced for a hidden reason, etc."
  }
}
```

**In plain terms:** `dealScorePercent` is how far below (positive) or above (negative) the
area's median price per m² that listing sits. `deals` is sorted best-score-first. A listing with
no usable price/area data can't be scored and is excluded (counted in `unscored`). This is a
heuristic against *today's asking prices*, not a prediction of what the listing will actually
sell for, and not any kind of fraud/scam detection — see [Dos and don'ts](#dos-and-donts).

#### Idealista specialized endpoints

Idealista additionally exposes its own richer set of data endpoints (map data, location
suggestions, translations, breadcrumbs, etc.), all under the `/idealista/` prefix, all requiring
the same `X-API-Key`, all returning the same `{error,data,message}` envelope. Call
`GET /idealista/endpoints` for the full current route catalog.

| Routes (prefix each with `/idealista/`) | Parameters |
|---|---|
| `search`, `free-text`, `zones-of-interest` | `location` or `locationUri`, `type=sale\|rent`, `propertyType=apartment\|house`, `minPrice`, `maxPrice`, `bedrooms`, `page` (`free-text` also accepts `freeText`; `zones-of-interest` accepts `zoneOfInterest`) |
| `totals` | Same search parameters — returns upstream result totals. |
| `locations` | `searchField`, optionally `type` — location-name suggestions with canonical location paths. |
| `zone-experts` | `location` or `locationUri`, optionally `type`. |
| `map`, `map-grouped`, `map-no-pins`, `draw-map`, `draw-map-no-pins`, `live-map`, `live-map-no-pins` | Search filters plus map viewport parameters (`northEast`, `southWest`, `zoom`). |
| `breadcrumbs`, `free-text-url`, `draw-search-url`, `live-search-url`, `draw-search-area` | Corresponding geographic/search parameters. |
| `microsite-search`, `microsite-totals`, `microsite-map`, `microsite-map-item`, `microsite-breadcrumbs`, `microsite-configuration` | `micrositeName` plus the matching search/geography parameters. |
| `map-item`, `comment`, `translation`, `static-map`, `signed-map`, `slideshow` | Listing/media parameters (`translation` uses `adId`, `language`, `requestTranslation`). |
| `agency-branding` | Numeric `adId`. |
| `listings/:country/:id` | Country code + numeric property ID — normalized listing detail. |

```bash
curl "${AUTH[@]}" \
  "$BASE/idealista/search?country=pt&location=braga&propertyType=apartment&type=sale&page=2"
```

`country` defaults to `pt`; use `es`, `it`, or `fr` for the others. `search`/`free-text`/
`zones-of-interest`/microsite-listing responses use the same normalized listing shape as
`/listings/search`. The other dedicated routes (maps, translations, suggestions) pass the
upstream response through mostly as-is, since those don't fit the normalized listing schema.

***

### Key concepts

#### Location names: what to pass

There's no address-autocomplete/geocoding service behind `location` (or `:area`) — it's matched
against a curated list of known place names per country, with a best-effort fallback for
anything else:

- **Portugal/Spain, a known city or area name** (e.g. `lisboa`, `cascais`, `madrid`,
  `barcelona`) — resolved exactly.
- **Portugal, a specific parish** — pass an explicit path, e.g.
  `lisboa/lisboa/sao-vicente` (URL-encode the slashes: `lisboa%2Flisboa%2Fsao-vicente`).
- **Anything not recognized** — falls back to a nationwide (Portugal) or Madrid-area (Spain)
  search, filtered best-effort against the text you gave. This *never* hard-fails, but it's a
  much coarser match — **for reliable results, stick to a known city/area name.**

#### Bedroom counts

`bedrooms` always means "number of bedrooms," normalized the same way across every source, even
though the underlying portals count differently internally (one counts total rooms including the
living room, another reads it straight off the listing's own title). You never need to account
for that difference yourself — just pass/expect a plain bedroom count. `6` (in a request or a
response) always means "6 or more."

#### Partial source failures

A multi-source request (search, area stats, valuation, deals) never fails outright just because
one portal is temporarily unreachable. Every response includes a `sources` (or `sources[]`)
array — always check it for a non-null `error` on any source before assuming you got the
complete picture.

#### Freshness and caching

Every number this API returns is computed from **live listings fetched on request** — there's no
historical database or stored snapshot. To keep response times reasonable and be considerate to
the underlying sites, results are cached briefly server-side (tens of minutes) — so two requests
for the same area within a short window can return the exact same numbers even if a listing
changed in between. This API reports a live snapshot, not a transaction history.

Note also: since this runs on Apify, the Actor's own container can be recycled by the platform
between bursts of traffic (standard Standby behavior) — the in-memory cache described above
resets whenever that happens, same as a restart of the non-Apify version would.

***

### Pricing

This Actor uses pay-per-event pricing: **$4.00 per 1,000 successful API requests** (about $0.004 per request), plus a negligible $0.00005 per Actor start. `GET /health` and `GET /` are not charged, and failed requests (non-2xx responses) are not charged.

### Dos and don'ts

**Do:**

- ✅ Always send **both** the Apify `Authorization: Bearer` token and this API's own `X-API-Key`
  — they're two separate gates, not interchangeable.
- ✅ Always use the `id` exactly as returned by search/detail to fetch a listing — never
  construct one yourself from a portal URL or ad number.
- ✅ Check the `sources`/`sources[]` array on every multi-source response before treating the
  result as complete — a source can legitimately fail while others succeed.
- ✅ Check `sampleSize` (area stats) and `confidence`/`sampleSize` (valuation) before treating a
  number as reliable, especially for less-searched areas.
- ✅ Treat `grossRentalYieldPercent` as an area-level estimate, not a per-property calculation.
- ✅ Use `6` for "6 or more" bedrooms, both when querying and when reading results.
- ✅ Handle HTTP error statuses from the standard envelope (`error`/`message` both set,
  `data: null`) rather than assuming every response is a success.

**Don't:**

- ❌ Don't treat `/valuation` as a professional appraisal, a bank valuation, or financial advice
  — it's a live comparables estimate with clearly reported confidence, meant as a starting point.
- ❌ Don't treat `/areas/:area/deals` as fraud/scam detection or a guarantee a listing will sell
  at that price — it only compares a listing's price per m² to the area's current median.
- ❌ Don't assume a country outside `pt`/`es`/`it`/`fr` is supported, or that every source is
  available for every country — check [Coverage](#coverage).
- ❌ Don't expect sub-second-fresh data on every call — results are cached briefly server-side
  (see [Freshness and caching](#freshness-and-caching)).
- ❌ Don't pass an unrecognized location name and expect a precise match — see
  [Location names](#location-names-what-to-pass).
- ❌ Don't rely on `price`/`pricePerSquareMeter` as confirmed *achieved* sale/rental prices —
  every figure in this API comes from current *asking* prices.

***

### Error responses

Every error uses the standard envelope, with the HTTP status telling you the category:

| Status | Meaning |
|---|---|
| `400` | Bad request — a parameter was missing, invalid, or not valid for the given country. |
| `401` | Missing or invalid Apify token (Standby URL gate) or missing/invalid `X-API-Key` (this API's own gate). |
| `404` | The requested listing doesn't exist (removed, expired, or never existed). |
| `502` / `504` | An upstream source failed or timed out — on a multi-source endpoint, check `sources[]` first, since other sources may have still succeeded. |

```json
{ "error": "propertyType must be one of: apartment, house.", "data": null, "message": "propertyType must be one of: apartment, house." }
```

***

Looking to run, deploy, or contribute to this Actor? See [EXPLANATION.md](EXPLANATION.md) for
setup instructions, environment variables, and how everything works under the hood.

***

> ## 💬 Need faster support? Message us on Telegram: [**@pintoflow**](https://t.me/pintoflow)

# Actor input Schema

## `operation` (type: `string`):

What to run. Search operations use the Search filters. Listing operations need a Listing ID. Area operations need an Area. Valuation needs Area and Size in m2.

## `country` (type: `string`):

Used by search, sources, area, valuation and Idealista operations. For "Idealista: listing by country and ID" it is required.

## `location` (type: `string`):

City, district or area to search, for example Lisboa, Porto or Madrid.

## `type` (type: `string`):

Sale or rent.

## `propertyType` (type: `string`):

Apartment or house. Leave empty to use the API default.

## `minPrice` (type: `integer`):

Minimum price in EUR.

## `maxPrice` (type: `integer`):

Maximum price in EUR.

## `bedrooms` (type: `integer`):

Number of bedrooms. Also used by valuation.

## `page` (type: `integer`):

Results page, starting at 1.

## `source` (type: `string`):

Optional: restrict results to one listing source. Run "List sources for a country" to see valid values.

## `id` (type: `string`):

Listing ID as returned by search. Used by the getListing, getMedia, getFeatures, getLocation, getAdvertiser, getPricing and idealistaListing operations.

## `area` (type: `string`):

Area name, for example lisboa. Used by areaStats, areaDeals and valuation.

## `transaction` (type: `string`):

Sale or rent. Used by areaDeals and valuation.

## `areaSquareMeters` (type: `number`):

Property size in square metres. Required by valuation.

## `limit` (type: `integer`):

Maximum number of deals to return for areaDeals.

## `searchField` (type: `string`):

Text to look up Idealista location IDs. Required by idealistaLocations.

## Actor input object example

```json
{
  "operation": "searchListings",
  "country": "pt",
  "location": "Lisboa",
  "type": "sale",
  "page": 1,
  "transaction": "sale"
}
```

# Actor output Schema

## `results` (type: `string`):

The API response for the chosen operation: the { error, data, message } envelope plus the operation name and HTTP status.

## `output` (type: `string`):

The same response as a single JSON record.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "location": "Lisboa"
};

// Run the Actor and wait for it to finish
const run = await client.actor("pintostudio/iberian-real-estate-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "location": "Lisboa" }

# Run the Actor and wait for it to finish
run = client.actor("pintostudio/iberian-real-estate-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "location": "Lisboa"
}' |
apify call pintostudio/iberian-real-estate-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pintostudio/iberian-real-estate-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Xi04ddfu3RTpLVpuo/builds/b8yKw4PnztRbxmOTr/openapi.json
