# Fotocasa Spain Property Scraper (`devilscrapes/fotocasa-spain-property-scraper`) Actor

Scrape structured property listings from Fotocasa.es, Spain's #1 real-estate portal — price, rooms, bathrooms, surface m², full address, coordinates, features, description, and photo URLs. Per-listing fault isolation keeps one bad record from failing the run. Export to JSON or CSV.

- **URL**: https://apify.com/devilscrapes/fotocasa-spain-property-scraper.md
- **Developed by:** [DevilScrapes](https://apify.com/devilscrapes) (community)
- **Categories:** Real estate
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

<div align="center">
  <img src=".actor/icon.svg" width="160" alt="Devil Scrapes mark" />

## Fotocasa Spain Property Scraper

**💰 $4.20 / 1 000 results**  ·  pay only for results  ·  no credit card to try

*We do the dirty work so your dataset stays clean.* 😈

Scrape structured property listings from Fotocasa.es, Spain's #1 real-estate portal — price, rooms, bathrooms, surface m², full address, coordinates, features, description, and photo URLs. Per-listing fault isolation keeps one bad record from failing the run. Export to JSON or CSV.

</div>

***

### 🎯 What this scrapes

Fotocasa.es is Spain's #1 property portal and the default place millions of buyers, renters, and investors search for homes. This Actor walks its search-results pages — paste a location/zone slug or a full search URL — and pulls every listing's price, building type, rooms, bathrooms, surface area, full address (province/city/district/neighbourhood/zip), coordinates, dynamic features, up to ~18 photo URLs, and the full listing description, straight from the page's own embedded JSON payload. Every row is validated against a strict Pydantic schema before it ships, and one malformed listing never takes down the rest of the run. Built on `curl-cffi` with browser TLS impersonation and Spain-pinned residential proxy exits.

### 🔥 What we handle for you

- 🛡️ **Browser fingerprint rotation** — `curl-cffi` impersonates real Chrome / Firefox / Safari TLS handshakes so the target sees a browser, not Python.
- 🌐 **Residential proxy rotation** via Apify Proxy — fresh session and exit IP on every block.
- 🔁 **Retries with exponential backoff** on `408 / 429 / 5xx` — up to 5 attempts per page, `Retry-After` honoured.
- 🧱 **Rate-limit-aware pacing** — when the target pushes back, we slow down instead of getting banned.
- 🧊 **Clean, typed dataset rows** — Pydantic-validated, ISO-8601 timestamps, stable IDs, JSON / CSV / Excel export straight from the Apify Console.
- 💰 **Pay-Per-Event pricing** — you only pay for results that hit your dataset. No data, no charge.

### 💡 Use cases

- **Market pricing analytics** — track asking prices per m² by city, district, and neighbourhood across Spain.
- **Investor / prop-tech feeds** — pipe structured listings into a valuation or underwriting model.
- **Buyer alerting** — diff successive runs on a saved search to catch new listings and price drops.
- **Agency benchmarking** — aggregate <code>agency\_alias</code> and <code>agency\_type</code> to map professional vs. private supply.
- **Geo/map integrations** — <code>latitude</code>/<code>longitude</code> plug straight into mapping and clustering tools.

### ⚙️ How to use it

1. Click **Try for free** at the top of the page.
2. Fill in the input form — most fields have sensible defaults.
3. Click **Start**. Output streams into the run's dataset.
4. Export from **Storage → Dataset** as JSON, CSV, or Excel — or fetch via the API.

### 📥 Input

| Field | Type | Required | Default | Notes |
|---|---|:--:|---|---|
| `searchUrl` | `string` | no | None | Full Fotocasa.es search-results URL pasted from your browser (must start with <code>https://www.fotocasa.es/</code>).… |
| `locationSlug` | `string` | no | None | Fotocasa location segment, e.g. <code>madrid-capital</code>, <code>barcelona-capital</code>. Copy it from a Fotocasa… |
| `zoneSlug` | `string` | no | 'todas-las-zonas' | Fotocasa zone segment within the location, e.g. <code>todas-las-zonas</code> for all zones, or a specific district slug. |
| `transactionType` | `string` | no | 'buy' | <code>buy</code> maps to Fotocasa's <code>comprar</code> section, <code>rent</code> to <code>alquiler</code> (rent-URL… |
| `propertyTypeId` | `integer` | no | None | Raw Fotocasa <code>propertyTypeId</code> filter, copied from a filtered search URL. Leave empty for all property types. |
| `minPrice` | `integer` | no | None | Exclude listings priced below this amount, in euros. Applied after fetching (client-side). |
| `maxPrice` | `integer` | no | None | Exclude listings priced above this amount, in euros. Applied after fetching (client-side). |
| `maxPages` | `integer` | no | 10 | Stop paginating after this many Fotocasa result pages (each page carries roughly 30 listings, but page size is read… |
| `maxResults` | `integer` | no | 300 | Stop once this many validated listings have been pushed to the dataset, even mid-page. |
| `proxyConfiguration` | `object` | no | {'useApifyProxy': True, 'apifyProxyGroups': \['RESIDENTIAL']} | Apify Proxy — RESIDENTIAL group, pinned to Spain (ES). A wrong-country exit risks wrong currency rendering or being… |

#### Example input

```json
{
  "locationSlug": "madrid-capital",
  "zoneSlug": "todas-las-zonas",
  "transactionType": "buy",
  "maxPages": 1,
  "maxResults": 3,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

### 📤 Output

Every row is one dataset item.

| Field | Type | Notes |
|---|---|---|
| `listing_id` | `integer` | Fotocasa internal numeric listing ID. |
| `ad_id` | `string` | Fotocasa advert UUID (realEstateAdId). |
| `detail_url` | `string` | Absolute URL to the listing's detail page on fotocasa.es. |
| `price_display` | `string` | Human-formatted price as shown on the site, e.g. '1.850.000 €'. |
| `price_eur` | `integer` | Asking price as an integer in euros. |
| `reduced_price_eur` | `['integer', 'null']` | Reduced/discounted price in euros, when the listing advertises one. |
| `building_type` | `string` | Building type, e.g. Flat, House. |
| `building_subtype` | `['string', 'null']` | Building subtype, e.g. SemidetachedHouse. |
| `transaction_type_id` | `integer` | Fotocasa internal transaction type ID (sale vs rent). |
| `rooms` | `['integer', 'null']` | Number of bedrooms. |
| `bathrooms` | `['integer', 'null']` | Number of bathrooms. |
| `surface_m2` | `['integer', 'null']` | Surface area in square metres. |
| `address_country` | `['string', 'null']` | Country name, e.g. España. |
| `address_province` | `['string', 'null']` | Spanish province. |
| `address_city` | `['string', 'null']` | City. |
| `address_district` | `['string', 'null']` | District within the city. |
| `address_neighborhood` | `['string', 'null']` | Neighbourhood within the district. |
| `address_zip_code` | `['string', 'null']` | Postal code. |
| `latitude` | `['number', 'null']` | Listing latitude. |
| `longitude` | `['number', 'null']` | Listing longitude. |
| `dynamic_features` | `array` | List of Fotocasa feature flags, e.g. IS\_EXTERIOR, IS\_LUXURY. |
| `image_urls` | `array` | List of listing photo URLs (up to ~18). |
| `description` | `string` | Full listing description text (Spanish). |
| `is_new` | `boolean` | Whether the listing was recently published. |
| `is_new_construction` | `boolean` | Whether the property is new-build construction. |
| `is_opportunity` | `boolean` | Whether Fotocasa flags this listing as a price opportunity. |
| `listed_diff` | `['integer', 'null']` | Numeric age of the listing in listed\_unit units. |
| `listed_unit` | `['string', 'null']` | Unit for listed\_diff, e.g. DAYS. |
| `listed_timestamp_ms` | `['integer', 'null']` | Original listing timestamp, epoch milliseconds. |
| `agency_alias` | `['string', 'null']` | Listing agency or seller display name. |
| `agency_type` | `['string', 'null']` | professional or private. |
| `phone` | `['string', 'null']` | Contact phone number, when published. |
| `location_label` | `['string', 'null']` | Short human-readable location label, e.g. Aravaca. |

#### Example output

```json
{
  "listing_id": 190914947,
  "ad_id": "ad017f94-6c23-4057-b2e6-2219e71b8cbb",
  "detail_url": "https://www.fotocasa.es/es/comprar/vivienda/madrid-capital/aire-acondicionado-terraza-zona-comunitaria-piscina/190914947/d",
  "price_display": "1.850.000 €",
  "price_eur": 1850000,
  "reduced_price_eur": null,
  "building_type": "Flat",
  "building_subtype": "SemidetachedHouse",
  "transaction_type_id": 1,
  "rooms": 8,
  "bathrooms": 6,
  "surface_m2": 485,
  "address_country": "España",
  "address_province": "Madrid",
  "address_city": "Madrid",
  "address_district": "Moncloa - Aravaca",
  "address_neighborhood": "Aravaca",
  "address_zip_code": "28023",
  "latitude": 40.45956755387569,
  "longitude": -3.7834746837336075,
  "dynamic_features": [
    "IS_EXTERIOR",
    "IS_LUXURY",
    "IS_VILLA"
  ],
  "image_urls": [
    "https://static.fotocasa.es/images/ads/6674a2a0-e114-4f53-a1f8-220abe4e08d7?rule=original"
  ],
  "description": "Gran Chalet adosado en el centro de Aravaca...",
  "is_new": false,
  "is_new_construction": false,
  "is_opportunity": false,
  "listed_diff": 1,
  "listed_unit": "DAYS",
  "listed_timestamp_ms": 1790161388100,
  "agency_alias": "FISOL",
  "agency_type": "professional",
  "phone": "+34627537863",
  "location_label": "Aravaca"
}
```

### 💰 Pricing

Pay-Per-Event — you pay only when these events fire:

| Event | USD | What it is |
|---|---:|---|
| `actor-start` | $0.20 | One-off warm-up charge per run |
| `result-scraped` | $0.004 | Per unique dataset item |

Example: 1 000 results at the rates above ≈ **$4.20**. No subscription, no minimum, no card to start — Apify gives every new account $5 of free credit.

### 🚧 Limitations

- Detail-page-only fields (if any exist beyond what the search page embeds) are out of scope for v1 — see the FAQ.
- Rent (alquiler) URLs are supported best-effort; sale (comprar) is the wire-confirmed path.
- Price filters are applied after fetching each page, not as a Fotocasa URL parameter, so a narrow price band still costs the request for out-of-range listings on that page.
- <code>propertyTypeId</code> is passed through as Fotocasa's raw internal ID — there is no confirmed ID-to-label table yet.

### ❓ FAQ

**Do I need a Fotocasa account or API key?**

No. Fotocasa publishes no public API for this data. This Actor reads the same public search-results pages a browser loads and parses the structured JSON already embedded in them.

**How do I scrape a specific search?**

Apply your filters on fotocasa.es, copy the resulting URL from your browser, and paste it into <code>searchUrl</code>. Or set <code>locationSlug</code>/<code>zoneSlug</code>/<code>transactionType</code> directly if you already know the slugs.

**Does this fetch each listing's detail page?**

Not in v1. The search-results page already embeds price, address, coordinates, features, up to ~18 photo URLs, and the full description per listing — a per-listing detail fetch would multiply request volume for no confirmed extra field.

**Is rent (alquiler) supported?**

Yes, best-effort — set <code>transactionType</code> to <code>rent</code>. The URL shape mirrors the sale (comprar) flow but wasn't independently wire-confirmed at build time; the run fails loud rather than silently mis-parsing if Fotocasa's rent pages differ.

**Why did my run return zero rows?**

Either your filters matched nothing on Fotocasa (the run still succeeds, with a status message naming the search), or the price bounds you set excluded every result on the page — try widening <code>minPrice</code>/<code>maxPrice</code>.

### 💬 Your feedback

Spotted a bug, hit a weird edge case, or need a new field? Open an
issue on the Actor's **Issues** tab on Apify Console — we ship
fixes weekly and we read every report.

***

<div align="center">

Built by **[Devil Scrapes](https://apify.com/DevilScrapes)** 😈 — a small fleet of
opinionated public-data Actors. Honest pricing, real engineering, zero fine print.

</div>

# Changelog

This Actor's version history is a separate document: https://apify.com/devilscrapes/fotocasa-spain-property-scraper/changelog.md

# Actor input Schema

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

Full Fotocasa.es search-results URL pasted from your browser (must start with <code>https://www.fotocasa.es/</code>). Takes precedence over Location slug / Zone slug / Transaction type below.

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

Fotocasa location segment, e.g. <code>madrid-capital</code>, <code>barcelona-capital</code>. Copy it from a Fotocasa search URL. Required when Search URL is left empty.

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

Fotocasa zone segment within the location, e.g. <code>todas-las-zonas</code> for all zones, or a specific district slug.

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

<code>buy</code> maps to Fotocasa's <code>comprar</code> section, <code>rent</code> to <code>alquiler</code> (rent-URL support is best-effort — see Limitations).

## `propertyTypeId` (type: `integer`):

Raw Fotocasa <code>propertyTypeId</code> filter, copied from a filtered search URL. Leave empty for all property types.

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

Exclude listings priced below this amount, in euros. Applied after fetching (client-side).

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

Exclude listings priced above this amount, in euros. Applied after fetching (client-side).

## `maxPages` (type: `integer`):

Stop paginating after this many Fotocasa result pages (each page carries roughly 30 listings, but page size is read dynamically, never hardcoded).

## `maxResults` (type: `integer`):

Stop once this many validated listings have been pushed to the dataset, even mid-page.

## `proxyConfiguration` (type: `object`):

Apify Proxy — RESIDENTIAL group, pinned to Spain (ES). A wrong-country exit risks wrong currency rendering or being blocked outright, so the Actor always forces the ES residential exit regardless of this setting's country.

## Actor input object example

```json
{
  "searchUrl": null,
  "locationSlug": "madrid-capital",
  "zoneSlug": "todas-las-zonas",
  "transactionType": "buy",
  "propertyTypeId": null,
  "minPrice": null,
  "maxPrice": null,
  "maxPages": 2,
  "maxResults": 40,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

All dataset items as JSON.

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

Same data exported to CSV.

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

Open the run dataset in the Console.

# 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 = {
    "locationSlug": "madrid-capital",
    "maxPages": 2,
    "maxResults": 40,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("devilscrapes/fotocasa-spain-property-scraper").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 = {
    "locationSlug": "madrid-capital",
    "maxPages": 2,
    "maxResults": 40,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("devilscrapes/fotocasa-spain-property-scraper").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 '{
  "locationSlug": "madrid-capital",
  "maxPages": 2,
  "maxResults": 40,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call devilscrapes/fotocasa-spain-property-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,devilscrapes/fotocasa-spain-property-scraper"
        }
    }
}
```

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/C564FPFBtm34qu5yb/builds/wmgJ2Mh1q5OzuAEN6/openapi.json
