# Habitaclia Scraper: Spain & Catalonia Homes for Sale, Rent (`cprussin/habitaclia-listings`) Actor

Scrape Habitaclia homes for sale and to rent by province and city (Barcelona, Girona, Tarragona, Lleida and more): price, price drop, m², rooms, baths, energy certificate, agency, address, coordinates and photo. No login. $2 per 1,000 listings.

- **URL**: https://apify.com/cprussin/habitaclia-listings.md
- **Developed by:** [Connor Prussin](https://apify.com/cprussin) (community)
- **Categories:** Real estate, Lead generation
- **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

## Habitaclia Scraper: Spain & Catalonia Homes for Sale, Rent

**Habitaclia Scraper** exports homes for sale and to rent from Habitaclia, the leading property portal in Catalonia (Barcelona, Girona, Tarragona, Lleida) that also covers the rest of Spain, as clean JSON, CSV or Excel. It reads the same public search pages the site shows, with no login and no API key:

- ✅ **For sale and to rent**, by province and city (or comarca), e.g. Barcelona, Sant Cugat del Vallès, Girona, Baix Llobregat.
- ✅ **Price** in euro, **price drop** and previous price, price per m².
- ✅ **Size and layout**: m², plot, bedrooms, bathrooms, floor, condition, year built, features (lift, terrace, parking, A/C, ...).
- ✅ **Energy certificate**: consumption and emissions rating (A–G) and values.
- ✅ **Location**: address, district, city, comarca, province, latitude and longitude.
- ✅ **Agency** name and Habitaclia agency page. Phone numbers and emails are never output.
- ✅ Main photo and photo count. Deduplicated across pages and cities; fast plain HTTP requests, no browser. Pay only for listings written to your dataset.

### Start in one minute

Click **Start** with the prefilled input:

```json
{
  "operation": "buy",
  "province": "barcelona",
  "city": ["barcelona"],
  "maxItems": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

You get: 20 homes for sale in Barcelona with `price`, `priceDrop`, `surfaceM2`, `rooms`, `bathrooms`, `energyConsumption`, `agency`, `district` and `url`.

**Cost:** $0.04: 20 listings × $0.002, plus the $0.00005 actor-start fee.

### Use with an AI assistant

Connect the [Apify MCP server](https://mcp.apify.com) to Claude, ChatGPT, Cursor or any MCP client (`https://mcp.apify.com?tools=cprussin/habitaclia-listings` loads only this actor), then paste:

```text
Use the Apify actor cprussin/habitaclia-listings to get 100 flats for rent in Barcelona and list the cheapest per m² with district, rooms and energy rating.
```

### Recipes

#### Rentals in several towns

```json
{
  "operation": "rent",
  "province": "barcelona",
  "city": ["sabadell", "terrassa", "sant-cugat-del-valles"],
  "maxItems": 300
}
```

#### A whole comarca for sale

Comarcas work like cities: `barcelones`, `baix-llobregat`, `maresme`, `valles-occidental`.

```json
{
  "operation": "buy",
  "province": "barcelona",
  "city": ["maresme"],
  "maxItems": 1000
}
```

#### Price drops in Girona

Run it, then filter `priceDrop` > 0 in the dataset.

```json
{
  "province": "girona",
  "city": ["girona"],
  "maxItems": 500
}
```

### Who uses Habitaclia data?

- **Investors and buyers**: track asking prices, price per m², price drops and energy ratings by district.
- **Estate agents**: monitor new listings and competing agencies in their area.
- **Lettings and relocation**: compare rents across Barcelona neighbourhoods and nearby towns.
- **Analysts and journalists**: study housing supply and prices in Catalonia.
- **AI agents**: give an LLM live Spanish property listings through the Apify API or MCP server.

### How does the Habitaclia scraper work?

1. It checks habitaclia.com/robots.txt and only fetches allowed URLs (never `pag=`, sort or filter parameters, and never the phone-reveal pages).
2. It loads the search page, e.g. `habitaclia.com/comprar/viviendas/barcelona-provincia/barcelona-capital/s`, and reads the listing data embedded in it (about 29 per page).
3. It follows `/s/2`, `/s/3`, ... until `maxItems` listings or the last page.

### How do I choose which properties to scrape?

| Field                | Description                                       | Example                     |
| -------------------- | ------------------------------------------------- | --------------------------- |
| `operation`          | `buy` or `rent`                                   | `"rent"`                    |
| `province`           | Spanish province                                  | `"barcelona"`               |
| `city`               | Cities or comarcas in the province                | `["barcelona", "badalona"]` |
| `maxItems`           | Max listings in total                             | `500`                       |
| `proxyConfiguration` | Apify Proxy (on by default; datacenter is enough) | `{ "useApifyProxy": true }` |

- **City names**: plain names work (`Sant Cugat del Vallès`); the province capital (`barcelona`, `girona`, ...) maps to Habitaclia's `barcelona-capital`. If a name doesn't match, copy the slug from a Habitaclia search URL: `habitaclia.com/comprar/viviendas/barcelona-provincia/`**`sant-cugat-del-valles`**`/s`.

### What data do you get for each property?

```json
{
  "id": "487f4118-c563-43af-8214-da7154d3dca8",
  "reference": "5740V",
  "title": "Piso alto con terraza, excelentes vistas, parking y trastero en Vila Olímpica, Barcelona",
  "operation": "buy",
  "kind": "secondHand",
  "price": 770000,
  "priceDrop": null,
  "previousPrice": null,
  "pricePerM2": 7476,
  "currency": "EUR",
  "surfaceM2": 103,
  "landAreaM2": null,
  "rooms": 3,
  "bathrooms": 2,
  "propertyType": "flat",
  "propertySubtype": "flat",
  "floor": "SEVENTH",
  "condition": "ALMOST_NEW",
  "constructionYear": null,
  "features": [
    "ELEVATOR",
    "PRIVATE_PARKING",
    "AIR_CONDITIONER",
    "OFFICE_KITCHEN",
    "SUITE_BATHROOM"
  ],
  "energyConsumption": "D",
  "energyConsumptionValue": 94,
  "energyEmissions": "D",
  "energyEmissionsValue": 16,
  "energyCertificateStatus": "AVAILABLE",
  "agency": "Walter Haus S.L.",
  "agencyUrl": "https://www.habitaclia.com/inmobiliaria/walter-haus-s-l/",
  "privateSeller": false,
  "address": "Avinguda del Bogatell",
  "district": "Sant Martí",
  "city": "Barcelona Capital",
  "comarca": "Barcelonès",
  "province": "Barcelona",
  "latitude": 41.39238340019232,
  "longitude": 2.191090857316226,
  "imageUrl": "https://static.fotocasa.es/images/ads/f378822a-6a07-4c86-be95-fe6c5ae0ed64?rule=original",
  "imageCount": 42,
  "updatedAt": "2026-10-30T09:27:22.2048697+01:00",
  "url": "https://www.habitaclia.com/comprar/planta-intermedia/avinguda-del-bogatell/sant-marti/barcelona-capital/487f4118-c563-43af-8214-da7154d3dca8/d",
  "searchUrl": "https://www.habitaclia.com/comprar/viviendas/barcelona-provincia/barcelona-capital/s",
  "scrapedAt": "2026-10-30T14:05:46.223Z"
}
```

### How much does it cost to scrape Habitaclia?

Pay per event:

- **$0.002 per listing** ($2 per 1,000).
- $0.00005 per run start. Platform compute is included.

### FAQ

**Why is there no phone number?** The actor never collects phone numbers or emails. Contact the agency through the listing `url`.

**Why is `address` empty for some listings?** The advertiser chose to hide the exact address; coordinates are approximate then.

**Can I use sort or price filters?** Not yet: Habitaclia's robots.txt disallows the sort and filter parameters, so filter the dataset instead (e.g. by `price` or `rooms`).

**Is it legal?** The actor reads public listing pages that robots.txt allows, without login, and outputs listing data and agency names only. Check Habitaclia's terms for your use case.

### Related actors

- [Daft.ie Property](https://apify.com/cprussin/daft-ie-property): property for sale and to rent in Ireland.
- [QuintoAndar Listings](https://apify.com/cprussin/quintoandar-listings): homes for rent and sale in Brazil.

# Actor input Schema

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

Homes for sale (comprar) or to rent (alquiler).

## `province` (type: `string`):

Spanish province, e.g. <code>barcelona</code>, <code>girona</code>, <code>tarragona</code>, <code>lleida</code>, <code>madrid</code>, <code>valencia</code>.

## `city` (type: `array`):

Cities (or comarcas) in the province, as names or Habitaclia URL slugs: <code>barcelona</code> (the capital), <code>sant-cugat-del-valles</code>, <code>badalona</code>, <code>barcelones</code>. One search per city.

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

Stop after this many listings in total, across all cities. Each listing is billed once.

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

Apify Proxy (datacenter is enough). The actor switches to a new IP whenever a request is blocked or fails, and falls back to direct requests if the proxy keeps failing.

## Actor input object example

```json
{
  "operation": "buy",
  "province": "barcelona",
  "city": [
    "barcelona"
  ],
  "maxItems": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

No description

# 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 = {
    "province": "barcelona",
    "city": [
        "barcelona"
    ],
    "maxItems": 20,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("cprussin/habitaclia-listings").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 = {
    "province": "barcelona",
    "city": ["barcelona"],
    "maxItems": 20,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("cprussin/habitaclia-listings").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 '{
  "province": "barcelona",
  "city": [
    "barcelona"
  ],
  "maxItems": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call cprussin/habitaclia-listings --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cprussin/habitaclia-listings"
        }
    }
}
```

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/6ZyVpzp9lEewpfxxh/builds/GfIW8Ya8zY4QbgnFW/openapi.json
