SL Departures 4

Description

Real-time information regarding buses, subways, commuter trains, and local trains.

This API will be shut down at the end of March 2024. It is replaced by SL’s new transport API.

URL

https://api.sl.se/api2/realtimedeparturesV4.<FORMAT>?key=<YOUR API KEY>&siteid=<SITEID>&timewindow=<TIMEWINDOW>

API Key Levels

LevelMax calls/minuteMax calls/month
Bronze3010,000
Silver60500,000
Silver +601,500,000
Gold10,000,000
Gold +30,000,000
PlatinumOn demand

Format

JSON or XML according to the extension in the service call.

Parameters

ParametersData TypeMandatoryDescription
FormatStringYesFormat of the response data. Valid values are “json” or “xml”.
SiteIdIntegerYesUnique identification number for the location for which current departures should be fetched, e.g., 9192 for Slussen. Obtained from the SL Location Lookup service.
TimeWindowIntegerYesFetch departures within the desired time window. The time window is the number of minutes from now. Max 60.
KeyStringYesA valid API key.
BusBooleanNoDefault = true. If false, excludes bus data from the response.
MetroBooleanNoDefault = true. If false, excludes metro data from the response.
TrainBooleanNoDefault = true. If false, excludes train data from the response.
TramBooleanNoDefault = true. If false, excludes tram data from the response.
ShipBooleanNoDefault = false. If true, includes information about uncertain prognosis.
EnablePredictionBooleanNoDefault = true. If false, excludes prediction data from the response.

Result

Results from real-time search. For XML format, the root element name is “ResponseOfDepartures.”

Response Structure

NameData TypeDescription
StatusCodeIntegerContains the status code for the possible message.
MessageStringContains any call-related messages such as error messages. See “Error Messages” below.
ExecutionTimeLongIndicates how long (in ms) it took for the server to generate the response.
ResponseDataDepartureContains the actual response data from the service. See “Response Data” below.

Response Data/ResponseData

NameData TypeDescription
LatestUpdateDateTimeIndicates when the real-time information (DPS) was last updated.
DataAgeIntegerNumber of seconds since the LatestUpdate timestamp.
BusesListList of all bus departures for the given siteId, see response structure.
MetrosListList of all subway departures for the given siteId, see response structure.
TrainsListList of all commuter train departures for the given siteId, see response structure.
TramsListList of all local train departures for the given siteId, see response structure.
ShipsListList of all boat departures for the given siteId, see response structure.
StopPointDeviationsListList of stop area-specific deviations/disruptions. In other words, disruptions not tied to a specific departure.

Departure

NameData TypeDescription
TransportModeStringMode of transport: “BUS”, “METRO”, “TRAIN”, “TRAM”, or “SHIP”.
LineNumberStringLine designation/number.
DestinationStringName of the line’s end station.
JourneyDirectionIntegerJourney direction ID. 0 for unknown direction, otherwise 1 or 2.
GroupOfLineStringFor bus: Specifies if it is a blue bus. If it is a blue bus, it says “bluebus”, otherwise the element is missing (XML) or null (JSON). For local train: Line group, e.g., “Tvärbanan” or “Roslagsbanan”. For subway: Line grouping. Red/green/blue line. For boat: Specifies if it is a commuter boat or Waxholmsbolaget.
StopAreaNameStringStop area name.
StopAreaNumberIntegerID for the current stop area. Subway before transfer: 0.
StopPointNumberIntegerID for the current stopping point. Subway before transfer: 0.
StopPointDesignationStringAdditional identifier for stopping point, e.g., letter for bus shelter or track for commuter train.
TimeTabledDateTimeDateTimeDeparture time according to the timetable.
ExpectedDateTimeDateTimeExpected departure time. If there is an associated disruption with sufficiently high priority, this may be null/empty. This is the case until a few minutes before departure.
DisplayTimeStringDeparture time for presentation. Can take formats like x min, HH:mm, or Now. If there is an associated disruption with sufficiently high priority, this may be set to “-”. This is the case until a few minutes before departure.
JourneyNumberIntegerJourney number for the departure.
DeviationsListContains the type “Deviation” below. This can be empty or contain 1 to several deviations.
SecondaryDestinationNameStringOnly for: Commuter train. Name of the intermediate destination.
PredictionStateStringCan have three different values: NORMAL, UNRELIABLE, UNKNOWN. UNRELIABLE indicates an uncertain prognosis. Name of the intermediate destination.

Deviation

NameData TypeDescription
ConsequenceStringDescription of the consequence for the current deviation.
ImportanceLevelIntegerSignificance level of the current deviation. 0-9 where 9 is most severe.
TextStringDescription of the current deviation.

StopPointDeviations

NameData TypeDescription
StopInfoStopInfoStop information. May be empty. See StopInfo.
DeviationDeviationDeviation information. May be empty. See Deviation.

StopInfo

NameData TypeDescription
GroupOfLineStringIf TransportMode is “TRAM”, this node contains one of the following values: “Lidingöbanan”, “Nockebybanan”, “Roslagsbanan”, “Saltsjöbanan”, “Spårväg City”, “Tvärbanan”. Otherwise blank (subject to change).
StopAreaNameStringName of the stop area affected by the deviation.
StopAreaNumberIntegerID of the stop area affected by the deviation. Is zero if TransportMode is not BUS.
TransportModeString“METRO”, “BUS”, “TRAIN”, “TRAM”, or unspecified.

Error Messages

Status CodeMessage
1001Key not provided.
1002Invalid key.
1003Invalid API.
1004Problem with request: This API is currently not available for keys with priority above 2.
1005Key exists, but not for this API.
1006Too many requests per minute for the profile being used.
1007Too many requests per month for the profile being used.
4001SiteId must be convertible to an integer.
5321Couldn’t retrieve information from TPI (subway) or DPS (other modes of transportation).
5322Couldn’t retrieve information from DPS.
5323Couldn’t retrieve information from TPI.
5324Couldn’t retrieve information from TPI (subway) or DPS (other modes of transportation) due to outdated DPS data. This occurs if the DPS data is more than 2 minutes old at the time of response.

Support

If the documentation is insufficient, please search through the hundreds of posts on our support forum. It’s likely that someone has already encountered and solved the same problem you’re facing.

If you still can’t find an answer to your question, create a new post on the forum and we’ll assist you.