Endpoints: Fastest and Next Departures

The following set of API Endpoints allow you to get the next, or next fastest service between two stations. There are 2 endpoints available here:


Endpoint Description
getNextDeparturesByCRS Shows the next departing service between two stations
getFastestDeparturesByCRS Shows the next fastest service between two station


Get Next Departures by CRS

getNextDeparturesByCRS is used to get the next service running between two stations. Multiple destinations can be specified. This will typically return a single train service, but will also return a replacement bus or ferry service if in place.

This will return the next departures for each of the filterList stations specified. It may not return the fastest next service. To get the fastest next service use the getFastestDeparturesByCRS endpoint.


HTTP Request

GET https://api.departureboard.io/api/v2.0/getNextDeparturesByCRS/{CRS}/


URL Parameters

Parameter Default Description
CRS
required
none The CRS (Computer Reservation System) for the station you wish to get departure information for, e.g. KGX for London Kings Cross.

Query Parameters

Parameter Default Description
apiKey
required
none The National Rail OpenLDBWS API Key to use for looking up service information. You must register with National Rail to obtain this key and whitelist it with us.
filterList
required
none The CRS (Computer Reservation System) codes to show departing services to. Up to 20 destination stations can be specified. These should be split by a comma, for example HAY,EAL,PAD.
timeOffset 0 The time window in minutes to offset the departure information by. For example, a value of 20 will show the next services departing after 20 minutes.
timeWindow 120 The time window to show services for in minutes. For example, a value of 60 will show services departing the station in the next 60 minutes.
serviceDetails true Should the response contain information on the calling points for each service? If set to false, calling points will not be returned.

Example Queries

Lookup next departure from London Kings Cross to: Huntingdon, Peterborough and St. Neots:
curl -X GET "https://api.departureboard.io/api/v2.0/getNextDeparturesByCRS/KGX/?apiKey=01234&filterList=HUN,PBO,SNO"

Lookup next departure from London Kings Cross to: Huntingdon, Peterborough and St. Neots, departing within the next 5 minutes:
curl -X GET "https://api.departureboard.io/api/v2.0/getNextDeparturesByCRS/KGX/?apiKey=01234&filterList=HUN,PBO,SNO&timeWindow=5"

Lookup next departure from London Kings Cross to: Huntingdon, Peterborough and St. Neots, don’t return Calling Points:
curl -X GET "https://api.departureboard.io/api/v2.0/getNextDeparturesByCRS/KGX/?apiKey=01234&filterList=HUN,PBO,SNO&serviceDetails=false


Example Response

curl -X GET "https://api.departureboard.io/api/v2.0/getNextDeparturesByCRS/EUS/?apiKey=1234&filterList=MKC,MAN"

