The first Night Tube services launch on the Central and Victoria lines on Friday 19 August, offering a 24-hour service on Fridays and Saturdays. Services on the Jubilee, Northern and Piccadilly lines will follow in autumn. The Night Tube will be pivotal to London’s night economy, and with over 500 apps powered by our Open Data, we’re pleased to announce the addition of Night Tube data into our Unified API. 

Victoria line platforms at Warren Street

The Night Tube launches on the Central and Victoria lines on Friday 19 August – data is available in our Unified API


You can read some more information about the launch of Night Tube services here, and this post is designed to offer guidance to developers wishing to include Night Tube data in their apps.

Night Tube routes

As the Night Tube service initially applies to a subset of the Underground network, we have introduced the notion of a “service type” as a means of differentiating between the regular daytime service and the new night service where applicable.

To retrieve all possible service type values, we send a metadata request to https://api.tfl.gov.uk/Line/Meta/ServiceTypes:

[
  "Regular",
  "Night"
]

Theses values can be used in the serviceTypes parameter added to most Route endpoints such as https://api.tfl.gov.uk/Line/victoria/Route/Sequence/inbound?serviceTypes=Regular,Night. The response includes routes for each service supported:

orderedLineRoutes: [
  {
    "name":"Walthamstow Central ↔ Brixton ",
    "naptanIds":[...],
    "serviceType":"Night"
  },
  {
    "name":"Walthamstow Central ↔ Brixton ",
    "naptanIds":[...],
    "serviceType":"Regular"
  }
]

We use this API on the route page on the TfL website to display both the daytime and Night Tube routes, and let the user choose between them:

victoria-night-tube-route

Select the Night Tube tab to see the route – here’s an example showing the Victoria line

In all cases where serviceTypes is now a parameter, it is optional (with “Regular” set as the default value) to avoid any breaking changes to these endpoints.

Is Night Tube active?

To determine what service type is currently in operation for any mode that supports it, we check the ActiveServiceType with https://api.tfl.gov.uk/Mode/ActiveServiceTypes. Currently this endpoint is only supported by tube.

[
  {
    "mode":"tube",
    "serviceType":"Regular"
  }
]

This endpoint is used on the TfL website to switch various elements to a “night” mode, as shown below for the service status board. The active service type is controlled by the Transport for London Network Operations Centre (NOC) which will enable “Night service” on a daily basis – and not necessarily on the same schedule every night.

night-tube-status

View of the Night Tube service status board

Which lines are Night Tube lines?

Not all tube lines are currently part of the Night Tube service. To determine whether a given line is part of Night Tube, we can query the line API and look for the serviceTypes e.g for the Victoria line: https://api.tfl.gov.uk/Line/victoria, the response now includes a serviceTypes collection of LineServiceTypeInfo, listing the supported services:

{
  name: "Regular",
  uri: "/Line/Route?ids=Victoria&serviceTypes=Regular"
},
{
  name: "Night",
  uri: "/Line/Route?ids=Victoria&serviceTypes=Night"
}

Business as usual elsewhere

With the exception of the introduction of serviceTypes to Line entities, the rest of our tube APIs remain otherwise unchanged:

As the London Underground service transitions in to Night Tube, these APIs will seamlessly continue to provide real-time information. In the case of Status, tube lines that are not served by Night Tube will report a status of “Service Closed” along with a corresponding status code:

"statusSeverity":20
"statusSeverityDescription":"Service Closed"

As always, we love to hear what you are building with our Unified API, or if you have any questions, please let us know in the comments.

* As always, the API usage examples in this blog are anonymous, so the quota is strictly limited. For a real application, developers should register for an API key.

Posted by James Rogers

Lead Developer

10 Comments

  1. […] to a TfL blog by lead developer James Rogers, which describes the API, existing apps should not require […]

    Like

    Reply

  2. […] to a TfL blog by lead developer James Rogers, that describes a API, existent apps should not need […]

    Like

    Reply

  3. […] to a TfL blog by lead developer James Rogers, which describes the API, existing apps should not require […]

    Like

    Reply

  4. Does this mean the Night Tube gets activated across the whole network at once? Surely before the final “Regular” service has reached Chesham on the Metropolitan line, there will be “Night” services already running on the Central and Victoria lines?
    Or will ActiveServiceType return both “Night” and “Regular” at once? – the data is in an array after all.

    Like

    Reply

    1. Hi Luke,

      Unfortunately the notion of service type applies per-mode rather than per-line. As you point out, the situation can (and probably will) arise where the active service type is reported as “Night” yet “Regular” services will still be running.

      On the TfL website, we purely use the /Mode/ActiveServiceTypes endpoint to control styling of UI elements such as the service status board. Lines will still appear on the status board whilst their Status is not reported as “Service Closed”.

      I hope this helps.

      James

      Like

      Reply

  5. Are there any branding guidelines around how Night services should be displayed? For example, can third-party apps use the owl logo? Or is there copyright/trademark preventing that?

    Like

    Reply

    1. Hi Luke,

      Unfortunately third-party apps cannot use the owl logo. Please follow this link for further information:

      https://tfl.gov.uk/info-for/open-data-users/design-and-branding

      Thanks,

      James

      Like

      Reply

  6. […] to a TfL blog by lead developer James Rogers, which describes the API, existing apps should not require […]

    Like

    Reply

  7. A question about the API…

    You can use

    /StopPoint/{id}/Arrivals

    … to get the list of departures too. But not for the first station on a line, for example the jubilee line at Stratford.

    How am I expected to get Departures for the three jubilee line platforms?

    Thanks in advance

    B

    Like

    Reply

    1. Hi Brian,

      Very sorry for the slow reply.

      At present our API only provides data relating to train arrivals rather than departures. For the majority of stations, there is little difference between arrival time and departure time, with the notable exception of terminal stations such as Stratford.

      This is a known issue that we hope to address in the future.

      Sorry I cannot be of any further help at this stage.

      James

      Like

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s