Discover/Trainline API
live

Trainline APItrainline.eu

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

This API takes change requests — .
Endpoint health
verified 16h ago
search_locations
get_routes_from_station
2/2 passing latest checkself-healing
Endpoints
3
Updated
22d ago

What is the Trainline API?

The Trainline API exposes 3 endpoints for working with train travel data across the UK and Europe. Use search_locations to resolve station names into URNs, search_journeys to retrieve up to 8 journeys between two stations with departure times, durations, distances, and CO2 emissions, and get_routes_from_station to list all reachable destinations from a given origin along with frequency and schedule data.

This call costs1 credit / call— charged only on success
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, discover routes, and find journeys."""
from parse_apis.Trainline_API import Trainline, StationNotFound

client = Trainline()

# Search for stations by name
for station in client.stations.search(query="Manchester", limit=3):
    print(station.name, station.urn, station.country)

# Get a station and list routes reachable from it
london = client.station(urn="urn:trainline:generic:loc:182gb")
for route in london.routes.list(limit=3):
    print(route.destination_name, route.destination_country, route.duration, route.trains_per_day)

# Search for journeys between two stations
for journey in client.journeys.search(
    origin="urn:trainline:generic:loc:182gb",
    destination="urn:trainline:generic:loc:115gb",
    departure_date="2026-08-04",
    limit=3,
):
    print(journey.departure_time, journey.arrival_time, journey.duration, journey.num_legs)

# Typed error handling
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 / station.routes.list / journeys.search / StationNotFound catch")
All endpoints · 3 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 and URN Resolution

The search_locations endpoint accepts a partial or full station name via the query parameter and returns an array of matching location objects. Each object includes the station's name, urn, country, type, timezone, latitude, and longitude. Both individual stations and station groups (such as "London") appear in results. The urn field is the key identifier used as origin and destination in downstream requests — it takes the form urn:trainline:generic:loc:<id>.

Journey Search

search_journeys accepts two URNs (origin and destination) and an optional departure_date. The date can be supplied as YYYY-MM-DD (defaults to 09:00 local time) or as a full ISO datetime string. 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. Results are sorted by departure time and capped at 8 journeys per call.

Route Discovery from a Station

get_routes_from_station takes a station_urn and returns all destinations reachable from that station. The routes array contains objects with destination_name, destination_slug, destination_country, duration, trains_per_day, first_departure, and last_departure. The response also includes a resolved station_name for the supplied URN. This endpoint is useful for mapping out a network of connections before committing to a specific journey search.

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
16h 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 route planner that resolves city names to URNs and displays available journeys with CO2 comparisons.
  • Calculate carbon footprint estimates for train trips using the co2_grams field returned per journey.
  • Generate a connection map for a major hub by calling get_routes_from_station and charting all reachable destinations.
  • Automate journey-time lookups for a travel-time matrix between multiple European city pairs.
  • Display typical daily train frequency and first/last departure times for a given station to inform trip planning.
  • Enrich transport data pipelines with station coordinates (latitude, longitude) and timezone metadata from search_locations.
  • Compare multi-leg journey counts across routes using the num_legs field to identify direct versus connecting services.
Pricing & limitsSee full pricing →
TierPriceCredits/monthRate limit
Free$0/mo2005 req/min
Hobby$30/mo1,00020 req/min
Developer$100/mo5,000100 req/min
Team$300/mo20,000300 req/min
Company$1,000/mo100,000500 req/min

Each endpoint has a fixed posted price per successful call — most fall between 1 and 10 credits — shown on this API's page before you run it. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.

Frequently asked questions
Does Trainline have an official public developer API?+
Trainline does not publish a general-purpose developer API for third-party use. Their developer resources are focused on B2B rail distribution partnerships rather than open access for individual developers.
What does search_journeys return, and does it include ticket prices?+
Each journey object includes departure_time, arrival_time, duration, distance_km, co2_grams, and num_legs. Ticket pricing is not currently returned by this endpoint. The API covers schedule and logistics data for available journeys. You can fork it on Parse and revise to add a pricing-focused endpoint if that data becomes accessible.
Are all European countries covered by search_locations?+
The endpoint returns stations from the UK and Europe as indexed on Trainline, but coverage depth varies by country — major rail networks (UK, France, Germany, Spain, Italy) are well represented while smaller regional operators may have limited or no station data.
Does the API return real-time disruption or live delay information?+
Not currently. The API covers journey schedules, durations, distances, and route frequency. Live delay, disruption, or platform information is not included in any of the three endpoints. You can fork it on Parse and revise to add a disruption-status endpoint.
How many journeys does search_journeys return per call, and can results be paginated?+
Each call returns up to 8 journeys sorted by departure time. There is no pagination parameter — to retrieve journeys at a different time window, adjust the departure_date input to a later date or time.
Page content last updated . Spec covers 3 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.
rome2rio.com API
Find and compare train routes between cities worldwide, instantly viewing travel duration, number of stops, carrier information, ticket prices, and direct booking links. Streamline your train journey planning by accessing comprehensive route options and pricing in one place.
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.
bahn.de API
Access data from bahn.de.
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.
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.