SL Traffic status 2

Due to technical reasons, this API is being replaced by SLs Deviations API and GTFS Service alerts. It will stop working in the near future.

Description

This API provides information about the current status of SL’s traffic situation. It offers an overview of the current status for each type of traffic. The information used by this API can be found on the front page of sl.se under the heading “Trafikläget kl. xx:xx” (“Traffic situation at xx:xx”). The API has only one method that returns a summary of the current traffic situation, considering disruptions that may affect passengers. The response is a list of different traffic types, each with a summary status and a number of events (0 or more). There are three possible statuses for events:

  • “No major disruptions”
  • “Major impact”
  • “Closed”

An event affects its traffic type, so that the traffic type’s summary status is equal to the worst status among currently active events belonging to that traffic type. In addition to the status, an event may also be planned.

SL will replace this API with a new, similar API in the near future. The documentation for the current API has therefore not been translated for the new Trafiklab website.

URL

https://api.sl.se/api2/trafficsituation.<FORMAT>?key=<YOUR API KEY>

API Key Levels

LevelMax requests/minuteMax requests/month
Bronze3010,000
Silver60100,000
GoldAs needed

Format

JSON or XML according to the format specified in the service call.

Parameters

ParametersData TypeMandatoryDescription
KeyStringYesA valid API key.

Result

Response Structure

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

Response Data

NameData TypeDescription
TrafficTypesListA TrafficType object for each type of traffic.

TrafficType

NameData TypeDescription
NameStringName of the traffic type: “Tunnelbana”, “Pendeltåg”, etc.
TypeString“metro”, “train”, “local”, “tram”, “bus” or “fer”. fer = Boat, local = Local train, tram = Tram
StatusIconStringAssistive information indicating which icon to display on the web. Possible values: EventMajor: “Closed”, EventMinor: “Major impact”, EventGood: “No major disruptions”, EventPlanned: “Planned event”
ExpandedBooleanAssistive information indicating whether the information has high priority or not.
HasPlannedEventBooleanAssistive information indicating whether there are planned events.
EventsListA TrafficEvent object for each event.

TrafficEvent

NameData TypeDescription
EventIdIntegerEvent number.
MessageStringMessage regarding the disruption/event.
ExpandedBooleanAssistive information indicating whether the information has high priority or not.
PlannedBooleanAssistive information indicating whether the event is planned or not.
SortIndexIntegerSorting order of the event.
StatusIconStringAssistive information indicating which icon to display on the web.
LineNumbersStringLine numbers affected by the event, a comma-separated string e.g., “177, 69K, 508”.
LineNumbers/InputDataIsOptionalBooleanAlways set to True, indicating that line numbers are optional.
TrafficLineStringName of the line affected by the event. May be absent if the event affects the entire traffic type or if lines do not exist (e.g., buses).
EventInfoUrlStringLink to storningsinformation.sl.se, or to a specific page with information about the event.

Error Messages

No error messages are available at this time.

Support

If the documentation is not sufficient, please search among the hundreds of posts on our support forum. It is likely that someone has already encountered and solved the same problem you have. If you still cannot find an answer to your question, post your own thread on the forum and we will assist you.