# Spain Tourism by Municipality Scraper (INE Mobile Phones) (`steadfetch/ine-turismo-moviles-extractor`) Actor

Monthly domestic and inbound tourists per Spanish municipality from INE mobile phone statistics, by province of origin or country. Domestic figures are the sum of the published origin-destination pairs, a lower bound, not the official total. One row per municipality, month and indicator.

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

## Pricing

from $1.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 Tourism by Municipality Scraper (INE Mobile Phones)

Returns monthly domestic and inbound tourists per Spanish destination municipality as JSON,
from the experimental statistics of the Spanish National Statistics Institute (INE) that
measure tourism with mobile phone positions. Domestic figures are the sum of the published
origin-destination pairs (a lower bound, not the INE's official total: pairs of 30 tourists
or fewer and residents of the same province are not in the source); inbound totals are the
INE's own figure.

- **Source:** [INE, "Medicion del turismo nacional y receptor a partir de la posicion de los telefonos moviles"](https://www.ine.es/dynt3/inebase/es/index.htm?padre=8578\&capsel=8581) (public, no login, no CAPTCHA).
- **Why this Actor:** the INE JSON API refuses the municipal tables of this statistic because of their volume. The municipal figures only exist as yearly Excel workbooks of 17 to 32 MB with one sheet per month and one row per origin-destination pair. The Actor finds the right workbook, reads only the month you ask for and returns tidy rows.
- **One row per destination municipality, month, indicator and breakdown:** an all-origins row (domestic: sum of the published pairs, a lower bound; inbound: INE total) plus one row per province of origin (domestic) or per country of residence (inbound).
- **Coverage:** every Spanish municipality the INE publishes as a destination, including those of the Canary Islands. Domestic tourism from 2019-01 to the latest month (2026-09 on 16 November 2026); inbound tourism from 2019-01 to 2025-12. The layout was checked on the 2022 and 2026 domestic files and the 2025 inbound file; a file with another layout makes the run fail with a clear error instead of returning misread rows.
- **No personal data:** only aggregated counts of tourists.

### What it does

1. Reads the INEbase page of each kind you ask for (domestic, inbound or both) and finds the yearly workbook of the requested month, or of the latest month published.
2. Downloads that workbook and reads only the sheet of that month.
3. Emits one validated row per destination municipality, month, indicator and breakdown.

Indicators:

| Indicator | Kind | What it counts |
| --- | --- | --- |
| `domestic_tourists` | `internal` | Residents in Spain from **another province** who spent the night in the municipality. Sum of the origin-destination pairs the INE publishes (see "Data notes"). |
| `inbound_tourists` | `inbound` | Foreign residents who spent the night in the municipality (INE total). The INE ended this series in 2025-12 and now measures inbound tourism in another statistic; this one does not continue. |

### Minimum input

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

That returns domestic tourism in Benidorm (INE code 03031) for the latest published month:
one total row and one row per province of origin (49 rows for 2026-09). With `{}` the Actor
returns every destination municipality in Spain for the latest month (about 28,500 rows).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `municipalityCodes` | array of strings | no | Five-digit INE codes of destination municipalities with the leading zero, e.g. `"03047"` (Calp). Empty or missing means every municipality. A badly written or unknown code (`"3047"`, `3047`, `"03047 "`, `"99999"`) fails the run before anything is downloaded. A valid code with no row in the file (a small municipality below the INE threshold) gives no rows and a warning in the log. |
| `period` | string | no | Month as `YYYY-MM`. Missing means the latest published month of each kind. A month not published yet makes the run fail and says which is the latest available; it is never replaced by another month. Asking for inbound tourism after `2025-12` fails before downloading and says the series ends in 2025-12. |
| `kinds` | array of strings | no | `"internal"` (domestic tourism) and/or `"inbound"`. Default `["internal"]`. |

### Example output

```json
{
  "municipalityCode": "03047",
  "municipalityName": "Calp",
  "period": "2026-09",
  "indicator": "domestic_tourists",
  "value": 21653,
  "valueNote": "sum of published crossings (lower bound)",
  "unit": "persons",
  "breakdown": null,
  "source": "INE - Medicion del turismo a partir de telefonos moviles (estadistica experimental)",
  "url": "https://www.ine.es/experimental/turismo_moviles/exp_tmov_interno_mun_2026.xlsx",
  "title": "Calp (03047) - domestic_tourists - 2026-09",
  "scrapedAt": "2026-11-16T12:00:00.000Z"
}
```

The domestic `breakdown: null` row is the sum of the 191 origin-destination pairs the INE
published for Calp in 2026-09 (a lower bound, not the official total), which is why its
`valueNote` says so even though `value` is a number. Breakdown rows of the same month:

```json
{ "municipalityCode": "03047", "period": "2026-09", "indicator": "domestic_tourists", "value": 8371, "breakdown": { "originProvince": "Madrid", "originProvinceCode": "28" } }
{ "municipalityCode": "03047", "period": "2025-12", "indicator": "inbound_tourists", "value": 2431, "breakdown": { "country": "Reino Unido", "countryCode": "125" } }
```

### Output fields

- `municipalityCode`: INE code of the destination municipality, five digits.
- `municipalityName`: official INE name (2026 list); the name in the source file for codes that no longer exist.
- `period`: month, `YYYY-MM`.
- `indicator`: `domestic_tourists` or `inbound_tourists`.
- `value`: number of tourists, or `null` when the source hides it. For `domestic_tourists` it is always a sum of the published origin-destination pairs: a lower bound, not the official total.
- `valueNote`: literal text of the source when `value` is `null`. On `domestic_tourists` rows with `breakdown: null` it is always `"sum of published crossings (lower bound)"` while `value` is a number. `null` otherwise.
- `unit`: always `persons`.
- `breakdown`: `null` for the all-origins row. In domestic tourism that row is the sum of the published pairs (lower bound), not the official total; in inbound tourism it is the INE total. `{originProvince, originProvinceCode}` for domestic rows by province of origin (also sums of published pairs); `{country, countryCode}` for inbound rows by country of residence (INE country name in Spanish and its 3-digit INE code).
- `source`, `url`, `title`, `scrapedAt`: common Steadfetch envelope; `url` is the public INE yearly workbook the row comes from.

### Pricing

Pay per event:

| Event | When it fires | Price |
| ----- | ------------- | ----- |
| `apify-actor-start` | once per run (synthetic, automatic) | 0.00005 USD |
| `apify-default-dataset-item` | one validated row saved to the dataset (synthetic, automatic) | 0.001 USD per row = **1.00 USD per 1,000 rows** |

Works on the Apify free plan: about 4,999 rows for the $5 monthly credit (about 100 one-municipality runs of domestic tourism).

Only validated rows are pushed. There is no custom per-item event, so a row is never billed twice. Monitor Actors bill a `monitor-check` event per watched item; this extractor does not. A one-municipality run costs about 0.05 USD.

#### Cost per 1,000 results (measured locally, 16 November 2026)

| Measurement | Value |
| ----------- | ----- |
| Calp, domestic and inbound (`apify run`, real source) | 63 rows, 28 s wall clock including tool start-up, two downloads (32 MB and 17 MB) and the courtesy pauses; peak process memory about 400 MB |
| Every municipality, domestic, latest month | 28,555 rows, 82 s wall clock (most of it writing the local dataset), peak process memory about 400 MB |
| Every municipality, domestic, 2026-05 (largest sheet: 84 MB of XML) | 30,093 rows, 158 s wall clock, peak process memory 731 MB (private bytes) |
| Run memory | 1,024 MB minimum (about 40% above the largest peak measured), 2,048 MB maximum |

At 1 GB and about 30 s of platform time, a run costs roughly 0.008 GB-hours (about 0.003 USD), well below the 1 USD charged per 1,000 rows even for a one-municipality run. The platform figure has not been billed yet: no platform run has been spent on this Actor.

### Development

```bash
npm install --include=dev
npm test                     # lint + typecheck + tests (no network, no credit)
npm run publish:check
npm run build && npm run verify:build
```

Tests run on the real INE workbooks (2026 domestic, 2025 inbound) cropped to the province of Alicante, and on the two INEbase pages, saved in `test/fixtures/`. `docs/data-map.md` describes the files and the crop.

### Data notes

- **Statistical secrecy.** The INE does not publish an origin-destination pair with 30 tourists or fewer: the row is simply missing from the file, it is not marked. Domestic totals and province rows are therefore the **sum of the published pairs**, a lower bound of the real figure, lower for small municipalities and distant provinces. Inbound totals are the INE's own total; country rows below the threshold are missing.
- **Domestic tourism excludes residents of the same province** (the INE file only covers trips to another province).
- If a future file marks hidden cells with text, the row has `value: null` and the text in `valueNote`, never 0.
- Continent subtotals of the inbound file ("Total Europa", ...) are not returned; only the total and the countries.
- Rows are matched by INE code, never by name: a province total called "Madrid" never becomes the municipality of Madrid.
- The statistics are experimental: the INE may revise the files or change their layout. A layout the Actor does not recognise makes the run fail with a clear error instead of returning wrong numbers.

### FAQ

**Why is my municipality missing?** Small municipalities may have no published pair above the INE threshold in a month, so they are not in the file. The run succeeds with no rows for them and logs a warning.

**Why does inbound tourism stop in 2025-12?** The INE ended this series; it now measures inbound tourism in another statistic. Asking for a later inbound month fails with that explanation.

**Can I get several months?** Run once per `period`. Each run downloads one yearly workbook per kind.

**Does it need a proxy or a browser?** No. Plain HTTP requests and a local XLSX reader that only inflates the sheet it needs.

**What happens if the INE blocks the request?** The run aborts with a clear error and delivers nothing: no CAPTCHA solving, no proxy evasion.

### Maintenance

This Actor is **tested daily**: automated runs keep the source reachable and the output schema valid, and failures open an issue in this repository. Schema changes are announced through repository releases.

### Legal and attribution

Only public, aggregated statistics of the INE are read. The INE licenses its statistical information under Creative Commons Attribution 4.0 (CC BY 4.0), commercial reuse included. Because the Actor sums rows, cite it as: "Elaboracion propia con datos extraidos del sitio web del INE: www.ine.es". When you republish, keep the workbook `url` and the publication date shown on the INEbase page. Municipality names come from the INE list of municipalities (CC BY 4.0, "Fuente: INE, www.ine.es"). `https://www.ine.es/robots.txt` was checked by hand on 16 November 2026: for all user agents it disallows internal paths such as `/cgi-bin/`, `/buscar/`, `/Test/` and `/Admin/`, and does not disallow `/dynt3/inebase/` (the index pages) or `/experimental/` (the workbooks), the only paths this Actor requests. The Actor does not read `robots.txt` at run time. It sends an honest User-Agent with contact information and pauses between requests. See `docs/legal-gate.md`. Steadfetch is not affiliated with the INE.

# Actor input Schema

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

Five-digit INE codes of destination municipalities, with the leading zero (for example "03031" for Benidorm, "03047" for Calp). Leave empty to get every destination municipality in Spain.

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

Reference month in YYYY-MM format (for example "2026-09"). Leave empty for the latest month published for each kind. A month that is not published yet makes the run fail and tells you the latest one available. Inbound tourism ends in 2025-12.

## `kinds` (type: `array`):

"internal": domestic tourism (residents in Spain from another province). "inbound": tourism of foreign residents, a series the INE ended in 2025-12. Default: \["internal"].

## Actor input object example

```json
{
  "municipalityCodes": [
    "03031",
    "03047"
  ],
  "period": "2026-09",
  "kinds": [
    "internal",
    "inbound"
  ]
}
```

# 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": [
        "03031"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("steadfetch/ine-turismo-moviles-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": ["03031"] }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,steadfetch/ine-turismo-moviles-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/U83iReVde86wqC4Kq/builds/Ilw7RV2lOfqMr7gCy/openapi.json
