# Spain Property Price per m2 by City & District (`bonpleincapital/spain-price-per-sqm`) Actor

Spain property price per m2 by city and district, for sale or rent: median, average and quartile asking prices from public Pisos.com ads.

License: personal use only; resale and redistribution prohibited.
Created with the help of artificial intelligence.

- **URL**: https://apify.com/bonpleincapital/spain-price-per-sqm.md
- **Developed by:** [Bon Plein Capital](https://apify.com/bonpleincapital) (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 $0.96 / 1,000 price per m2 statistics rows

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?

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

## Spain Property Price per m2 by City and District

This **Spain property price per m2 scraper** turns public Pisos.com search pages into a ready-to-use market table: the median, average and quartile asking price per square metre for a Spanish city and for each of its districts, for sale or for rent. Instead of thousands of raw ads, you get a few clean rows you can drop into a spreadsheet, a dashboard or a valuation model. Typical users are investors, relocation agents, appraisers, analysts and agencies who want fast price-per-m2 benchmarks for Madrid, Barcelona, Valencia, Sevilla, Malaga and other towns.

### What does this Actor do?

- Samples public Pisos.com search result pages for each city you give (about 30 listings per page).
- Reads price and living area from every ad, computes the price per m2 and removes ads with missing values and extreme outliers.
- Groups the clean listings by district and returns one **city row**, one **district row** per district with enough listings and one **bedrooms row** per bedroom-count group.
- Adds **bedroom-count rows** (0, 1, 2, 3, 4+ bedrooms, `level: "bedrooms"`) when the sample is large enough, so you can compare studios with family flats.
- Gives for each row: `medianPricePerSqm`, `meanPricePerSqm`, `p25PricePerSqm`, `p75PricePerSqm`, `minPricePerSqm`, `maxPricePerSqm`, `medianPrice`, `medianAreaSqm`, `avgBedrooms`, `listingsCount` and a `confidence` level (low, medium, high) based on sample size.
- Includes up to three sample listing URLs per row so you can spot-check the figures.
- Works for sale prices (EUR per m2) and for rents (EUR per m2 per month).

Figures are **asking prices** in current ads, not transaction prices, and they describe the sample read (pages per city are configurable). Read the `confidence` field before relying on a district row. The Actor reads public pages only: it never logs in, never reads private accounts and never bypasses captchas. If the portal serves an anti-bot page, the log says so and the run ends without billing.

### How to use it

1. Click **Try for free** and open the **Input** tab.
2. Enter one or more Spanish cities (for example `Madrid`, `Barcelona`).
3. Choose **For sale** or **For rent**, and the number of result pages per city (more pages mean more reliable district rows).
4. Click **Start**, then download the Overview table as JSON, CSV or Excel, or read it through the Apify API, Make, Zapier or n8n.

The prefilled input (Madrid, for sale, 2 pages, at most 5 rows) is small on purpose, so you can test the Actor for a few cents.

### Input

```json
{
  "cities": ["Madrid", "Barcelona"],
  "operation": "buy",
  "pagesPerCity": 5,
  "minListingsPerDistrict": 3,
  "maxItems": 50
}
```

| Field | Type | Meaning |
| --- | --- | --- |
| `cities` | array | Spanish cities as written on Pisos.com |
| `operation` | string | `buy` or `rent` |
| `pagesPerCity` | integer | Result pages sampled per city (1 to 30) |
| `minListingsPerDistrict` | integer | Districts below this count are left out |
| `maxItems` | integer | Maximum number of rows (city and district rows) |
| `proxyConfiguration` | object | Optional Apify Proxy |

### Output

Each row is one dataset item. Example district row:

```json
{
  "level": "district",
  "country": "ES",
  "city": "Madrid",
  "district": "Chamberi",
  "operation": "buy",
  "currency": "EUR",
  "listingsCount": 12,
  "medianPricePerSqm": 6100,
  "meanPricePerSqm": 6240,
  "p25PricePerSqm": 5300,
  "p75PricePerSqm": 7000,
  "minPricePerSqm": 4200,
  "maxPricePerSqm": 9100,
  "medianPrice": 480000,
  "medianAreaSqm": 78,
  "avgBedrooms": 2.3,
  "confidence": "medium",
  "pagesRead": 2,
  "source": "pisos.com",
  "sampledAt": "2026-10-16T09:00:00+00:00"
}
```

### How much does it cost?

This Actor uses **pay per event** pricing: one `area-stat` event per statistics row saved to the dataset, at **$1.60 per 1,000 rows**. A typical city gives one city row plus a handful of district rows, so analysing ten cities usually costs a few cents, plus a small Apify platform usage. You pay nothing when no row is produced. Apify's free plan monthly credits let you try it first.

### FAQ

#### Which portal and which countries are covered?

Spain only, from Pisos.com. For raw listings in Spain, Italy, Portugal and France, use a listings scraper instead; this Actor is made for price-per-m2 benchmarks.

#### Why is a district missing?

Districts with fewer usable listings than `minListingsPerDistrict` are left out, and some ads do not publish a district. Increase `pagesPerCity` to get a larger sample.

#### Are these official statistics?

No. They are computed from asking prices in public ads at the time of the run, and they can differ from notary or registry data. Treat them as a market indicator, not as a valuation or financial advice.

#### Is it legal to use this Actor?

The Actor reads only public search pages and returns aggregated statistics plus links to public ads; it collects no names, phone numbers or e-mail addresses. You remain responsible for using the data lawfully, including the GDPR in the European Union, and for respecting the terms of the portal.

#### What if a city returns nothing?

Check the spelling used on Pisos.com, try again later, or add an Apify Proxy in `proxyConfiguration`. Open an issue in the **Issues** tab with your input and run link if the problem persists.

***

Created with the help of artificial intelligence.

# Changelog

This Actor's version history is a separate document: https://apify.com/bonpleincapital/spain-price-per-sqm/changelog.md

# Actor input Schema

## `cities` (type: `array`):

Cities or towns to analyse, as written on Pisos.com, for example Madrid, Barcelona, Valencia, Sevilla, Malaga.

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

Sale prices (EUR per m2) or monthly rents (EUR per m2 per month).

## `pagesPerCity` (type: `integer`):

How many result pages (about 30 listings each) are sampled per city. More pages give more reliable district figures. Keep it at 2 to test.

## `minListingsPerDistrict` (type: `integer`):

Districts with fewer usable listings are left out (the city row is always kept).

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

Stop after this many statistics rows (city rows and district rows both count). Keep it low to test the Actor cheaply.

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

Optional Apify Proxy settings. Leave empty unless Pisos.com rejects the request.

## Actor input object example

```json
{
  "cities": [
    "Barcelona",
    "Valencia"
  ],
  "operation": "buy",
  "pagesPerCity": 2,
  "minListingsPerDistrict": 3,
  "maxItems": 5
}
```

# Actor output Schema

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

One dataset item per city or district statistics row, shown in the Overview view.

# 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 = {
    "cities": [
        "Madrid"
    ],
    "operation": "buy",
    "pagesPerCity": 2,
    "maxItems": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("bonpleincapital/spain-price-per-sqm").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 = {
    "cities": ["Madrid"],
    "operation": "buy",
    "pagesPerCity": 2,
    "maxItems": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("bonpleincapital/spain-price-per-sqm").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 '{
  "cities": [
    "Madrid"
  ],
  "operation": "buy",
  "pagesPerCity": 2,
  "maxItems": 5
}' |
apify call bonpleincapital/spain-price-per-sqm --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bonpleincapital/spain-price-per-sqm"
        }
    }
}
```

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/K7cdbB6dfHHXgynOq/builds/H69e5mLbsobQv6gm2/openapi.json
