Open Government, Spain API

Free to Use
59 C
Measured Score 0 50 100 Speed 8/30 Consistency 8/20 Security 20/20 Browser access 15/15 Transparency 8/15 TESTED 2026-08-10

Overview

The Spain Open Government Data API (datos.gob.es) exposes thousands of datasets from Spanish public institutions including statistics, geography, and public services. It follows the DCAT-AP standard and requires no authentication, making it easy to query with a simple HTTP request. Perfect for exploring Spanish civic data or building data journalism tools.

Beginner Tip

Use the /api/action/package_search endpoint with the q parameter to search by keyword, or browse datos.gob.es to find specific dataset IDs before fetching them via the API.

Measurement Record

What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.

Request
GET https://datos.gob.es/apidata/catalog/dataset.json?_pageSize=5&_page=1
Result
HTTP 200 · application/json · 15,170 bytes · compressed
Response time
432 ms (median of 3) · fastest 321 ms
Transport
TLSv1.3 · TLS_AES_128_GCM_SHA256 · certificate issued by Hellenic Academic and Research Institutions CA
Browser CORS
Allowed — Access-Control-Allow-Origin: *
Served by
nginx
Recorded
2026-08-10

Fields Returned

Top-level fields present in the response we captured, with the type and value we actually received.

Field Type Value received
_about string (url) http://datos.gob.es/apidata/catalog/dataset.j…
definition string (url) http://datos.gob.es/apidata/catalog/meta/data…
extendedMetadataVersion string (url) http://datos.gob.es/apidata/catalog/dataset.j…
first string (url) http://datos.gob.es/apidata/catalog/dataset.j…
isPartOf object {4 fields}
items array [1 item]
itemsPerPage integer 5
next string (url) http://datos.gob.es/apidata/catalog/dataset.j…
page integer 1
prev string (url) http://datos.gob.es/apidata/catalog/dataset.j…
startIndex integer 6
type string (url) http://purl.org/linked-data/api/vocab#Page

Captured Response

Captured from a real request to https://datos.gob.es/apidata/catalog/dataset.json?_pageSize=5&_page=1 on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.

JSON Response · Captured
{
  "format": "linked-data-api",
  "version": "0.2",
  "result": {
    "_about": "http://datos.gob.es/apidata/catalog/dataset.json?_pageSize=5&_page=1",
    "definition": "http://datos.gob.es/apidata/catalog/meta/dataset.json",
    "extendedMetadataVersion": "http://datos.gob.es/apidata/catalog/dataset.json?_pageSize=5&_page=1&_metadata=all",
    "first": "http://datos.gob.es/apidata/catalog/dataset.json?_page=0",
    "isPartOf": {
      "_about": "http://datos.gob.es/apidata/catalog/dataset.json",
      "definition": "http://datos.gob.es/apidata/catalog/meta/dataset.json",
      "hasPart": "http://datos.gob.es/apidata/catalog/dataset.json?_pageSize=5&_page=1",
      "type": "http://purl.org/linked-data/api/vocab#ListEndpoint"
    },
    "items": [
      {
        "…": "(15 more fields)"
      }
    ],
    "itemsPerPage": 5,
    "next": "http://datos.gob.es/apidata/catalog/dataset.json?_page=2",
    "page": 1,
    "prev": "http://datos.gob.es/apidata/catalog/dataset.json?_page=0",
    "startIndex": 6,
    "type": "http://purl.org/linked-data/api/vocab#Page"
  }
}

Field Reference

result List of dataset entries matching the search or browse query

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://datos.gob.es/apidata/catalog/dataset.json?_pageSize=5&_page=1";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

How This API Fails

We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.

HTTP 404 Requesting a path that does not exist unknown

Returned an HTML error page rather than JSON — worth knowing if your client assumes every response can be parsed as JSON.

HTTP 400 Sending an invalid value for "_pageSize" application/json
<html>
<head>
<title>bad request</title>

<style> 

body { 
    background-color: pink 
} 

pre {
    margin: 1ex
    ; padding: 1ex
    ; background-color: #ffaaaa
    ; border-radius: 1ex
    ; font-weight: bold
}
    
</style>

    

</head>
<body>
<h1>Bad Request</h1>

Your request was ill-formed.

<pre>
_pageSize=!!!invalid!!!: value must be an integer > 0.
</pre>

</body>
</html>

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

SSL handshake error Some older client libraries have trouble with the certificate chain on datos.gob.es
Update your HTTP client library or add the --cacert flag to curl pointing to an updated CA bundle
Unexpected encoding in response text Some dataset fields contain special Spanish characters and are UTF-8 encoded
Always decode responses with UTF-8 in Python or set Accept-Charset utf-8 in your header
No datasets returned for keyword Search terms are matched against Spanish-language metadata
Use Spanish keywords (e.g., presupuesto instead of budget) for better search results

Measured Score Breakdown

Live HTTP request to the API endpoint

Speed 8/30
Consistency 8/20
Security 20/20
Browser access 15/15
Transparency 8/15
Endpoint Response Time 432ms

Fully tested on Aug 10, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Government
Difficulty Beginner
Endpoint last called: 2026-08-10

Similar APIs

View All →