Open Government, Spain API

Free to Use Varies (check documentation)

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.

Available Data

Use case: Integrate spain government open data data into web and mobile applications
Open Government, Spain data via REST API
JSON-formatted response data
Freely accessible without authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Open Government, Spain",
    "description": "Spain Government Open Data",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

result List of dataset entries matching the search or browse query
result[].title Human-readable title of the dataset in Spanish
result[].identifier Unique identifier for the dataset used in API lookups
result[].distribution Download links and format info for the dataset files
result[].publisher The government entity that published the dataset

Implementation Example

const url = "https://datos.gob.es/en";
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.

Common Errors & Troubleshooting

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

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 15/20
🔒 Security 15/15
🛠 Developer XP 15/20
✓ Reliability 7/15
Response Time 366ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Government
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →