# Fotocasa Scraper — Spain Real Estate, Numeric Price (`axery/fotocasa-property-scraper`) Actor

Scrape Fotocasa.es sale and rental listings with clean numeric price, structured Spanish address levels, and amenities separated from measurements.

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

## Pricing

from $1.01 / 1,000 results

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?

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 Property Scraper (Spain)

Scrapes sale and rental property listings from **fotocasa.es** over plain HTTP — no browser, no login, no cookies.

### What makes this different

**No second fetch per listing.** Unlike most real-estate Actors — including the Bayt, Funda and Immowelt Actors in this suite — Fotocasa's search page already embeds every field a detail page would: price, full address, coordinates, amenities, photos. This Actor reads it in one request per page instead of one plus a detail fetch per row, which is why its price sits lower than its two-step siblings for equivalent data.

**Price with nothing to parse.** `price.amount` comes from Fotocasa's own `rawPrice` field — already a clean number, not a display string like `"435.000 €"` that needs unpicking.

**Amenities kept separate from measurements — deliberately.** Fotocasa's source data lists rooms, bathrooms, surface area and amenity flags (air conditioning, elevator, terrace...) under the same `{key, value}` shape. For amenities, `value` is an internal catalog id that means nothing as a number; for measurements, it's the actual count or square metres. Flattening both into one list would make every value ambiguous, so this Actor splits them:

```json
"rooms": 3, "bathrooms": 2, "surface_sqm": 105, "floor": 6,
"amenities": ["air_conditioner", "elevator", "terrace"]
```

### Input

| Field | Type | Notes |
|---|---|---|
| `city` | string | A Fotocasa city slug, e.g. `madrid-capital`, `barcelona`. Not a plain city name — `madrid` alone will not resolve. |
| `transaction` | enum | `SALE` (comprar) or `RENT` (alquiler). |
| `zone` | string | A neighbourhood slug to narrow within the city, or the default to search the whole city. |
| `maxItems` | integer | Pages automatically (~31 listings/page) until this limit or the reachable depth. |
| `incremental` | boolean | Only listings not seen in previous runs. |
| `proxyConfiguration` | object | Datacenter is sufficient — no IP-reputation gate was observed on this target. |

### Known limits

- **`posted_at` is approximate.** Fotocasa exposes only a relative age ("179 days ago"), not a literal timestamp — the Actor computes a date from that, so treat it as accurate to the day, not the minute.
- **`building_age_years` is a band code**, not a literal year count — Fotocasa does not expose the latter on the search page.
- **Reachable depth is finite.** Past a certain page, Fotocasa starts repeating the last valid page instead of erroring. The Actor detects that repeat (by comparing the first listing id) and stops cleanly rather than returning duplicate rows.

### Local development

```bash
pip install -r requirements.txt
python test_local.py madrid-capital --max 20 --out sample_output.json
python test_local.py barcelona --transaction RENT --max 10
```

`sample_output.json` in this folder is real output from a live run, kept so the schema can be reviewed without running anything.

# Actor input Schema

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

A Fotocasa city slug, e.g. `madrid-capital`, `barcelona`, `valencia`. Use the exact slug Fotocasa's own URLs use, not a plain city name - `madrid` alone will not resolve.

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

Which market to search.

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

A neighbourhood slug within the city to narrow the search, or leave as the default to search the whole city.

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

Maximum listings to return. Fotocasa serves about 31 per page; the Actor pages automatically via the `pn` parameter until this limit or the reachable depth, whichever comes first.

## `incremental` (type: `boolean`):

Remember listing ids between runs and return only listings not seen before. You are charged only for the new rows. Ids are stored in this Actor's key-value store under `seen_job_ids`.

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

Apify Proxy settings. Defaults to Residential - Fotocasa was built alongside sibling real-estate sites that needed TLS-fingerprint rotation to get past their WAF, indicating the category has real IP sensitivity.

## Actor input object example

```json
{
  "city": "madrid-capital",
  "transaction": "SALE",
  "zone": "todas-las-zonas",
  "maxItems": 100,
  "incremental": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

One row per property: numeric price, Spanish address levels (neighbourhood/district/city/province), rooms, surface, amenities, and photos.

# 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-capital",
    "zone": "todas-las-zonas",
    "maxItems": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("axery/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 = {
    "city": "madrid-capital",
    "zone": "todas-las-zonas",
    "maxItems": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("axery/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 '{
  "city": "madrid-capital",
  "zone": "todas-las-zonas",
  "maxItems": 100
}' |
apify call axery/fotocasa-property-scraper --silent --output-dataset

```

## MCP server setup

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