February 04, 2019
When prototyping something with the TFL API I found the documentation on the official site lacking. However I since found some information from looking at other peoples implementations of the TFL API. Here I will document them so I don’t forget them.
For example the API call for arrivals for Liverpool Street Overground rail is
https://api.tfl.gov.uk/StopPoint/910GLIVST/arrivals
This can be customised to any TFL station, by changing the 910GLIVST
, the code can be found by searching this link
https://tfl.gov.uk/travel-information/stations-stops-and-piers/
and taking the station ID from the URL path for a station. Be aware that each line has it’s own ID, but can fall under a umbrella ID for the station that has many services, e.g. Liverpool Street is HUBLST
since it includes London Overground & Rail, Central line and Circle, Hammersmith & City and Metropolitain.
So for each transport line, drill down to find the Id for example, the Liverpool Street - Central line underground station’s URL is
https://tfl.gov.uk/tube/stop/940GZZLULVT/liverpool-street-underground-station?lineId=central
Thus the API call for arrivals would be https://api.tfl.gov.uk/StopPoint/940GZZLULVT/arrivals
TFL Blog post on these calls from TFL can be found here
More information and some example calls using Postman can be found on the official API webpage as well here
Written by Farhad Agzamov who lives and works in London building things. You can follow him on Twitter and check out his github here