trainline.eu APItrainline.eu ↗
Search Trainline stations by name and find train journeys across the UK and Europe. Returns URNs, schedules, duration, distance, and CO2 data.
curl -X GET 'https://api.parse.bot/scraper/447b13bc-e3c7-4dca-a183-dbdaa6edee8a/search_locations?query=Berlin' \ -H 'X-API-Key: $PARSE_API_KEY'
Search for train station locations by name. Returns station URNs, coordinates, and metadata that can be used as origin/destination in search_journeys.
| Param | Type | Description |
|---|---|---|
| queryrequired | string | Station name or partial name to search for (e.g. 'London', 'Manchester', 'Paris'). |
{
"type": "object",
"fields": {
"locations": "array of station objects with name, urn, country, type, timezone, latitude, longitude"
},
"sample": {
"data": {
"locations": [
{
"urn": "urn:trainline:generic:loc:MAN2968gb",
"name": "Manchester Piccadilly",
"type": "station",
"country": "GB",
"latitude": 53.4767,
"timezone": "Europe/London",
"longitude": -2.229
},
{
"urn": "urn:trainline:generic:loc:115gb",
"name": "Manchester",
"type": "stationGroup",
"country": "GB",
"latitude": null,
"timezone": "Europe/London",
"longitude": null
}
]
},
"status": "success"
}
}About the trainline.eu API
The Trainline EU API provides 2 endpoints for discovering train stations and searching available journeys across the UK and Europe. Use search_locations to resolve station names to URNs, then pass those URNs to search_journeys to retrieve journey schedules with departure and arrival times, total duration, distance in kilometres, and CO2 emissions per journey.
Station Search
The search_locations endpoint accepts a query string — a full or partial station name such as London, Manchester, or Paris — and returns an array of matching station objects. Each object includes a name, a urn (e.g. urn:trainline:generic:loc:182gb), country, type, timezone, and geographic coordinates (latitude, longitude). The URN is the key identifier used as origin or destination in journey searches.
Journey Search
The search_journeys endpoint accepts origin and destination as station URNs obtained from search_locations. An optional departure_date parameter accepts ISO 8601 format: either YYYY-MM-DD (which defaults departure time to 09:00) or a full datetime string YYYY-MM-DDTHH:MM. The response includes a total count and a journeys array. Each journey object carries id, departure_time, arrival_time, duration, direction, distance_km, co2_grams, and num_legs.
Coverage and Data Shape
Station coverage spans UK and European networks as indexed on Trainline.com. The CO2 emissions field (co2_grams) makes the API useful for comparing journeys on environmental impact alongside schedule and distance. The num_legs field indicates how many segments a journey involves, letting you distinguish direct services from those requiring changes.
- Build a train journey planner that compares travel times between UK cities using departure and arrival fields
- Display CO2 emissions per route to help users choose lower-carbon journeys
- Resolve station names to URNs for use in downstream booking or scheduling workflows
- Calculate travel distance between European cities using the distance_km field
- Filter multi-leg vs direct journeys by inspecting the num_legs field
- Populate an autocomplete station selector using search_locations with partial name queries
- Aggregate journey duration data across multiple departure times to find the fastest available service
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 250 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.