National Rail APInationalrail.co.uk ↗
Access UK National Rail data via 6 endpoints: live departures/arrivals, station details, CRS codes, disruptions, and engineering works.
What is the National Rail API?
The National Rail API exposes 6 endpoints covering live UK train departure and arrival boards, full station metadata, and real-time network disruptions. Call get_live_departures with a 3-letter CRS code to retrieve scheduled and estimated times, platform numbers, operators, and service status for any staffed station. Station endpoints return CRS codes, coordinates, accessibility details, and facility data drawn directly from the nationalrail.co.uk estate.
No input parameters required.
curl -X GET 'https://api.parse.bot/scraper/63073631-1d9b-4af5-b9a2-ffd95836d0bc/get_stations' \ -H 'X-API-Key: $PARSE_API_KEY'
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 nationalrail-co-uk-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.
"""National Rail API — stations, live boards, and disruptions."""
from parse_apis.national_rail_api import NationalRail, StationNotFound
client = NationalRail()
# Search for stations by name — limit caps total items fetched.
for station in client.stations.search(query="Manchester", limit=3):
print(station.name, station.crs_code, station.classification)
# Get detailed info for a specific station by slug.
try:
detail = client.stationdetails.get(slug="london-euston")
print(detail.name, detail.crs_code, detail.address.postcode)
except StationNotFound as exc:
print(f"Station not found: {exc}")
# Live departure board — construct a Station by CRS code, then list departures.
euston = client.station(crs_code="EUS")
for dep in euston.departures.list(limit=5):
print(dep.rid, dep.destination, dep.platform, dep.scheduled)
# Live arrivals at the same station.
for arr in euston.arrivals.list(limit=5):
print(arr.rid, arr.origin, arr.platform, arr.estimated)
# Network-wide disruption report — single object with all categories.
report = client.disruptionreports.get()
for indicator in report.service_indicators[:3]:
print(indicator.name, indicator.status)
print("exercised: stations.search / stationdetails.get / departures.list / arrivals.list / disruptionreports.get")
Retrieve the full list of UK rail stations and their CRS codes. Returns all stations including National Rail, London Underground, and Docklands Light Railway classifications. No parameters required — returns the complete station reference dataset in a single page.
No input parameters required.
{
"type": "object",
"fields": {
"stations": "array of station objects each containing crsCode, name, classification, and state flags"
},
"sample": {
"data": {
"stations": [
{
"name": "Tower Gateway",
"crsCode": "1DA",
"kbState": 0,
"ojpState": 1,
"dlrLuState": 1,
"darwinState": 0,
"classification": "DOCKLAND_LIGHT_RAILWAY"
},
{
"name": "London Euston",
"crsCode": "EUS",
"kbState": 2,
"ojpState": 1,
"dlrLuState": 1,
"darwinState": 4,
"classification": "LONDON"
}
]
},
"status": "success"
}
}About the National Rail API
Station Data
get_stations returns the full list of UK rail stations as an array of objects, each with a crsCode, name, classification (National Rail, London Underground, or Docklands Light Railway), and state flags. Use search_stations with a query parameter — partial name or CRS abbreviation — to get autocomplete-style matches with coordinates. For deeper detail, get_station_details accepts a URL slug (e.g. london-euston) and returns structured data including address, location, stationOperator, stationAccessibility, ticket buying options, transport links, and platform-level facilities.
Live Departure and Arrival Boards
get_live_departures and get_live_arrivals both accept a crs parameter and return a board object with a generatedAt timestamp and a services array. Each service entry includes scheduled and estimated times, the calling destination or origin station, the operator, platform number, and a service status string. These boards reflect the same real-time data presented on nationalrail.co.uk, making them suitable for journey monitoring and alerting tools.
Disruptions and Engineering Works
get_disruptions requires no parameters and returns four top-level arrays: disruptions (active incidents), cleared_disruptions (recently resolved incidents), engineering_works (planned possessions and line closures), and service_indicators (per-operator performance summaries). This gives a network-wide picture of current and upcoming service impacts without needing to poll individual station boards.
The National Rail API is a managed, monitored endpoint for nationalrail.co.uk — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when nationalrail.co.uk 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 nationalrail.co.uk 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.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Display a live departure board on a travel app using
get_live_departureswith a station's CRS code - Alert commuters to delays or cancellations by polling
get_disruptionsfor active incidents - Build a station finder with autocomplete backed by
search_stationsreturning CRS codes and coordinates - Show accessibility and facility information for a station using
get_station_detailsfields likestationAccessibility - Monitor engineering works to surface weekend line closures before a user books travel
- Populate a CRS-code lookup table from
get_stationsfor use in journey planning integrations - Track per-operator service performance using
service_indicatorsfrom the disruptions endpoint
| 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 | 100 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.
Does National Rail have an official developer API?+
What does `get_live_departures` actually return per service?+
services array includes the scheduled departure time, estimated departure time (or 'On time'), the destination station name, the operating company, platform number where allocated, and a status string. The board also carries a generatedAt timestamp so you know exactly how fresh the data is.Does the API cover journey planning — fare prices, ticket booking, or specific calling points?+
How current is the disruptions data from `get_disruptions`?+
cleared_disruptions array alongside active ones.Can I look up a station's CRS code if I only know part of the name?+
query parameter to search_stations. The response includes a payload with matched stations, each carrying its crsCode and coordinates. This is the same autocomplete data used by the nationalrail.co.uk search box.