Project Research: Transport For London API

One of the key features I plan on implementing within the Explore:LDN application is a route planner for London’s rail services. Thankfully Transport for London (TFL) provides an application program interface “API” that provides unified access to real time data across all of London’s public transport systems. Moreover, this API service enables API calls specifically for route planning and rail service updates.

Whilst this is a potentially complex API, I have previously gained experience with other developer API’s such as Twitter, Facebook and Flickr. These all rely on what is known as ReST frameworks whereby the communications protocol is stateless, client-server based and most commonly relies upon HTTP protocol requests. I feel using my development experience and the resources/documentation currently available I will be able to successfully implement the API within the final application.

Transport for London API


Having completed initial research, I registered the application website with the TFL API in order to acquire an API key and gain access to the API. Following my application’s successful registration with the API, I decided to setup some initial tests to experiment with the API’s capabilities.

For the first API test, I setup a simple AJAX call with jQuery that requested the status of each London tube line from the TFL API. In turn, this AJAX call was initiated when the user pressed a html button I defined with the body of the html document. example: Bakerloo line – “Good service”


Below I have outlined the process of API interaction in simple iterative steps:


  • On html button click, launch jquery function to call API.
  • Within this function, an AJAX request is initialised. The type of request is set to GET, the URL for the API call is defined and a response “success” function is also initialised.
  • If the API is successfully called, the success function will start.
  • The success function then parses the returned JSON results and iterativley appends values to the defined html DOM element
  • Styling is defined for each of the populated DOM elements in order to present the data in an appealing form to users.



After successfully retrieving the status of each of London’s rail lines, I then researched the API’s route planner functionality. In turn, the route planner follows the same concept of calling the API and parsing the returned JSON data, however the JSON data returned is far more complex in this case. Due to this complexity I will create a seperate blog post that documents the process of developing the route planner functionality.