# Fotocasa.es - Spanish Real Estate (`swerve/fotocasa-scraper`) Actor

Scrape fotocasa.es real estate listings from Spain. Returns price, rooms, area, location, agency, image gallery, and listing age for sale and rent listings across all Spanish cities.

- **URL**: https://apify.com/swerve/fotocasa-scraper.md
- **Developed by:** [Swerve](https://apify.com/swerve) (community)
- **Categories:** Real estate, Lead generation
- **Stats:** 7 total users, 1 monthly users, 90.6% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 listings

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Fotocasa.es Scraper - Spanish Real Estate API

Extract real estate listings from [fotocasa.es](https://www.fotocasa.es/), Spain's leading real-estate portal. Returns rich structured data per listing: price, area, rooms, location, agency, image gallery, and listing type.

### What you get per listing

- `listingId`, `url` — unique ID and direct link
- `listingType` — `sale` or `rent`
- `propertyType` — apartment subtype (e.g. PENTHOUSE, INTERMEDIATE\_FLOOR, GROUND\_FLOOR, ATTIC)
- `title` — synthesized from address + zone
- `price` (EUR), `pricePerSqm`
- `rooms`, `bathrooms`, `areaSqm`
- `floor` — human-friendly Spanish ordinal (e.g. "4ª Planta", "Bajo", "Sótano")
- `city`, `neighbourhood`
- `agencyName` — listing agency / publisher name
- `imageUrl` — cover photo
- `isFeatured` — true for promoted (Top+) listings
- `scrapedAt`

### How to use

**Easy mode (recommended):** type a Spanish city name and pick listing type.

```json
{
  "city": "Madrid",
  "listingType": "sale",
  "maxItems": 200
}
```

Other examples:

```json
{ "city": "Barcelona", "listingType": "rent", "maxItems": 100 }
{ "city": "Valencia", "listingType": "sale", "maxItems": 50 }
{ "city": "Sevilla", "listingType": "sale", "maxItems": 100 }
```

**Power-user mode:** for finer filters (price range, sub-neighborhoods, specific room counts), set them on fotocasa.es, copy the URL, paste into `searchUrl`.

### Common use cases

- **Investor monitoring** — track new listings across Madrid, Barcelona, and other Spanish cities; snapshot price changes.
- **Agencies / brokers** — pull competitor listings + agency activity for your market.
- **Market analytics** — supply, average price/m² by neighborhood, featured-listing share.
- **Lead generation** — combine listing data with publisher info to identify high-volume agencies.

### Data quality

In testing across Madrid, Barcelona, and Valencia (sample of 80+ listings):

| Field | Fill rate |
|---|---|
| price, areaSqm, floor, propertyType | 100% |
| title, neighbourhood, city, imageUrl | 100% |
| agencyName | ~100% (private listings rare) |
| rooms, bathrooms | 95-100% (some studio/loft listings legitimately have no `rooms` value) |

### Pricing

Pay per result. See the Pricing tab. Failed runs cost nothing.

### Notes

- `propertyType` and `floor` use fotocasa.es's internal labels (`INTERMEDIATE_FLOOR`, `Bajo`, etc.). These are stable identifiers; localized labels are easy to add downstream.
- The actor uses Apify's residential proxy (Spain) for reliable access.
- Pagination is automatic. Leave `maxItems` blank to scrape ALL matching listings (big Spanish cities can return thousands, so a full run may take a while); set `maxItems` to a number only if you want to cap the run and its cost.

Found a bug or have a feature request? Open an issue and I respond within 24h.

# Actor input Schema

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

Spanish city name (e.g. 'Madrid', 'Barcelona', 'Valencia', 'Sevilla'). Required unless 'Search URL' is set.

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

Sale or rent

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

Optional cap on how many listings to return. Leave blank to scrape ALL matching listings for your city or search URL (big Spanish cities like Madrid or Barcelona can return thousands, so a full run may take a while). Set a number (e.g. 50, 200, 1000) only if you want to limit the run and its cost.

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

Optional. Power-user override. Set your filters on fotocasa.es (price range, sub-area, room count, etc.), copy the URL from your browser, paste here. Bypasses the structured inputs above.

## Actor input object example

```json
{
  "city": "Madrid",
  "listingType": "sale"
}
```

# 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 = {
    "city": "Madrid"
};

// Run the Actor and wait for it to finish
const run = await client.actor("swerve/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 = { "city": "Madrid" }

# Run the Actor and wait for it to finish
run = client.actor("swerve/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 '{
  "city": "Madrid"
}' |
apify call swerve/fotocasa-scraper --silent --output-dataset

```

## MCP server setup

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