# Fotocasa Scraper - Spain Property for Sale & Rent (`santis_hermes/fotocasa-property-scraper`) Actor

Scrape Spanish real estate from Fotocasa.es (pisos, casas, alquiler, venta): price, price per m2, rooms, size, photos, coordinates, energy rating, agency. Real published-in-last-N-days filter and only-new mode.

- **URL**: https://apify.com/santis_hermes/fotocasa-property-scraper.md
- **Developed by:** [Santi](https://apify.com/santis_hermes) (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 $2.00 / 1,000 listings

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

## Fotocasa Scraper: Spain property for sale and rent with a working date filter

Scrape **Spanish real estate from Fotocasa.es**: homes, flats (pisos), houses, new builds, offices and land for sale (comprar) or rent (alquiler). Each listing comes back as clean data: price, price per m2, rooms, bathrooms, size, full description, photos, coordinates, agency and energy rating. Paste a Fotocasa search URL or type a place. Export to CSV, JSON or Excel, or call it from the API.

Use it for **Spain property market research, rental yield and price-per-m2 analysis, investor deal alerts and agency lead lists**. The "published in the last N days" filter checks each listing's real publication date, and only-new mode gives you just the new listings on every scheduled run. Works with AI agents through the Apify MCP server.

### Why this one

Other Fotocasa scrapers get the same complaints again and again. This one was built around them:

- **"Published in the last 48 hours" really works.** The filter is checked against each listing's own publication date, and results come newest-first, so the run stops as soon as it passes your cut-off (you are not billed for a long backlog).
- **Precise places.** Paste any Fotocasa search URL (province, district, neighbourhood, drawn filters) or use slugs like `madrid-capital`.
- **Price, rooms, bathrooms and size filters are applied by Fotocasa itself**, so you only pay for matching listings.
- **Only-new mode** for scheduled daily runs: listings you already received are skipped and not charged.
- **No silent empty runs.** If Fotocasa blocks the run before any data arrives, the run FAILS with the reason and charges nothing, instead of "succeeding" with zero rows.
- **Hard spending cap**: `maxItems` is exact.

### Input (main fields)

| Field | Meaning |
|---|---|
| Fotocasa search URLs | Copy from your browser after setting filters |
| Places | e.g. `madrid-capital`, used with Buy/Rent and Property type |
| Only listings from the last N days | Real publication-date check |
| Min/Max price, Min rooms, Min bathrooms, Min/Max size | Applied by Fotocasa |
| Fetch each detail page | Adds energy rating, kWh, CO2, construction type, extras |
| Only listings not seen before | Remembers IDs between runs |
| Max listings | Hard stop (default 50) |
| Proxy / Custom proxy URL | Residential proxy in Spain recommended for big runs |

### Output (one row per listing)

`id, url, transaction, propertyType, price, pricePerM2, currency, priceReduced, previousPrice, rooms, bathrooms, surfaceM2, floor, description, tags, street, neighbourhood, district, city, province, region, zipCode, latitude, longitude, exactAddress, publishedAt (Spanish local time), isNewBuild, hasVideo, hasFloorPlan, hasVirtualTour, imageCount, images[], agencyName, agencyType, agencyUrl, detailScraped, searchUrl, scrapedAt` and, with details on: `createdAt, energyRating, energyConsumptionKwh, emissionsRating, emissionsKgCo2, extraFeatures, constructionType`. Agency phone only if you switch it on.

`exactAddress=false` means Fotocasa itself shows only an approximate location for that listing.

### Output example

Three real rows from a run of this Actor (columns trimmed; each row has many more fields, see Output above):

| Type | Price (EUR) | EUR/m2 | Rooms | Size m2 | City | District | Agency |
|---|---|---|---|---|---|---|---|
| Flat | 220000 | 5000 | 1 | 44 | Madrid | Latina | - |
| Flat | 234615 | 6015.8 | - | 39 | Madrid | Vicálvaro | subastaabogados.com  |
| Flat | 162960 | 1940 | - | 84 | Madrid | Villaverde | subastaabogados.com  |

### Pricing

Pay per event: **$0.002 per listing**, plus **$0.003 per detail page** if enabled. 1,000 listings = $2.00. See PRICING.md for how that compares.

### Notes and limits

- Result pages go deep (page 300 = 9,000 listings answered normally in our test) but the default is 40 pages per search; raise "Max result pages" for big areas.
- Only publicly visible listing data is collected; no logins. Agency phone numbers are off by default. Use the data in line with Fotocasa's terms and Spanish/EU data-protection law for any personal data.
- Run it on a schedule with "only listings not seen before" to build a new-listings feed.

### FAQ

**How much does it cost?** Pay per event: $0.002 per listing, plus $0.003 per listing detail page (adds energy rating and extra features) if you switch details on, plus a $0.00005 start event per run (per GB of memory). 1,000 listings = $2.00 before details. You are not charged for items skipped by filters or only-new mode, duplicates, or anything past your max-items limit. Prices are on the Pricing tab and in PRICING.md.

**Is there a limit on results?** `maxItems` is a hard cap you set per run (default 50). Runs also stop at the paging limit in the input (`maxPagesPerSearch`). The source site may cap how deep its own search goes; see Notes and limits.

**Is it legal?** The Actor collects only publicly visible data from Fotocasa.es, with no logins. You remain responsible for using the data in line with the site's terms and data-protection law (GDPR/UK GDPR), especially for personal data.

**Do I need proxies?** Not for normal runs: the default input works without one (no proxy is used). For very large runs you can add an Apify proxy or your own proxy URL in the Proxy configuration field; that cost is then yours.

**Can I schedule it?** Yes: use Apify Schedules or the API; a daily schedule with "only new" mode and a max-age filter gives a new-listings alert feed.

**Which export formats are available?** Download the dataset as JSON, CSV, Excel, XML, HTML or RSS from the Console or API, or pull it with the Apify API/clients (Python, JavaScript) and integrations such as Make, Zapier, n8n, Google Sheets.

**Something broke or a field is missing?** Open an issue on the Actor's Issues tab with the run link.

### Use with AI agents / MCP

Agents can call this Actor through the [Apify MCP server](https://mcp.apify.com) (`https://mcp.apify.com`). Add the Actor to the server, or let the agent find it with the `search-actors` tool, then call it by name:

- Actor: `santis_hermes/fotocasa-property-scraper`
- Example prompt: "Get 3 flats for sale in Madrid from Fotocasa with price per m2."
- Minimal input:

```json
{
  "locations": [
    "madrid-capital"
  ],
  "operation": "buy",
  "maxItems": 3
}
```

Results come back as dataset items (structured JSON), so an agent can read them directly. Keep `maxItems` small for agent calls to control cost. Docs: https://docs.apify.com/platform/integrations/mcp

### Feedback

If this saved you time, a rating on the Store page helps others find it. If it did not work for you, please open an issue on the Issues tab with the run link and I will look at it.

# Actor input Schema

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

Any Fotocasa results page (fotocasa.es/es/comprar/... or /alquiler/...). Copy it from your browser after setting the filters you want. Filters you set in the fields below are added on top.

## `locations` (type: `array`):

Place names as they appear in Fotocasa URLs, e.g. madrid-capital, valencia-capital, malaga-capital, sevilla-provincia (a plain name such as Barcelona searches the whole area Fotocasa files under that name). For anything precise, paste the search URL instead.

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

Buy (venta) or rent (alquiler). Only used with the Places field; URLs already contain it.

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

Type of property to search. Only used with the Places field; URLs already contain it.

## `maxAgeDays` (type: `integer`):

Checked against each listing's real publication date. Leave empty for no limit.

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

Per month when renting.

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

Highest price in EUR (per month when renting). Applied by Fotocasa.

## `minRooms` (type: `integer`):

Minimum number of bedrooms. Applied by Fotocasa.

## `minBathrooms` (type: `integer`):

Minimum number of bathrooms. Applied by Fotocasa.

## `minSurface` (type: `integer`):

Smallest size in square metres. Applied by Fotocasa.

## `maxSurface` (type: `integer`):

Largest size in square metres. Applied by Fotocasa.

## `includeDetails` (type: `boolean`):

Adds energy rating, kWh, construction type and extra features. Slower and billed as an extra event.

## `onlyNew` (type: `boolean`):

Remembers listing IDs between runs (in a store called fotocasa-seen). Good for scheduled daily runs.

## `includeAgencyPhone` (type: `boolean`):

Business phone shown on the listing. Off by default.

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

Hard stop. You are never charged for more than this.

## `maxPagesPerSearch` (type: `integer`):

30 listings per page.

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

Apify Proxy (residential, country ES recommended) or your own proxy URLs.

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

Optional. Example: http://user:pass@host:port . Overrides the proxy setting above.

## Actor input object example

```json
{
  "locations": [
    "madrid-capital"
  ],
  "operation": "buy",
  "propertyType": "homes",
  "includeDetails": false,
  "onlyNew": false,
  "includeAgencyPhone": false,
  "maxItems": 50,
  "maxPagesPerSearch": 40,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

All scraped listings as a table with the key columns.

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

Every scraped listings item with all fields.

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

Counts for the run: items pushed, skipped, charged events, block status.

# 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 = {
    "locations": [
        "madrid-capital"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("santis_hermes/fotocasa-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 = {
    "locations": ["madrid-capital"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("santis_hermes/fotocasa-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 '{
  "locations": [
    "madrid-capital"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call santis_hermes/fotocasa-property-scraper --silent --output-dataset

```

## MCP server setup

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