What is the GB Rail Distance API?
The GB Rail Distance API calculates the distance between any two National Rail stations in Great Britain using the operational rail network - not just a straight line on a map. It follows the actual line-of-route station chain, making it suitable for both distance lookups and as a routing guide in applications that need to display or validate the intermediate stations along the journey.
​
Whether you’re building a journey planner, estimating emissions, generating ticket logic, or modelling transport performance, this API provides a trusted backbone for accurate route data.
​
Unlike generic geodesic calculations, it uses official route topology, ensuring precise outputs for planning, pricing, and sustainability tools.
The distance between Looe and Lostwithiel is:
-
34 km
-
21 miles
The journey travels via Sandplace, Causeland, St Keyne, Coombe (Cornwall), Liskeard, and Bodmin Parkway.
How it works
The Distance API measures the station-to-station path between two stations.
API endpoints include:
-
The route-based distances in km and miles
-
Includes the full station path along the journey
Example: For a journey from Reston (RSN) to Haymarket (HYM):
-
Distance: 77.09 km / 47.9 miles
-
Train path: RSN - DUN - ELT - DRM - LND - PST - WAF - MUB - EDB - HYM
The intermediate stations listed are those along the geographic rail path, not the scheduled rail service. This feature allows for more exact distance calculations using more granular waypoints.
Who it’s for
Journey planning & mapping platforms: Display realistic rail routes between any two stations, complete with intermediate stations along the official line of route - not just a straight line on a map
Disruption & travel information tools: Use the station sequence to visualise affected segments, helping passengers understand detours or closures
AI assistants & chatbots
Answer natural-language questions such as “How far is Leeds to London by train?” or “Show me the route between Birmingham and Brighton”
Transport consultants & planning teams:
Model corridor lengths, infrastructure usage, or route options
Fare calculators & retail platforms:
Support journey validation
This API supports the principle of using best-available data where it exists and makes it easy to compare routes.
Try it or subscribe
Available to subscribe accessed via CRS origin and destination stations.
DataWharf feeds are available via the Rail Data Marketplace with subscription offers tailored to suit rail industry organisations as well as general users. Full details are available on each product listing via the links below. Contact us to discuss bespoke packages.
Explore more with DataWharf
The GB Rail Carbon Calculator works best when combined with other DataWharf APIs.
Popular combinations include:
Explore our suite of APIs or contact us to discuss a custom bundle for your use case.