# Spain Open Data API

> datos.gob.es: 75,000+ Spanish public datasets by title, keyword, publisher or theme, with downloads

- Vendor: `spainopendataapi` · version 1.0 · category Government Data · tags spain open data api, datos.gob.es api, spanish government data api, datos abiertos api, open datasets api, dcat api
- Datasource: custom HTTP routes
- Marketplace page: https://apiclay.com/api/spainopendataapi
- This document: https://apiclay.com/docs/spainopendataapi.md
- OpenAPI 3.1: https://apiclay.com/api/spainopendataapi/openapi.json
- MCP: connect https://api.apiclay.com/v1/mcp (see https://apiclay.com/llms.txt), then `apiclay_describe_api` with vendor `spainopendataapi`
- Updated: 2026-11-18

## About

## Spain Open Data API

Spain's national open data catalogue (datos.gob.es), which gathers more than 75,000 datasets from ministries, regions, cities and public bodies. List and page through the catalogue, find datasets by words in the title, by keyword, by publishing body or by theme, read one dataset in full, get its distributions (download links and formats), and list the publishing bodies.

Data comes from **datos.gob.es** (https://datos.gob.es). Every route calls the source's own public API and returns it unchanged.

Typical flow: `/by-title?title=agua&amp;_pageSize=10` for a dataset `id` (last part of `_about`), then `/dataset?id=` and `/distributions?id=` for its files.

### Routes

#### GET `/datasets` - Datasets
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| _pageSize | query | number | no | Items per page (up to 50). |
| _page | query | number | no | Page, from 0. |
| _sort | query | string | no | e.g. `-modified` or `title`. |

Returns: `result.items`: datasets with `_about` (the dataset page; its last part is the `id`), `title` and `description` per language, `publisher`, `theme`, `keyword`, `modified` and `distribution` (`accessURL`, `format`); plus `next` for paging.

#### GET `/dataset` - Dataset
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | yes | Dataset id, e.g. `e05068001-mapas-estrategicos-de-ruido`. |

Returns: `result.items[0]`: the full dataset record with its distributions.

#### GET `/by-title` - By title
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| title | path | string | yes | A word in the title, e.g. `agua`. |
| _pageSize | query | number | no | Items per page (up to 50). |
| _page | query | number | no | Page, from 0. |
| _sort | query | string | no | e.g. `-modified` or `title`. |

Returns: `result.items`: datasets with `_about` (the dataset page; its last part is the `id`), `title` and `description` per language, `publisher`, `theme`, `keyword`, `modified` and `distribution` (`accessURL`, `format`); plus `next` for paging.

#### GET `/by-keyword` - By keyword
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| keyword | path | string | yes | Keyword, e.g. `turismo`. |
| _pageSize | query | number | no | Items per page (up to 50). |
| _page | query | number | no | Page, from 0. |
| _sort | query | string | no | e.g. `-modified` or `title`. |

Returns: `result.items`: datasets with `_about` (the dataset page; its last part is the `id`), `title` and `description` per language, `publisher`, `theme`, `keyword`, `modified` and `distribution` (`accessURL`, `format`); plus `next` for paging.

#### GET `/by-publisher` - By publisher
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| publisher | path | string | yes | Publisher code from `/publishers`, e.g. `E05068001`. |
| _pageSize | query | number | no | Items per page (up to 50). |
| _page | query | number | no | Page, from 0. |
| _sort | query | string | no | e.g. `-modified` or `title`. |

Returns: `result.items`: datasets with `_about` (the dataset page; its last part is the `id`), `title` and `description` per language, `publisher`, `theme`, `keyword`, `modified` and `distribution` (`accessURL`, `format`); plus `next` for paging.

#### GET `/by-theme` - By theme
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| theme | path | string | yes | Theme slug, e.g. `medio-ambiente`, `economia`, `salud`, `transporte` or `turismo`. |
| _pageSize | query | number | no | Items per page (up to 50). |
| _page | query | number | no | Page, from 0. |
| _sort | query | string | no | e.g. `-modified` or `title`. |

Returns: `result.items`: datasets with `_about` (the dataset page; its last part is the `id`), `title` and `description` per language, `publisher`, `theme`, `keyword`, `modified` and `distribution` (`accessURL`, `format`); plus `next` for paging.

#### GET `/distributions` - Distributions
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | yes | Dataset id. |
| _pageSize | query | number | no | Items per page (up to 50). |
| _page | query | number | no | Page, from 0. |
| _sort | query | string | no | e.g. `-modified` or `title`. |

Returns: `result.items`: the dataset's files with `accessURL`, `format` and `title`.

#### GET `/publishers` - Publishers
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| _pageSize | query | number | no | Items per page (up to 50). |
| _page | query | number | no | Page, from 0. |
| _sort | query | string | no | e.g. `-modified` or `title`. |

Returns: `result.items`: publisher URIs; the last part is the code for `/by-publisher`.

### Caveats

- Text is mostly Spanish, with English, Catalan, Basque or Galician where the publisher adds it.
- Each dataset keeps its publisher's licence (`license`); credit the publishing body.
- Upstream responses can change over time. Verify fields before relying on them.
- Not affiliated with or endorsed by datos.gob.es.

## Pricing

- Pay as you go: 0.0012 credits/request
- Trial: 1 free requests per buyer
- Billing order: trial requests -> subscribed plan requests -> pay as you go. 1 credit's USD value is shown on the marketplace page.

## HTTP routes

Only the public, buyer-facing parts of each route are listed; vendor-side credentials stay on the gateway.

### GET /datasets — Datasets
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/datasets`
- Public query params: `_pageSize` (number), `_page` (number), `_sort` (string)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /dataset — Dataset
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/dataset`
- Public query params: `id` (string, required)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /by-title — By title
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/by-title`
- Public query params: `_pageSize` (number), `_page` (number), `_sort` (string), `title` (string, required)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /by-keyword — By keyword
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/by-keyword`
- Public query params: `_pageSize` (number), `_page` (number), `_sort` (string), `keyword` (string, required)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /by-publisher — By publisher
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/by-publisher`
- Public query params: `_pageSize` (number), `_page` (number), `_sort` (string), `publisher` (string, required)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /by-theme — By theme
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/by-theme`
- Public query params: `_pageSize` (number), `_page` (number), `_sort` (string), `theme` (string, required)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /distributions — Distributions
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/distributions`
- Public query params: `_pageSize` (number), `_page` (number), `_sort` (string), `id` (string, required)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /publishers — Publishers
- Gateway: `GET https://api.apiclay.com/v1/api/spainopendataapi/publishers`
- Public query params: `_pageSize` (number), `_page` (number), `_sort` (string)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

## Call example

```bash
curl -X GET "https://api.apiclay.com/v1/api/spainopendataapi/datasets" \
  -H "token: <YOUR_APICLAY_TOKEN>"
```

Index of every published API: https://apiclay.com/llms.txt
