+Trainline API
Search Trainline stations, read route timetables and lowest fares, and pull UK live departure boards as clean JSON.
The API.SH Trainline API turns public Trainline pages into structured JSON. Look up stations and cities across Great Britain and Europe, read what Trainline publishes about a route (average and fastest journey time, trains per day, first and last train, operators, distance, the lowest fare, a sample timetable, reviews and FAQ), and follow trains in Great Britain in real time with live departure and arrival boards and each service's calling points.
- 5 endpoints
- from $1 / 1,000 calls
- 1,000 free credits / month
- failed calls free
GET https://api.api.sh/trainline/v1/ locations
{"q": "manchester","locale": "en-GB","count": 17,"locations": [{"code": "urn:trainline:generic:loc:MAN2968gb","name": "Manchester Piccadilly","short_code": "MAN","type": "station","country_code": "GB","subtitle": null,"attributes": ["MainStation","BusStation","… 1 more"],"time_zone": "Europe/London","language": "en","connections": ["atoc","nationalexpress"],"score": 0.40811986,"slug": "manchester-piccadilly"},{"code": "urn:trainline:generic:loc:115gb","name": "Manchester","short_code": "115","type": "stationGroup","country_code": "GB","subtitle": "Any","attributes": ["BusStation","category:point"],"time_zone": "Europe/London","language": "en","connections": ["atoc","distribusion","… 1 more"],"score": 0.21027617,"slug": "manchester"},"… 15 more"],"cached": false,"credits_used": 1} What you can build with the Trainline API
Rail route comparison
Compare journey times, trains per day, operators and the lowest fare across city pairs to plan a trip, a relocation or a travel product.
Live departure screens
Show the next trains from a station with scheduled and expected times, platforms and delay or cancellation flags, filtered to one destination if you like.
Delay and punctuality tracking
Poll a station's board and a train's calling points to log how late services run and where they are now.
Station lookup for travel apps
Resolve what a user types into Trainline station codes, slugs, time zones and the carriers that serve each station.
Travel content and SEO pages
Fill route pages with real journey times, distances, operators and fares-from, plus the questions travelers ask about the route.
Trainline data you get
Field names from real responses. Numbers come parsed, URLs absolute, dates in ISO 8601.
Trainline API endpoints and prices
Every Trainline endpoint costs 1 credit per call: credits are $1 per 1,000 on a monthly plan, $2 pay-as-you-go. Pricing
| Trainline station and city search /trainline/ | $1 · $2 PAYG 1 credit |
| Trainline UK live arrivals /trainline/ | $1 · $2 PAYG 1 credit |
| Trainline UK live departures /trainline/ | $1 · $2 PAYG 1 credit |
| Trainline route: times, trains per day, fares from /trainline/ | $1 · $2 PAYG 1 credit |
| Trainline UK train calling points /trainline/ | $1 · $2 PAYG 1 credit |
Call the Trainline API
Trainline station and city search: GET https://api.api.sh/trainline/
curl "https://api.api.sh/trainline/v1/locations?q=manchester" \
-H "x-api-key: $APISH_KEY" import os, requests
res = requests.get(
"https://api.api.sh/trainline/v1/locations",
params={"q": "manchester"},
headers={"x-api-key": os.environ["APISH_KEY"]},
timeout=120,
)
res.raise_for_status()
data = res.json() const url = new URL("https://api.api.sh/trainline/v1/locations");
url.searchParams.set("q", "manchester");
const res = await fetch(url, { headers: { "x-api-key": process.env.APISH_KEY } });
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = await res.json(); # Google Sheets (API.SH add-on)
=APISH("/trainline/v1/locations", "q", "manchester")
# Zapier, Make, n8n (verified node): pick the API.SH app,
# choose "Trainline" and "Trainline station and city search".
# AI agents (Claude, ChatGPT, Cursor): add the
# API.SH MCP server https://api.sh/mcp - Create a free accountConfirm your email and get 1,000 free credits every month. No card needed.
- Create an API keyOne key works for all 918 platforms.
- Send the requestJSON back in one call. Add
output=csvoroutput=ndjsonfor files.
Why API.SH for Trainline data
- Public data only: no Trainline login, cookies or account needed
- One key and one response shape for Trainline and 917 other platforms
- Built and maintained by API.SH, not third-party publishers
- Pay per call; errors on our side cost nothing
- No rate limits: run as many calls in parallel as you need
- Live status for every endpoint
API.SH vs the official Trainline API
Trainline's Global API is a wholesale booking API sold to travel companies and agencies through Trainline Partner Solutions; it needs a commercial agreement. API.SH needs no partner contract and returns Trainline's public route, station and UK live board data as JSON with one key.
Skip writing and maintaining your own Trainline scraper or testing Apify actors one by one: API.SH gives you one key, one JSON shape and a fixed price per call.
Trainline API questions
What Trainline data can I get?+
Station and city search (/trainline/v1/locations), route pages with journey times, trains per day, operators, lowest fare, sample timetable, reviews and FAQ (/trainline/v1/route), UK live departures (/trainline/v1/departures) and arrivals (/trainline/v1/arrivals), and a train's calling points with live times (/trainline/v1/service).
How much does the Trainline API cost?+
Every Trainline endpoint costs 1 credit per call. On a monthly plan 1,000 credits cost $1 (Starter is $50/month for 50,000 credits). Pay-as-you-go is $2 per 1,000 credits, with top-ups from $15 that never expire.
Is there a free trial?+
Yes. Every account gets 1,000 free credits every month. That is 1,000 calls to /trainline/v1/arrivals at 1 credit each.
Is there an official Trainline API?+
Trainline sells its Global API to travel businesses under a partner agreement. It is not open for self-serve sign-up. API.SH reads Trainline's public pages and needs no agreement.
Do I need a Trainline account or login?+
No. API.SH reads public Trainline pages only. No endpoint uses a login, cookies or anyone's account, and it never books tickets.
Is there a free Trainline API?+
Trainline does not offer a free public API. With API.SH you can start on the free monthly credits and only pay for more calls when you need them.
Can I see which platform my train leaves from?+
Yes, for stations in Great Britain. /trainline/v1/departures returns the platform when it has been announced, along with the scheduled and expected time.
How do I get started?+
1. Sign up at api.sh. 2. Copy your API key. 3. Call /trainline/v1/departures with station=london-euston, or /trainline/v1/route with from=london and to=manchester. Request examples and every parameter are in the docs at https://api.sh/docs. You can also use the JS or Python SDK, Google Sheets, Zapier, Make, n8n or the MCP server at https://api.sh/mcp.
Does the Trainline API have a rate limit?+
No. API.SH puts no rate limit on your key: send as many Trainline calls in parallel as you need and pay only for the calls that run. If Trainline itself slows down, the call returns 503 with a retry-after header and is not charged.