Overview
Transport for Spain provides access to public train data from Renfe, Spain's national rail operator. You can retrieve train schedules, station information, and route data for the Spanish rail network. No API key is required, making it easy to start building travel and transport apps.
Beginner Tip
Start by browsing the open data portal to discover available datasets and their resource IDs before making API requests. Data is returned in JSON format and requires no authentication.
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://data.renfe.com/api/3/action/datastore_search?resource_id=a2368cff-1562-4dde-8466-9635ea3a572a&limit=5
- Result
- HTTP 200 · application/json · 3,363 bytes
- Response time
- 245 ms (median of 3) · fastest 244 ms
- Transport
- TLSv1.2 · ECDHE-RSA-AES256-GCM-SHA384
- Browser CORS
- No Access-Control-Allow-Origin header — call it from a server, not the browser
- 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 |
|---|---|---|
| include_total | boolean | true |
| resource_id | string | a2368cff-1562-4dde-8466-9635ea3a572a |
| fields | array | [1 item] |
| records_format | string | objects |
| records | array | [1 item] |
| limit | integer | 5 |
| _links | object | {2 fields} |
| total | integer | 23 |
Captured Response
Captured from a real request to https://data.renfe.com/api/3/action/datastore_search?resource_id=a2368cff-1562-4dde-8466-9635ea3a572a&limit=5 on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.
{
"help": "https://data.renfe.com/api/3/action/help_show?name=datastore_search",
"success": true,
"result": {
"include_total": true,
"resource_id": "a2368cff-1562-4dde-8466-9635ea3a572a",
"fields": [
{
"…": "(2 more fields)"
}
],
"records_format": "objects",
"records": [
{
"…": "(11 more fields)"
}
],
"limit": 5,
"_links": {
"start": "/api/3/action/datastore_search?limit=5&resource_id=a2368cff-1562-4dde-8466-9635ea3a572a",
"next": "/api/3/action/datastore_search?offset=5&limit=5&resource_id=a2368cff-1562-4dde-8466-9635ea3a572a"
},
"total": 23
}
} Field Reference
success Indicates whether the API request was successful. Implementation Example
Calls a real endpoint of this API. Replace any placeholder credentials with your own key.
const url = "https://data.renfe.com/api/1/util/snippet/";
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.
Returned an HTML error page rather than JSON — worth knowing if your client assumes every response can be parsed as JSON.
{
"help": "https://data.renfe.com/api/3/action/help_show?name=datastore_search",
"success": false,
"error": {
"message": "No encontrado: Resource \"!!!invalid!!!\" was not found.",
"__type": "Not Found Error"
}
} 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.
Measured Score Breakdown
Live HTTP request to the API endpoint
Fully tested on Aug 10, 2026
Technical Specifications
Related Tags
Similar APIs
View All →ADS-B Exchange
⭐ Beginner's PickADS-B Exchange is a community-driven API that provides real-time and historical position data for aircraft around the world.
airportsapi
⭐ Beginner's PickThe airportsapi lets you look up airport names and official website URLs by providing an ICAO code.
BC Ferries
⭐ Beginner's PickThe BC Ferries API is a free, open API providing real-time sailing schedules, capacity, and current conditions for BC Ferries routes in British Columbia, Canada.
Community Transit
⭐ Beginner's PickCommunity Transit (Transitland) is a free, open API that aggregates public transit data from hundreds of agencies worldwide including routes, stops, and schedules.
Transport for Sweden
Transport for Sweden (Trafiklab) is a developer platform providing access to public transport data across all of Sweden.