Expand Response
{
"GeneratedAt": "2019-09-10T13:50:25.7418604+01:00",
"nationalRailResponseTimeMilliseconds": 130,
"locationName": "London Euston",
"crs": "EUS",
"filterLocationName": null,
"filtercrs": null,
"filterType": null,
"nrccMessages": null,
"platformAvailable": true,
"areServicesAvailable": null,
"destination": [
  {
    "crs": "MKC",
    "service": {
      "serviceID": "09uXKDYQdDRjLNRxgajOhQ==",
      "serviceIDUrlSafe": "09uXKDYQdDRjLNRxgajOhQ--",
      "serviceType": "train",
      "isCancelled": null,
      "filterLocationCancelled": null,
      "cancelReason": null,
      "delayReason": null,
      "adhocAlert": null,
      "std": "13:49",
      "etd": "On time",
      "sta": null,
      "eta": null,
      "platform": null,
      "operator": "West Midlands Trains",
      "operatorCode": "LM",
      "isCircularRoute": null,
      "length": 4,
      "detachFront": null,
      "isReverseFormation": null,
      "rsid": null,
      "origin": [
        {
          "locationName": "London Euston",
          "crs": "EUS",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "destination": [
        {
          "locationName": "Liverpool Lime Street",
          "crs": "LIV",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "currentOrigins": null,
      "currentDestinations": null,
      "subsequentCallingPointsList": [
        {
          "subsequentCallingPoints": [
            {
              "locationName": "Watford Junction",
              "crs": "WFJ",
              "st": "14:03",
              "et": "On time",
              "at": null,
              "length": null
            },
            {
              "locationName": "Liverpool Lime Street",
              "crs": "LIV",
              "st": "17:42",
              "et": "On time",
              "at": null,
              "length": null
            }
          ]
        }
      ]
    }
  },
  {
    "crs": "MAN",
    "service": {
      "serviceID": "j+meN1h8C66roUaXvm+iXg==",
      "serviceIDUrlSafe": "j!meN1h8C66roUaXvm!iXg--",
      "serviceType": "train",
      "isCancelled": null,
      "filterLocationCancelled": null,
      "cancelReason": null,
      "delayReason": null,
      "adhocAlert": null,
      "std": "14:00",
      "etd": "On time",
      "sta": null,
      "eta": null,
      "platform": "1",
      "operator": "Virgin Trains",
      "operatorCode": "VT",
      "isCircularRoute": null,
      "length": null,
      "detachFront": null,
      "isReverseFormation": null,
      "rsid": null,
      "origin": [
        {
          "locationName": "London Euston",
          "crs": "EUS",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "destination": [
        {
          "locationName": "Manchester Piccadilly",
          "crs": "MAN",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "currentOrigins": null,
      "currentDestinations": null,
      "subsequentCallingPointsList": [
        {
          "subsequentCallingPoints": [
            {
              "locationName": "Stoke-on-Trent",
              "crs": "SOT",
              "st": "15:24",
              "et": "On time",
              "at": null,
              "length": null
            },
            {
              "locationName": "Manchester Piccadilly",
              "crs": "MAN",
              "st": "16:05",
              "et": "On time",
              "at": null,
              "length": null
            }
          ]
        }
      ]
    }
  }
]
}


Notes

When the serviceDetails query parameter is set to true for getNextDeparturesByCRS, only subsequent calling points will be returned. This is by design from National Rail.

To get subsequent and previous Calling Points for a service, take the serviceIDUrlSafe value is provided in the response and use the getServiceDetailsByID endpoint to lookup more details.

It is possible to have two sets of subsequentCallingPoints returned for a service (when looking up train services that split).

Consequently, subsequentCallingPoints are returned in the subsequentCallingPointsList array.

However, in 99% of circumstances there are only 1 set of subsequentCallingPoints returned. For services that do not split, you can use subsequentCallingPointsList[0].subsequentCallingPoints to access the previous calling points. The Python Code Samples have examples of how this works.



Get Fastest Departures by CRS

getFastestDeparturesByCRS is used to get the fastest next service running between two stations. Multiple destinations can be specified. This will typically return a single train service, but will also return a replacement bus or ferry service if in place.


HTTP Request

GET https://api.departureboard.io/api/v2.0/getFastestDeparturesByCRS/{CRS}/


URL Parameters

Parameter Default Description
CRS
required
none The CRS (Computer Reservation System) for the station you wish to get departure information for, e.g. KGX for London Kings Cross.

Query Parameters

Parameter Default Description
apiKey
required
none The National Rail OpenLDBWS API Key to use for looking up service information. You must register with National Rail to obtain this key and whitelist it with us.
filterList
required
none The CRS (Computer Reservation System) codes to show the fastest departing services to. Up to 20 destination stations can be specified. These should be split by a comma, for example HAY,EAL,PAD.
timeOffset 0 The time window in minutes to offset the departure information by. For example, a value of 20 will show the fastest services departing after 20 minutes.
timeWindow 120 The time window to show train services for in minutes. For example, a value of 60 will show the fastest services departing the station in the next 60 minutes.
serviceDetails true Should the response contain information on the calling points for each service? If set to false, calling points will not be returned.

Example Queries

Lookup the fastest next departure from London Kings Cross to: Huntingdon, Peterborough and St. Neots: curl -X GET "https://api.departureboard.io/api/v2.0/getFastestDeparturesByCRS/KGX/?apiKey=01234&filterList=HUN,PBO,SNO"

Lookup the fastest next departure from London Kings Cross to: Huntingdon, Peterborough and St. Neots, departing within the next 5 minutes: curl -X GET "https://api.departureboard.io/api/v2.0/getFastestDeparturesByCRS/KGX/?apiKey=01234&filterList=HUN,PBO,SNO&timeWindow=5"

Lookup the fastest next departure from London Kings Cross to: Huntingdon, Peterborough and St. Neots, don’t return Calling Points: curl -X GET "https://api.departureboard.io/api/v2.0/getFastestDeparturesByCRS/KGX/?apiKey=01234&filterList=HUN,PBO,SNO&serviceDetails=false


Example Response

curl -X GET "https://api.departureboard.io/api/v2.0/getFastestDeparturesByCRS/EUS/?apiKey=1234&filterList=MKC,MAN"

Expand Response
{
"GeneratedAt": "2019-09-10T13:51:58.8967576+01:00",
"nationalRailResponseTimeMilliseconds": 135,
"locationName": "London Euston",
"crs": "EUS",
"filterLocationName": null,
"filtercrs": null,
"filterType": null,
"nrccMessages": null,
"platformAvailable": true,
"areServicesAvailable": null,
"destination": [
  {
    "crs": "MKC",
    "service": {
      "serviceID": "Zl3D4b/c5lYGfUNhF3Ylrg==",
      "serviceIDUrlSafe": "Zl3D4b_c5lYGfUNhF3Ylrg--",
      "serviceType": "train",
      "isCancelled": null,
      "filterLocationCancelled": null,
      "cancelReason": null,
      "delayReason": null,
      "adhocAlert": null,
      "std": "14:10",
      "etd": "On time",
      "sta": null,
      "eta": null,
      "platform": null,
      "operator": "Virgin Trains",
      "operatorCode": "VT",
      "isCircularRoute": null,
      "length": null,
      "detachFront": null,
      "isReverseFormation": null,
      "rsid": null,
      "origin": [
        {
          "locationName": "London Euston",
          "crs": "EUS",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "destination": [
        {
          "locationName": "Chester",
          "crs": "CTR",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "currentOrigins": null,
      "currentDestinations": null,
      "subsequentCallingPointsList": [
        {
          "subsequentCallingPoints": [
            {
              "locationName": "Milton Keynes Central",
              "crs": "MKC",
              "st": "14:40",
              "et": "On time",
              "at": null,
              "length": null
            },
            {
              "locationName": "Chester",
              "crs": "CTR",
              "st": "16:08",
              "et": "On time",
              "at": null,
              "length": null
            }
          ]
        }
      ]
    }
  },
  {
    "crs": "MAN",
    "service": {
      "serviceID": "j+meN1h8C66roUaXvm+iXg==",
      "serviceIDUrlSafe": "j!meN1h8C66roUaXvm!iXg--",
      "serviceType": "train",
      "isCancelled": null,
      "filterLocationCancelled": null,
      "cancelReason": null,
      "delayReason": null,
      "adhocAlert": null,
      "std": "14:00",
      "etd": "On time",
      "sta": null,
      "eta": null,
      "platform": "1",
      "operator": "Virgin Trains",
      "operatorCode": "VT",
      "isCircularRoute": null,
      "length": null,
      "detachFront": null,
      "isReverseFormation": null,
      "rsid": null,
      "origin": [
        {
          "locationName": "London Euston",
          "crs": "EUS",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "destination": [
        {
          "locationName": "Manchester Piccadilly",
          "crs": "MAN",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": null
        }
      ],
      "currentOrigins": null,
      "currentDestinations": null,
      "subsequentCallingPointsList": [
        {
          "subsequentCallingPoints": [
            {
              "locationName": "Stoke-on-Trent",
              "crs": "SOT",
              "st": "15:24",
              "et": "On time",
              "at": null,
              "length": null
            },
            {
              "locationName": "Manchester Piccadilly",
              "crs": "MAN",
              "st": "16:05",
              "et": "On time",
              "at": null,
              "length": null
            }
          ]
        }
      ]
    }
  }
]
}


Notes

When the serviceDetails query parameter is set to true for getFastestDeparturesByCRS, only subsequent calling points will be returned. This is by design from National Rail.

To get subsequent and previous calling points for a service, take the serviceIDUrlSafe value is provided in the response and use the getServiceDetailsByID endpoint to lookup more details.

It is possible to have two sets of subsequentCallingPoints returned for a service (when looking up train services that split).

Consequently, subsequentCallingPoints are returned in the subsequentCallingPointsList array.

However, in 99% of circumstances there are only 1 set of subsequentCallingPoints returned. For services that do not split, you can use subsequentCallingPointsList[0].subsequentCallingPoints to access the previous calling points. The Python Code Samples have examples of how this works.