# Spain Tourist Dwellings Scraper (INE by Municipality) (`steadfetch/ine-viviendas-turisticas-extractor`) Actor

Tourist dwellings, bed places, bed places per dwelling and share of all dwellings for every Spanish municipality as JSON, from the INE experimental statistic. One row per municipality, month and indicator; statistical secrecy kept as null.

- **URL**: https://apify.com/steadfetch/ine-viviendas-turisticas-extractor.md
- **Developed by:** [Steadfetch](https://apify.com/steadfetch) (community)
- **Categories:** Travel
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 result delivereds

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

## Spain Tourist Dwellings Scraper (INE by Municipality)

Returns tourist dwellings, bed places, bed places per dwelling and the share of all dwellings for every Spanish municipality as JSON, from the experimental statistic "Viviendas turisticas en Espana" of the Spanish National Statistics Institute (INE). One row per municipality, month and indicator.

- **Source:** INE Tempus API (`servicios.ine.es/wstempus`), tables 39363 and 39366. Public, no login, no CAPTCHA, no proxy.
- **Coverage:** 8,131 of the 8,132 municipalities of the INE 2026 list, including the 88 of the Canary Islands (Usansolo, created in 2025, has no series yet).
- **No personal data:** aggregated counts only.

### What it does

1. Validates the input before downloading anything: a municipality code written wrong ("3047", 3047, "99999", "03047 ") stops the run with an error that shows the value and the expected format.
2. Downloads the two INE tables once each (about 5.5 MB and 2.3 MB), for the latest month or for the month you ask for.
3. Ties every series to its five-digit INE code. The INE series carry only a name, and 34 names belong to more than one municipality (for example "Cabanes"); those are placed by the province of the neighbouring series, and a name that cannot be placed is skipped and logged, never guessed.
4. Emits one validated row per municipality, month and indicator.

Hidden figures stay visible as rows: when the INE hides a value for statistical secrecy the row has `value: null` and `valueNote: "secret"`, never a 0. When the INE publishes no figure (for example bed places per dwelling in a municipality without tourist dwellings) the row has `value: null` and `valueNote: "not available"`.

### Why this figure is not the regional registry figure

The INE does not read an administrative register. Its statistic is built from the listings of the three most used tourist-accommodation platforms: the INE scrapes them, keeps the dwellings that fit the rules of each autonomous community, removes duplicates across platforms and counts what is left. The count therefore measures dwellings **advertised on platforms**, and it will not match the regional tourist registers (for example the Valencian registry), which count registered dwellings whether or not they are advertised. Use the registry for legal status and this statistic for comparable, monthly supply by municipality across all of Spain.

### Minimum input

```json
{ "municipalityCodes": ["03047"] }
```

`{}` returns every municipality for the latest month (about 32,500 rows).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `municipalityCodes` | array of strings | no | Five-digit INE codes such as `"03047"` (Calp). Empty or missing means all municipalities. |
| `period` | string | no | Month as `YYYY-MM`. Empty means the latest month the INE has published. An earlier month works only if the INE published it; otherwise the run stops with an error that names the month asked for and the latest available one. |

### Example output

```json
{
  "url": "https://www.ine.es/jaxiT3/Tabla.htm?t=39363",
  "title": "Calp - Tourist dwellings (2026-05)",
  "scrapedAt": "2026-11-16T14:10:33.407Z",
  "municipalityCode": "03047",
  "municipalityName": "Calp",
  "source": "INE, Viviendas turisticas en Espana (estadistica experimental), www.ine.es",
  "period": "2026-05",
  "indicator": "tourist_dwellings",
  "value": 2943,
  "valueNote": null,
  "unit": "units",
  "breakdown": null
}
```

#### Output fields

| Field | Type | Description |
| --- | --- | --- |
| `url` | string | Public INE page of the table the figure comes from. |
| `title` | string | Municipality, indicator and period in words. |
| `scrapedAt` | date-time | ISO 8601 UTC timestamp of the run. |
| `municipalityCode` | string | Five-digit INE code. |
| `municipalityName` | string | Official INE name. |
| `source` | string | Statistic and publisher. |
| `period` | string | Reference month, `YYYY-MM`. |
| `indicator` | string | `tourist_dwellings`, `tourist_dwelling_bed_places`, `bed_places_per_dwelling` or `tourist_dwellings_share`. |
| `value` | number or null | The figure; null when hidden or not published, never 0 in its place. |
| `valueNote` | string or null | `secret` or `not available` when `value` is null. |
| `unit` | string | `units`, `places` or `percent`. |
| `breakdown` | object or null | Always null: the INE publishes no breakdown by municipality. |

For Calp, May 2026: 2,943 tourist dwellings, 15,792 bed places, 5.37 bed places per dwelling and 11.25 percent of all dwellings.

### Pricing

Pay-per-event with the two synthetic platform events: `apify-actor-start` at 0.00005 USD per run and `apify-default-dataset-item` at 0.002 USD per row, which is **2 USD per 1,000 results**. There is no custom event and no `Actor.charge()` call, so a row is never billed twice.

**Works on the Apify free plan** - about 2,499 results for the $5 monthly credit (N = floor((5.00 - 0.00005) / 0.002)).

Cost measured locally on 2026-11-16 (Node 24, home connection): a Calp run takes about 6 s with a peak of 161 MB resident memory; a run over all municipalities takes about 55 s, 32,524 rows and a peak of 240 MB. At 512 MB that is about 0.0023 USD of compute for the full run, around 0.07 USD per 1,000 rows, so the price keeps a wide margin. The Actor asks for a minimum of 512 MB.

### FAQ

**How fresh is the data?** The INE publishes the experimental statistic monthly; the Actor reads the latest month straight from the INE on every run. The last month seen when this was written was May 2026.

**Can I get earlier months?** Yes, one month per run: set `period` (for example `"2025-11"`). The INE does not publish this statistic every month: for Calp it has figures for 2024-02, 2024-08, 2024-11, 2025-05, 2025-11 and 2026-05 (seen on 2026-11-16). A month without figures stops the run with an error that names that month and the latest available one; it never swaps in a different month.

**Why is a value null?** `secret`: the INE hides it for statistical secrecy. `not available`: the INE publishes no figure for that municipality and indicator.

**Why do two series of the same name not get mixed up?** Province and region totals are skipped by their fixed position at the top of the table, and municipalities that share a name are placed by their neighbours; see `docs/data-map.md`.

**Does the INE endorse this Actor?** No. Data come from the INE website under CC BY 4.0: "Elaboracion propia con datos extraidos del sitio web del INE: www.ine.es". See `docs/legal-gate.md`.

### Maintenance

Tested daily by the Steadfetch QA run with the Calp input. If the INE changes the layout of the tables, the run fails with an error that says what changed instead of delivering wrong rows.

# Actor input Schema

## `municipalityCodes` (type: `array`):

Five-digit INE municipality codes as text, for example "03047" for Calp. Leave empty for all 8,132 municipalities.

## `period` (type: `string`):

Month as YYYY-MM, for example "2025-11". Leave empty for the latest month the INE has published. An earlier month works only if the INE published it (the statistic does not come out every month: Calp has figures for 2024-02, 2024-08, 2024-11, 2025-05, 2025-11 and 2026-05); any other month, or one in the future, stops the run with an error that names the month asked for and the latest available one.

## Actor input object example

```json
{
  "municipalityCodes": [
    "03047",
    "35001"
  ],
  "period": "2025-11"
}
```

# Actor output Schema

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

Dataset items validated against the item schema in dataset_schema.json (fields).

# 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 = {
    "municipalityCodes": [
        "03047"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("steadfetch/ine-viviendas-turisticas-extractor").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 = { "municipalityCodes": ["03047"] }

# Run the Actor and wait for it to finish
run = client.actor("steadfetch/ine-viviendas-turisticas-extractor").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 '{
  "municipalityCodes": [
    "03047"
  ]
}' |
apify call steadfetch/ine-viviendas-turisticas-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,steadfetch/ine-viviendas-turisticas-extractor"
        }
    }
}
```

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/5OdnvmukWnoEEeN2o/builds/pyZ13pamEtCS4Pamb/openapi.json
