# Fotocasa Scraper — Spain Sale & Rent Listings (`crawloop/fotocasa-scraper`) Actor

Extract Spanish property listings from Fotocasa search pages: sale and rent, price, size, rooms, address, agency, and public phone. Paste a results URL or a city slug.

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

## Pricing

from $0.70 / 1,000 property listings

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Fotocasa Scraper — Spain Sale & Rent Listings

> **Disclaimer:** Unofficial tool — not affiliated with, sponsored by, or endorsed by Fotocasa or its affiliates. Data is read from publicly accessible search result pages only. No login. You are responsible for complying with applicable law (including GDPR where a phone number or agency name appears) and the site’s terms. No warranty on accuracy or availability. Provided for informational and research use.

**Fotocasa scraper** for Spanish property **for sale or for rent**: homes, offices, commercial premises, garages, land, storage, and buildings. Each row has price, m², €/m², rooms, bathrooms, address, agency, and the public phone when the search card already shows one. Use it as a **Fotocasa API alternative** from **Python**, **Node.js**, **cURL**, or **Apify MCP**, and export the dataset as JSON, CSV, or Excel.

**Best for:** Spain real estate comps, agency coverage in one city, and a filtered results URL you already built in the browser.

| Actor | Role |
| :--- | :--- |
| Fotocasa Scraper ◄── you are here | Spain sale and rent |
| [Rightmove Scraper](https://apify.com/crawloop/rightmove-scraper) | UK sale and rent |
| [SeLoger Scraper](https://apify.com/crawloop/seloger-scraper) | France sale and rent |
| [ImmobilienScout24 Scraper](https://apify.com/crawloop/immobilienscout24-scraper) | Germany rent and buy |
| [Immobiliare.it Scraper](https://apify.com/crawloop/immobiliare-it-scraper) | Italy portal: sale, rent, auctions |
| [Subito Real Estate Scraper](https://apify.com/crawloop/subito-real-estate-scraper) | Italy classifieds: sale, rent, private sellers |

### When to use this Actor

- **Search URL in, rows out** — Paste a filtered results page (city, district, price, property type). Query filters stay on every page.
- **City slug** — Leave Start URLs empty and set sale or rent, a property type, and a location slug such as `madrid-capital`.
- **Comps** — Price, m², and €/m² on every saved card.
- **Publisher and phone** — Agency name and the phone printed on the card. The phone stays empty when the card has none. There is no extra contact request and no login.

### When not to use this Actor

- **A single listing URL** — This Actor reads search result pages, not a detail URL ending in `/d`.
- **A full-country dump in one run** — Cap `maxItems`. Split by city or price band.
- **Hidden contacts** — If the card does not show a phone, the field is empty.

### Key features

- **Search HTML** — One HTTP call per results page (about 30 listings). No browser. Default **256 MB**.
- **Sale and rent** — Homes, offices, commercial premises, garages, land, storage rooms, and buildings.
- **Structured fields** — Price, rent period, surface, €/m², rooms, bathrooms, floor, coordinates, postal code.
- **Phone on the card** — Saved only when the results card already includes it.
- **Proxy off by default** — Enable Apify Proxy only if a run is blocked. Try datacenter before residential.

### Input

| Field | What it does |
| :--- | :--- |
| **Start URLs** | Fotocasa search pages. When set, the builder fields are ignored. |
| **Sale or rent** / **Property type** / **Location slug** | Builder used when Start URLs is empty. The slug is the path segment, for example `madrid-capital`. |
| **Min / max price** | Euros. Applied only by the city builder. |
| **Maximum listings** | Cap on dataset rows. Default 30. Maximum 1000. |
| **Proxy** | Off unless you enable it. |

```json
{
  "startUrls": [
    { "url": "https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l" }
  ],
  "maxItems": 30,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

Rent in Barcelona, no URL:

```json
{
  "transaction": "rent",
  "propertyType": "homes",
  "location": "barcelona-capital",
  "maxPrice": 2000,
  "maxItems": 50
}
```

### Output

One dataset row per listing.

| Field | What it is |
| :--- | :--- |
| `title`, `url`, `id` | Card title, listing URL, numeric id |
| `price`, `pricePeriod`, `currency` | Euros. `month` on rent, empty on a sale price |
| `surfaceSqm`, `pricePerSqm`, `rooms`, `bathrooms`, `floor` | Size and layout |
| `municipality`, `province`, `district`, `neighborhood`, `zipCode` | Place |
| `latitude`, `longitude` | Coordinates from the card |
| `agencyName`, `sellerType`, `phone` | Publisher. Phone only when the card shows one |
| `features`, `imageUrls`, `description`, `publishedAt` | Tags, photos, text, UTC timestamp |
| `transaction`, `propertyType`, `isNewConstruction` | Sale or rent, subtype, new-build flag |
| `searchUrl` | Results page the row came from |

```json
{
  "id": "187999533",
  "url": "https://www.fotocasa.es/es/comprar/vivienda/madrid/aire-acondicionado/187999533/d",
  "title": "Flat in Castellana",
  "transaction": "sale",
  "propertyType": "Flat",
  "price": 7490000,
  "pricePeriod": null,
  "currency": "EUR",
  "surfaceSqm": 413,
  "pricePerSqm": 18135.59,
  "rooms": 3,
  "bathrooms": 4,
  "municipality": "Madrid",
  "province": "Madrid",
  "neighborhood": "Castellana",
  "agencyName": "FORTUNY MADRID REAL ESTATE",
  "sellerType": "agency",
  "phone": "+34900000000"
}
```

### Use cases

- **City comps** — Sale prices and €/m² for flats in one district, then the same shape for rent.
- **Agency coverage** — Who is listing in a neighborhood, with the phone printed on the card.
- **Offices and commercial** — Switch property type, or paste the commercial results URL.
- **Dataset export** — One JSON row per listing, then CSV or Excel from the same dataset, or a pull with the Python and Node.js clients below.
- **Cross-border book** — Spain from this Actor, then France, Germany, or the UK from the suite.

### Integration examples

Replace `YOUR_TOKEN` with an Apify API token. The Actor id is `crawloop/fotocasa-scraper`.

#### Node.js

```javascript
import { ApifyClient } from "apify-client";

const client = new ApifyClient({ token: "YOUR_TOKEN" });
const run = await client.actor("crawloop/fotocasa-scraper").call({
  startUrls: [
    { url: "https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l" },
  ],
  maxItems: 30,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("crawloop/fotocasa-scraper").call(run_input={
    "startUrls": [
        {"url": "https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l"}
    ],
    "maxItems": 30,
})
items = client.dataset(run["defaultDatasetId"]).list_items().items
print(items)
```

#### cURL

```bash
curl "https://api.apify.com/v2/acts/crawloop~fotocasa-scraper/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"startUrls\":[{\"url\":\"https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l\"}],\"maxItems\":30}"
```

### MCP and AI assistants

Use this Actor from AI tools via [Apify MCP](https://docs.apify.com/platform/integrations/mcp).
Connect your Apify account, then call this Actor by its Store name `crawloop/fotocasa-scraper`.

Example prompts:

- "Run Fotocasa Scraper for homes for sale in madrid-capital and return the top 20 rows as JSON with price, m², and phone."
- "Scrape Fotocasa rentals in barcelona-capital under 2000 euros and summarize the median €/m²."
- "Chain Fotocasa Scraper for Madrid sale comps, then Rightmove Scraper for the same budget in London."

### Suite next step

Spain is one book. For the next country, run [SeLoger Scraper](https://apify.com/crawloop/seloger-scraper) for France, [ImmobilienScout24 Scraper](https://apify.com/crawloop/immobilienscout24-scraper) for Germany, or [Rightmove Scraper](https://apify.com/crawloop/rightmove-scraper) for the UK.

### FAQ

**Can I paste a results URL with filters?**\
Yes. Price, rooms, and district filters in the URL are kept while the Actor turns the pages.

**What is a location slug?**\
The city piece of a results path, such as `madrid-capital` or `valencia-provincia`. Copy it from a results URL. A bare city name is not looked up.

**Does a quiet search still finish?**\
A location with no listings saves zero rows and the run succeeds. A blocked session fails with a proxy hint instead of pretending the city is empty.

**Is the phone always filled?**\
Only when that number is already on the search card. Rent cards often omit it.

**How do I scrape Fotocasa with Python or Node.js?**\
Call `crawloop/fotocasa-scraper` with the clients in the integration section. The same input works from an AI assistant through Apify MCP. The dataset is one listing per row.

**Sale or rent?**\
A results URL with `/comprar/` is a sale. `/alquiler/` is a rent. If you skip the URL, set `transaction` to `sale` or `rent` and pass a location slug such as `madrid-capital`, `barcelona-capital`, or `valencia-capital`.

# Actor input Schema

## `startUrls` (type: `array`):

Fotocasa search result pages. When this list is set, the city builder below is ignored. Keep filters in the URL (price, rooms, district).

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

Used only when Start URLs is empty.

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

Used only when Start URLs is empty.

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

Path segment from a Fotocasa results URL, for example madrid-capital, barcelona-capital, or valencia-provincia. Used only when Start URLs is empty.

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

Minimum price in euros. Applied only by the city builder.

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

Maximum price in euros. Applied only by the city builder.

## `maxItems` (type: `integer`):

Maximum dataset rows for this run. About 30 listings come back per results page.

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

Leave proxy off. Direct HTTP reads the search page. Enable Apify Proxy only if a run is blocked, and try datacenter before residential.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l"
    }
  ],
  "transaction": "sale",
  "propertyType": "homes",
  "maxItems": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Default dataset items — one property listing per row.

# 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 = {
    "startUrls": [
        {
            "url": "https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawloop/fotocasa-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 = { "startUrls": [{ "url": "https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l" }] }

# Run the Actor and wait for it to finish
run = client.actor("crawloop/fotocasa-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 '{
  "startUrls": [
    {
      "url": "https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l"
    }
  ]
}' |
apify call crawloop/fotocasa-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawloop/fotocasa-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/HHiavBJjoNTeg7q8N/builds/60OLeMaDecYmRYFEY/openapi.json
