Discover/Trainline API
live

Trainline APItrainline.eu

Search Trainline stations by name and find train journeys across the UK and Europe. Returns URNs, schedules, duration, distance, and CO2 data.

Endpoint health
verified 6d ago
search_locations
search_journeys
2/2 passing latest checkself-healing
Endpoints
2
Updated
21d ago

What is the Trainline 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.

Try it
Station name or partial name to search for (e.g. 'London', 'Manchester', 'Paris').
api.parse.bot/scraper/447b13bc-e3c7-4dca-a183-dbdaa6edee8a/<endpoint>
Ready to send
Fill in the parameters and hit sign in to send to see live response data here.
Call it over HTTPgrab a free API key at signup
curl -X GET 'https://api.parse.bot/scraper/447b13bc-e3c7-4dca-a183-dbdaa6edee8a/search_locations?query=London' \
  -H 'X-API-Key: $PARSE_API_KEY'
Python SDK · recommended

Typed, relational, agent-ready

A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.

  • Fully typed · autocompletes
  • Objects link to objects
  • Typed errors & pagination

Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:

uv add parse-sdk
uv run parse init
uv run parse add --marketplace trainline-eu-api

uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.

"""Trainline API — search stations and find train journeys between them."""
from parse_apis.trainline_api import Trainline, StationNotFound

client = Trainline()

# Search for stations by name — limit caps total items fetched
for station in client.stations.search(query="Manchester", limit=5):
    print(station.name, station.urn, station.country)

# Take one station, then search journeys from London to that destination
destination = client.stations.search(query="Manchester", limit=1).first()
if destination:
    for journey in client.journeys.search(
        origin="urn:trainline:generic:loc:182gb",
        destination=destination.urn,
        departure_date="2026-06-20",
        limit=3,
    ):
        print(journey.departure_time, journey.arrival_time, journey.duration, journey.co2_grams)

# Typed error handling — catch when a station search yields nothing useful
try:
    result = client.stations.search(query="Xyzzyville", limit=1).first()
    print(result.name if result else "No station found")
except StationNotFound as exc:
    print(f"Station not found: {exc}")

print("exercised: stations.search / journeys.search / StationNotFound catch")
All endpoints · 2 totalmissing one? ·

Search for train station locations by name. Returns station URNs, coordinates, and metadata. Each station has a URN that uniquely identifies it and can be used as origin or destination in search_journeys. Results include both individual stations and station groups (e.g. 'London' encompasses multiple terminals). Partial name matching is supported.

Input
ParamTypeDescription
queryrequiredstringStation name or partial name to search for (e.g. 'London', 'Manchester', 'Paris').
Response
{
  "type": "object",
  "fields": {
    "locations": "array of station objects with name, urn, country, type, timezone, latitude, longitude"
  },
  "sample": {
    "data": {
      "locations": [
        {
          "urn": "urn:trainline:generic:loc:182gb",
          "name": "London",
          "type": "stationGroup",
          "country": "GB",
          "latitude": null,
          "timezone": "Europe/London",
          "longitude": null
        },
        {
          "urn": "urn:trainline:generic:loc:EUS1444gb",
          "name": "London Euston",
          "type": "station",
          "country": "GB",
          "latitude": 51.5284,
          "timezone": "Europe/London",
          "longitude": -0.1346
        }
      ]
    },
    "status": "success"
  }
}

About the Trainline API

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.

Reliability & maintenanceVerified

The Trainline API is a managed, monitored endpoint for trainline.eu — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when trainline.eu changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.

This isn't an official trainline.eu API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.

