# Fotocasa Scraper — Spain Real Estate, Prices & Agents (`haketa/fotocasa-scraper`) Actor

Scrape Fotocasa.es property listings for sale or rent across Spain — price, size, rooms, features, coordinates, photos and the agency name, phone and private-vs-agency seller. Search by location or paste URLs and export as JSON, CSV or Excel for lead generation and market research.

- **URL**: https://apify.com/haketa/fotocasa-scraper.md
- **Developed by:** [Haketa](https://apify.com/haketa) (community)
- **Categories:** Real estate, Lead generation
- **Features:** Limited permissions
- **Stats:** 5 total users, 3 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 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.

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 Real Estate Listings, Prices, Agents & Phone Leads

> **The ultimate Fotocasa data extractor on Apify.** This high-speed **Fotocasa scraper** extracts live property listings directly from [**Fotocasa.es**](https://www.fotocasa.es) — one of Spain's leading real estate and property portals. Extract comprehensive listing data including **property prices in Euros (€)**, price per square meter, surface area ($m^2$), bedroom and bathroom counts, floor level, building antiquity, complete amenity checklists, geographic coordinates (latitude & longitude), full photo galleries, real estate agency profiles, **direct broker/owner telephone leads**, and a dedicated filter to isolate **private owner listings** (`particulares`).
>
> Export structured Spanish real estate datasets instantly to **JSON, CSV, Excel, or API**.

[![Apify Actor](https://img.shields.io/badge/Apify-Actor-blue?style=flat-square\&logo=apify)](https://apify.com/haketa/fotocasa-scraper)
[![Live Data](https://img.shields.io/badge/Data-Live%20at%20Run%20Time-orange?style=flat-square)]()
[![Region](https://img.shields.io/badge/Region-Spain%20%F0%9F%87%AA%F0%9F%87%B8-red?style=flat-square)]()
[![Leads](https://img.shields.io/badge/Includes-Direct%20Phones%20%26%20Agencies-success?style=flat-square)]()
[![Operations](https://img.shields.io/badge/Comprar%20%26%20Alquiler-EUR%20\(%E2%82%AC\)-brightgreen?style=flat-square)]()
[![Pagination](https://img.shields.io/badge/Pagination-1%2C000%2B%20Unlocked-purple?style=flat-square)]()
[![Export Formats](https://img.shields.io/badge/Export-JSON%20%C2%B7%20CSV%20%C2%B7%20Excel-lightgrey?style=flat-square)]()

***

### ⚡ At a glance

| Feature | Specification |
|---|---|
| **Target Platform** | [Fotocasa Spain](https://www.fotocasa.es) (Adevinta Spain) |
| **Market Scope** | Madrid, Barcelona, Valencia, Sevilla, Málaga, Zaragoza, Bilbao, and nationwide |
| **Operations Supported** | Buy (`comprar`), Rent (`alquiler`) |
| **Property Types** | Flats, Penthouses, Houses, Chalets, Duplexes, Studios, New Developments |
| **Contact Data** | Agency name, client ID, client profile URL, direct telephone number (+34...) |
| **Seller Categorization**| Direct Private Owner (`particular`) vs. Professional Agency (`profesional`) |
| **Pagination & Depth** | Unlocked 1,000+ listings (`maxPagesPerSearch: 0` for unlimited auto-pagination) |
| **Network Architecture**| Ultra-fast pure HTTP data pipeline with Spain residential IP routing |
| **Execution Speed** | ~20–35 seconds for 60 listings; ~45 seconds for 400+ properties |
| **Export Formats** | Clean tabular datasets: JSON, CSV, XLSX, HTML Table, XML, Apify Webhooks |

***

### 🔎 Why scrape Fotocasa?

**Fotocasa** (fotocasa.es), managed by Adevinta Spain, represents one of the largest and most authoritative real estate marketplaces in Southern Europe. Hosting hundreds of thousands of active listings across Madrid, Cataluña, Andalucía, and the Balearic Islands, the portal offers unmatched insights into Spain's competitive residential housing market:

- 💰 **Precision Pricing & Historical Adjustments**: Track exact asking prices, price drops (`isReduced`), and original versus discounted prices to analyze market negotiation margins across Spanish municipalities.
- 📞 **High-Yield B2B & B2C Real Estate Leads**: Over 95% of listings feature verified telephone numbers (`phone`), offering direct pipelines to listing agents, brokerage directors, and FSBO (For Sale By Owner) private sellers.
- 🏢 **Private Owner Segmentation (`onlyPrivateOwners`)**: Filter specifically for direct private owners (`particular`) to source off-market property acquisition deals, agency representation mandates, and direct investment opportunities.
- 📐 **Granular Architectural Metadata**: Access detailed floor plans, room counts, bathrooms, built surface in $m^2$, floor height, building age (`antiquity`), elevator presence, air conditioning, and heating systems.
- 📍 **Exact Geolocation Coordinates**: Every listing includes normalized latitude and longitude coordinates, enabling seamless mapping, spatial analysis, and radius querying.

Manual collection from Fotocasa search pages is practically impossible at commercial scale due to regional pagination limits and content structuring. This **Fotocasa scraper** converts dynamic search queries into clean, deduplicated datasets ready for analytics, database ingestion, or CRM synchronization.

***

### ✨ Key features

- 🏙️ **Buy & Rent Spectrum**: Seamlessly toggle between purchase (`comprar`) and long-term rental (`alquiler`) inventory across all Spanish regions.
- 🎯 **Flexible Search Targeting**: Scrape by standardized location slugs (e.g., `madrid-capital`, `barcelona-capital`, `valencia-capital`) or paste complex Fotocasa search URLs with custom price, size, and amenity filters.
- 🔄 **Unlocked 1,000+ Deep Pagination**: Set `maxPagesPerSearch` to `0` (unlimited) and configure `maxItems` to `1000` or higher to automatically traverse result pages without artificial limits.
- 📱 **Verified Direct Telephone Numbers**: Captures normalized Spanish phone numbers (`+34...`) and advertiser classifications on nearly 100% of scraped listings.
- 🏷️ **Private Owner Lead Filter**: Built-in `onlyPrivateOwners` toggle eliminates agency listings, delivering a pure database of direct homeowner listings.
- 🛋️ **Comprehensive Amenity Detection**: Surfaces standardized flags for terraces, elevators, swimming pools, air conditioning, parking spaces, fitted kitchens, storage rooms, and heating.
- ⚡ **Lightning Fast Pure-HTTP Pipeline**: No resource-heavy browser emulation required; runs lightweight HTTP requests that deliver hundreds of records in seconds while keeping compute costs minimal.
- 🛡️ **Spain Residential Routing**: Seamlessly navigates regional geo-restrictions with automated Spain residential proxy IP assignment.

***

### 🎯 Use cases & applications

#### 1. Direct Real Estate Lead Generation

Agency brokers, proptech acquisition teams, and investment funds can filter for `onlyPrivateOwners: true` to source private homeowner listings, securing exclusive listing mandates before competing agencies make contact.

#### 2. Agency & Brokerage Intelligence

Identify which real estate agencies (`inmobiliarias`) hold the largest market share across specific urban districts (e.g., Salamanca or Chamberí in Madrid, Eixample in Barcelona). Track listing inventory and price trends.

#### 3. Investment Yield & Price-Drop Tracking

Monitor price reductions (`isReduced`, `reducedPrice`) in real time across high-demand coastal regions (Málaga, Costa del Sol, Alicante) to capture distressed asset acquisitions and high-yield rental investments.

#### 4. Proptech Inventory Synchronization

Feed proprietary real estate aggregators, mobile applications, and property valuation engines with continuously synchronized, deduplicated listing feeds across all autonomous communities.

#### 5. Automated Property Valuation Models (AVM)

Train predictive machine learning algorithms on square meterage, district coordinates, floor heights, building ages, and amenity presence to accurately estimate fair market property values.

#### 6. Relocation & Corporate Housing Services

Curate bespoke rental portfolios for expatriates, corporate transfers, and digital nomads seeking furnished accommodations in Madrid, Barcelona, or Valencia.

***

### 🧭 How to construct search queries

You can configure searches in two straightforward ways:

#### Method A: Location Slugs (Recommended for Broad Searches)

Input standardized city slugs into the `locations` array. Examples include:

- `madrid-capital`
- `barcelona-capital`
- `valencia-capital`
- `sevilla-capital`
- `malaga-capital`
- `zaragoza-capital`

#### Method B: Filtered Search URLs (Recommended for Narrow Criteria)

1. Navigate to [fotocasa.es](https://www.fotocasa.es) in your web browser.
2. Select your desired operation (Comprar / Alquiler), property type, price limits, minimum bedrooms, terrace, and elevator filters.
3. Copy the complete URL from your browser address bar.
4. Paste the URL into the `startUrls` input field. The actor will respect all applied portal filters.

***

### 📥 Input parameters

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `operation` | String | No | `"comprar"` | Operation mode: `"comprar"` (Buy) or `"alquiler"` (Rent). Overridden if `startUrls` are provided. |
| `locations` | Array of strings | No | `["madrid-capital"]` | Fotocasa municipality slugs (e.g., `["madrid-capital", "barcelona-capital"]`). |
| `startUrls` | Array of objects/strings| No | `[]` | Direct Fotocasa filtered search URLs (e.g., `https://www.fotocasa.es/es/comprar/viviendas/madrid-capital/todas-las-zonas/l`). |
| `onlyPrivateOwners` | Boolean | No | `false` | When set to `true`, filters out commercial agencies and saves only private homeowner listings. |
| `maxItems` | Integer | No | `200` | Maximum listings to collect. Set to `0` for unlimited extraction. Fast prefill is set to `60`. |
| `maxPagesPerSearch` | Integer | No | `0` | Maximum pages per search query. Set to `0` for unlimited pagination governed by `maxItems`. |
| `proxyConfiguration` | Object | No | Residential (ES) | Spain residential proxy settings. Required to bypass regional geo-blocking. |

#### Example Input (`input.json`)

```json
{
  "operation": "comprar",
  "locations": ["madrid-capital"],
  "onlyPrivateOwners": false,
  "maxItems": 150,
  "maxPagesPerSearch": 0,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"],
    "apifyProxyCountry": "ES"
  }
}
```

***

### 📤 Output dataset schema

The actor outputs clean, highly structured JSON objects with typed primitives for effortless analysis:

#### 🏷️ Core identification & classification

| Field | Type | Coverage | Description |
|---|---|---|---|
| `id` | `number` | 🟢 High | Unique numerical Fotocasa property identifier |
| `adId` | `string` | 🟢 High | Internal real estate advertisement ID |
| `url` | `string` | 🟢 High | Canonical listing URL on Fotocasa.es |
| `operation` | `string` | 🟢 High | Operation type (`comprar` or `alquiler`) |
| `propertyType` | `string` | 🟢 High | Property category (`Piso`, `Casa`, `Chalet`, `Ático`, etc.) |
| `title` | `string` | 🟢 High | Extracted listing title headline |
| `scrapedAt` | `string` | 🟢 High | ISO 8601 extraction timestamp |

#### 💶 Pricing & valuation metrics

| Field | Type | Coverage | Description |
|---|---|---|---|
| `price` | `number` | 🟢 High | Current asking price in Euros (€) |
| `priceText` | `string` | 🟢 High | Raw formatted price string (e.g. `"385.000 €"`) |
| `reducedPrice` | `number` | 🟡 Conditional | Discounted price amount if listing received a price drop |
| `isReduced` | `boolean` | 🟢 High | Boolean flag indicating whether price was recently lowered |

#### 📐 Physical specifications & layout

| Field | Type | Coverage | Description |
|---|---|---|---|
| `surface` | `number` | 🟢 High | Built surface area in square meters ($m^2$) |
| `rooms` | `number` | 🟢 High | Number of bedrooms / rooms |
| `bathrooms` | `number` | 🟢 High | Number of bathrooms |
| `floor` | `number` | 🟡 Conditional | Building floor level (e.g. 1st, 2nd, penthouse) |
| `antiquity` | `number` | 🟡 Conditional | Age of the property in years |
| `isNew` | `boolean` | 🟢 High | Indicates if property is newly constructed |
| `isNewConstruction`| `boolean` | 🟢 High | Indicates off-plan or new housing promotion |
| `amenities` | `array` | 🟢 High | Array of verified features (terrace, elevator, heating, parking, AC, etc.) |

#### 📍 Geographical location

| Field | Type | Coverage | Description |
|---|---|---|---|
| `street` | `string` | 🟡 Conditional | Street address or road identifier |
| `neighborhood` | `string` | 🟢 High | Urban neighborhood / barrio |
| `district` | `string` | 🟢 High | Municipal district |
| `city` | `string` | 🟢 High | City name (e.g., Madrid, Barcelona) |
| `province` | `string` | 🟢 High | Spanish administrative province |
| `zipCode` | `string` | 🟢 High | Spanish postal code (e.g., 28001) |
| `latitude` | `number` | 🟢 High | Exact geographical latitude coordinate |
| `longitude` | `number` | 🟢 High | Exact geographical longitude coordinate |

#### 📞 Contact & advertiser intelligence

| Field | Type | Coverage | Description |
|---|---|---|---|
| `advertiserType` | `string` | 🟢 High | Seller classification (`professional` vs. `private`) |
| `isPrivateOwner` | `boolean` | 🟢 High | `true` if posted by a private homeowner (`particular`) |
| `agencyName` | `string` | 🟢 High | Real estate agency / commercial broker name |
| `phone` | `string` | 🟢 High (~98%) | Direct contact telephone number normalized to `+34...` |
| `agencyUrl` | `string` | 🟡 Conditional | Agency storefront profile link on Fotocasa |
| `clientId` | `number` | 🟢 High | Fotocasa advertiser client identifier |
| `photoCount` | `number` | 🟢 High | Total number of high-resolution images available |
| `photos` | `array` | 🟢 High | Array of full-resolution image URLs |
| `hasVideo` | `boolean` | 🟢 High | Boolean flag indicating whether property has video tours |
| `hasVirtualTour` | `boolean` | 🟢 High | Boolean flag indicating whether 3D virtual tour is available |
| `description` | `string` | 🟢 High | Complete property description text in Spanish |

***

### 📊 Sample output record

```json
{
  "id": 182937401,
  "adId": "182937401",
  "url": "https://www.fotocasa.es/es/comprar/vivienda/madrid-capital/aire-acondicionado-calefaccion-terraza-ascensor/182937401/d",
  "operation": "comprar",
  "propertyType": "Piso",
  "title": "Piso en venta en Chamberí, Madrid",
  "price": 425000,
  "priceText": "425.000 €",
  "reducedPrice": null,
  "isReduced": false,
  "surface": 84,
  "rooms": 3,
  "bathrooms": 2,
  "floor": 3,
  "antiquity": 15,
  "isNew": false,
  "isNewConstruction": false,
  "amenities": [
    "air_conditioner",
    "heating",
    "terrace",
    "elevator",
    "equiped_kitchen",
    "cabinets"
  ],
  "street": "Calle de Santa Engracia",
  "neighborhood": "Almagro",
  "district": "Chamberí",
  "city": "Madrid",
  "municipality": "Madrid",
  "province": "Madrid",
  "zipCode": "28010",
  "latitude": 40.432812,
  "longitude": -3.696145,
  "agencyName": "Inmobiliaria Chamberí Consulting",
  "advertiserType": "professional",
  "isPrivateOwner": false,
  "phone": "+34914482011",
  "agencyUrl": "https://www.fotocasa.es/es/inmobiliaria-chamberi-consulting",
  "clientId": 94821,
  "photos": [
    "https://fotocasa.es/multimedia/images/182937401/img1.jpg",
    "https://fotocasa.es/multimedia/images/182937401/img2.jpg"
  ],
  "photoCount": 24,
  "hasVideo": true,
  "hasVirtualTour": false,
  "publishedDaysAgo": 3,
  "description": "Magnífico piso exterior situado en una de las mejores zonas de Almagro...",
  "scrapedAt": "2026-11-10T12:44:00.000Z"
}
```

***

### 🚀 How to use & programmatic integration

#### Python Integration via Apify Client

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run_input = {
    "operation": "comprar",
    "locations": ["madrid-capital", "barcelona-capital"],
    "onlyPrivateOwners": False,
    "maxItems": 300,
    "maxPagesPerSearch": 0
}

run = client.actor("haketa/fotocasa-scraper").call(run_input=run_input)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"{item.get('title')} - €{item.get('price')} - Phone: {item.get('phone')}")
```

#### Node.js / JavaScript Integration

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({
    token: 'YOUR_APIFY_TOKEN',
});

const run = await client.actor('haketa/fotocasa-scraper').call({
    operation: 'comprar',
    locations: ['valencia-capital'],
    onlyPrivateOwners: true,
    maxItems: 200,
    maxPagesPerSearch: 0,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(`Extracted ${items.length} private owner listings from Valencia.`);
```

#### Direct REST API Export

```bash
curl -X GET "https://api.apify.com/v2/datasets/<DATASET_ID>/items?format=csv&clean=true" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -o fotocasa_spain_properties.csv
```

***

### ⚖️ Comparison: Manual vs. In-House vs. Fotocasa Scraper

| Feature | Manual Browsing | Custom In-House Scraper | Fotocasa Scraper (Actor) |
|---|---|---|---|
| **Speed** | 1 property / 2 min | High maintenance | 60+ properties / 20 seconds |
| **Phone Coverage** | Copied by hand | Vulnerable to DOM changes | 98%+ automated phone extraction |
| **Private Seller Filter** | Manual visual inspection | Custom logic required | Built-in `onlyPrivateOwners` toggle |
| **Proxy Infrastructure** | None (Immediate blocks) | Requires ES residential setup | Pre-configured Spanish residential proxy |
| **Scale & Pagination** | Impractical | Capped at ~30 items | Unlocked 1,000+ items across pages |
| **Data Quality** | Frequent omissions | Prone to parser breakages | 100% typed numerical fields |

***

### 💡 Best practices for large-scale extraction

1. **Leverage `maxPagesPerSearch: 0`**: Setting `maxPagesPerSearch` to `0` allows the actor to continue paginating smoothly until your target `maxItems` is satisfied or all available pages are collected.
2. **Targeting Private Sellers**: If your goal is direct lead generation or off-market property acquisition, toggle `onlyPrivateOwners: true`. This skips institutional agencies and delivers high-converting direct contacts.
3. **Partition by District**: When scraping massive metropolitan areas like Madrid or Barcelona, create multi-URL batches partitioned by district to run in parallel and maximize dataset diversity.
4. **Automate Scheduled Updates**: Set up an Apify schedule to run daily or weekly to capture newly listed homes (`publishedDaysAgo: 0`) and track sudden price reductions.

***

### ❓ Frequently Asked Questions (FAQ)

##### Why is a Spanish (ES) residential proxy required?

Fotocasa serves an empty shell response to foreign or datacenter IP addresses. The actor comes pre-configured with Spain residential proxy routing to ensure seamless, complete page loads.

##### How many listings can I extract in a single execution?

You can scrape thousands of listings. By specifying `maxPagesPerSearch: 0` and setting `maxItems: 2000`, the crawler automatically iterates through pages until reaching your requested volume.

##### Does the scraper extract phone numbers for every property?

In over 95% of listings, Fotocasa publishes a verified direct phone number for contact inquiries. This actor extracts and formats that number into the `phone` field.

##### What is the difference between `advertiserType: professional` and `private`?

`professional` indicates a registered real estate agency (`inmobiliaria`), while `private` indicates an individual homeowner listing their own property (`particular`).

##### Can I export directly to Microsoft Excel or Google Sheets?

Yes. From the Apify Console dataset interface, you can download files directly in XLSX format or configure a webhook to sync data continuously to Google Sheets or Airtable.

***

### 🔗 Related real estate scrapers

- [Zonaprop Scraper](https://apify.com/haketa/zonaprop-scraper) — Argentina property listings, prices, and WhatsApp leads
- [Zap Imóveis Scraper](https://apify.com/haketa/zapimoveis-scraper) — Brazil residential and commercial real estate data
- [Boliga Scraper](https://apify.com/haketa/boliga-scraper) — Danish real estate portal listings and historical sales
- [Yad2 Scraper](https://apify.com/haketa/yad2-scraper) — Israel classifieds and real estate marketplace
- [Realtor.ca Scraper](https://apify.com/haketa/realtor-ca-scraper) — Canadian MLS property listings and broker details

***

### 📋 Changelog

#### Version 1.2 (2026-11)

- **Unlocked Deep Pagination**: Configured `maxPagesPerSearch` default to `0` for auto/unlimited deep pagination beyond 1,000+ items.
- **Optimized Prefill Execution**: Calibrated default prefill to 60 listings, completing test runs in under 30 seconds with 0 duplicates.
- **Enhanced Data Normalization**: Improved extraction pipelines for private seller classification (`isPrivateOwner`) and telephone parsing.
- **Cleaned Dataset Schemas**: Removed legacy schema blocks and ensured 100% strict Apify CLI compliance.
- **Documentation Overhaul**: Added comprehensive SEO keyword mapping, field coverage indicators, and architecture summaries.

#### Version 1.1 (2026-09)

- Added direct phone number extraction across all residential categories.
- Added `onlyPrivateOwners` filter for B2B lead generation.
- Integrated automated Spain residential proxy rotation.

#### Version 1.0 (2026-09)

- Initial production release supporting sale and rental listings across Fotocasa Spain.

# Changelog

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

# Actor input Schema

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

Buy or rent listings across Spain.

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

Fotocasa location slugs (e.g. madrid-capital, barcelona-capital, valencia-capital, sevilla-capital, malaga-capital). Leave empty to use Madrid.

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

Paste Fotocasa search URLs directly (open fotocasa.es, set filters, copy the URL). Overrides operation/locations.

## `onlyPrivateOwners` (type: `boolean`):

Keep only listings posted by private owners (skip agencies) — useful for direct real estate leads.

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

Stop after collecting this many listings. Set to 0 for unlimited.

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

Maximum result pages per search (each page has ~30 listings). Set to 0 for auto/unlimited governed by maxItems.

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

A Spanish (ES) residential proxy is required — datacenter IPs are geo‑blocked. Leave as the default.

## Actor input object example

```json
{
  "operation": "comprar",
  "locations": [
    "barcelona-capital",
    "valencia-capital"
  ],
  "onlyPrivateOwners": false,
  "maxItems": 60,
  "maxPagesPerSearch": 0,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "ES"
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

URL to the listings dataset items

# 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"
    ],
    "maxItems": 60,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "ES"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("haketa/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 = {
    "locations": ["madrid-capital"],
    "maxItems": 60,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "ES",
    },
}

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

```

## MCP server setup

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