Last verified
6d ago
Latest check
2/2 endpoints passing
Maintenance
Monitored & self-healing
Will this API break when the source site changes?+
It's built not to. Every endpoint is health-checked on a schedule with automated test probes. When the source site changes and a check fails, the API is automatically queued for repair and re-verified — that's the self-healing layer. Each API page shows when its endpoints were last verified. And because marketplace APIs are shared, any fix reaches everyone using it.
Is this an official API from the source site?+
No — Parse APIs are independent, managed REST wrappers over publicly available data. That is the point: where a site has no official API (or only a limited one), Parse gives you a maintained, monitored endpoint for that data and keeps it working as the site changes — so you get a stable contract over a source that never promised one.
Can I fix or extend this API myself if I need a new endpoint or field?+
Yes — and you don't have to wait on us. This API was generated by the Parse agent, which stays attached. Describe the change in plain English ("add an endpoint that returns reviews", "fix the price field") in the revise box on the API page or via the revise_api MCP tool, and the agent rebuilds it against the live site in minutes. Contributing the change back to the public API is free.
What happens if I call an endpoint that has an issue?+
Errors are machine-readable: a bad call returns a clean status with the list of available endpoints and a repair hint, so an agent (or you) can recover or trigger a fix instead of failing silently. Confirmed failures feed the automatic repair queue.
Common use cases
  • 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
Pricing & limitsSee full pricing →
TierPriceCredits/monthRate limit
Free$0/mo1005 req/min
Hobby$30/mo1,00020 req/min
Developer$100/mo5,000100 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.

Frequently asked questions
Does Trainline have an official developer API?+
Trainline does not publish a public developer API. There is no documented REST or GraphQL API available for external developers on their website.
What does search_journeys return beyond schedule times?+
Each journey object includes departure_time, arrival_time, duration, direction, distance_km, co2_grams, and num_legs. It does not include real-time pricing or ticket availability — the API covers schedule and route metadata. You can fork it on Parse and revise to add a ticket price endpoint if that data becomes accessible.
Does the API return fare or ticket pricing for journeys?+
Not currently. The API returns schedule data, distance, and CO2 emissions but does not include fare prices or ticket classes. You can fork it on Parse and revise to add pricing fields if you need cost data alongside schedules.
Are there any limitations on the departure_date parameter?+
The departure_date field is optional and accepts either YYYY-MM-DD (defaulting to 09:00 departure) or a full ISO 8601 datetime string. Queries for historical dates or very far future dates may return no results depending on what Trainline has indexed for that route and time window.
Does the API cover all European train operators?+
Coverage reflects what Trainline.com indexes, which includes major UK and European rail networks. Smaller regional operators or networks not listed on Trainline may not appear in results. You can fork it on Parse and revise to integrate additional rail data sources if you need broader operator coverage.
Page content last updated . Spec covers 2 endpoints from trainline.eu.
Related APIs in TravelSee all →
thetrainline.com API
Search UK train stations and find the cheapest fares across date ranges, then generate direct booking links to complete your purchase on Trainline.com. Get real-time journey information to compare prices and book your tickets in seconds.
nationalrail.co.uk API
Check live train departure and arrival times at UK stations, search for specific stations, and get real-time service disruption alerts. Stay informed about rail service delays and changes to plan your journeys efficiently.
trenitalia.com API
Search for trains across Italy, check real-time train status and delays, view station departure and arrival boards, and find available tickets all in one place. Get live traffic information and detailed train itineraries to plan your journey with complete visibility into schedules and service disruptions.
railyatri.in API
Search trains between stations and get real-time information including live train status, timetables, seat availability, and PNR confirmation details. Find the perfect journey by autocompleting station and train names while checking current availability and train schedules.
bahn.de API
Access data from bahn.de.
amtrak.com API
Search for Amtrak trains across stations, compare fares, and discover discounts to plan your rail journey with current pricing and availability. Get detailed train information, autocomplete station names, and find the cheapest routes for your travel dates.
omio.com API
Search and compare train, bus, and flight trips across multiple providers in real-time, with detailed pricing breakdowns and the ability to view fares across different dates. Find the best deals by exploring popular destinations, autocompleting location searches, and analyzing price variations to plan your ideal journey.
bahn.com API
Search German train schedules and stations, find connections between destinations, and compare ticket prices across Deutsche Bahn routes. Get real-time station information and transit association details to plan your train journey efficiently.