SL Deviations

Description

Using this API, you can get information regarding deviations on SLs transport network. This API replaces the older Service Alerts (Störningsinformation) and Traffic Status (Trafikläget) APIs.

URL

https://deviations.integration.sl.se/v1/messages?future=<true/false>&site=<siteId1,siteId2>&line=<lineId1,lineId2>&transport_mode=<mode1,mode2>

Format

This API returns responses in the JSON format.

Request

Key quota levels

This API does not require API keys, and has no quota levels. Fair use rules apply however, and you should only make a request once a minute.

Parameters

NamnTypeRequiredDefault valueDescription
futureBooleanNoFalseInclude future deviations
siteInteger, can be specified multiple timesNoEmpty (all sites)Only include results with these site ids
lineInteger, can be specified multiple timesNoEmpty (all lines)Only include results with these line ids
transport_authorityintegerNoEmpty (all transport authorities)Only include results with this transport authority
transport_modeString, can be specified multiple timesNoEmpty (all modes)Only include results with this transport mode. Valid values: BUS, METRO, TRAM, TRAIN, SHIP, FERRY, TAXI

Headers

These specific headers may be used to alter the response sent by the server.

HeaderDescription
Accept-EncodingControls the compression used by the server. Typically managed by the HTTP client used. Valid values are ‘gzip’, ‘identity’ and ‘deflate’. When using this header, your client has to have support for the given compression standard.
ageUseful for caching responses. The time in seconds since the cached response was generated at first.

Response

Response codes

CodeDescription
200Ok, a valid API response is returned.
400Bad request, one of the request parameters contains an invalid value.
404Not found, the URL is incorrect
500Error on the server side
502Error on the server side
503Error on the server side
504Service temporary unavailable

Headers

HeaderDescription
Content-EncodingContent-Encoding of response to enable gzip compressed responses for client that accept it
Cache-ControlUseful for caching responses. Cache-Control containing max-age, as described in RFC 7234, 5.2

Example response

[
  {
    "version": 1,
    "created": "2022-03-03T19:03:48.713+01:00",
    "modified": "2022-03-03T19:03:48.713+01:00",
    "deviation_case_id": 52432153,
    "publish": {
      "from": "2022-03-03T19:03:48.700+01:00",
      "upto": "2022-03-03T20:03:00.000+01:00"
    },
    "priority": {
      "importance_level": 2,
      "influence_level": 3,
      "urgency_level": 1
    },
    "message_variants": [
      {
        "header": "Entré vid Medborgarplatsen stängd",
        "details": "Vid Medborgarplatsen är entrén från Folkungagatan stängd på grund av underhållsarbete.",
        "scope_alias": "tunnelbanans röda linje 13",
        "weblink": "https://sl.se",
        "language": "sv"
      }
    ],
    "scope": {
      "stop_areas": [
        {
          "id": 1511,
          "transport_authority": 1,
          "name": "Medborgarplatsen",
          "type": "METROSTN",
          "stop_points": [
            {
              "id": 222,
              "name": "Norrö"
            }
          ]
        }
      ],
      "lines": [
        {
          "id": 17,
          "transport_authority": 1,
          "designation": "17",
          "transport_mode": "METRO",
          "name": "Gröna linjen",
          "group_of_lines": "Tunnelbanans gröna linje"
        }
      ]
    }
  }
]

Response structure

The response consists of an array of deviations. Every deviation contains the following fields:

NameTypeDescriptionExample value
versionIntegerThe message version (sequential)1
createdDateTimeWhen the message was created2022-03-03T19:03:48.713+01:00
modifiedDateTime (Optional)When the message was last updated, if it has been updated2022-03-03T19:03:48.713+01:00
deviation_case_idInteger (Optional)The id for the deviation52432153
publish.fromDateTimeStart of the period when this deviation message version is valid2022-03-03T19:03:48.700+01:00
publish.uptoDateTime (Optional)End of the period when this deviation message version is valid2022-03-03T19:03:48.700+01:00
priority.importance_levelIntegerThe importance level of the deviation message, only used to sort messages. The importance gives a presentation system a hint of what message to present first. This value should have the highest data quality of all three priority fields. When in doubt, use this value to sort messages based on priority and ignore the other two fields.2
priority.influence_levelIntegerThe influence level of the deviation message, only used to sort messages. This influence level is a hint about how many persons that is influenced by a deviation.3
priority.urgency_levelIntegerThe urgency level of the deviation message, only used to sort messages. This is a hint of how fast information about a deviation shall reach the receivers.1
message_variantsArrayVariants of a message in different languages
message_variants.headerStringThe header of the messageEntré vid Medborgarplatsen stängd
message_variants.detailsStringThe full contents of the messageVid Medborgarplatsen är entrén från Folkungagatan stängd på grund av underhållsarbete.
message_variants.scope_aliasStringA readable representation of the scopeTunnelbanans röda linje 13
message_variants.weblinkStringThe header of the messagehttps://sl.se
message_variants.languageStringThe language of the messagesv
scopeObject (Optional)The stop(s) and/or line(s) affected by the deviation
scope.stop_areasArray (Optional)The affected stop area(s)
scope.stop_areas.transport_authorityIntegerStop Area transport authority id1
scope.stop_areas.idIntegerStop Area id1511
scope.stop_areas.nameStringStop Area nameMedborgarplatsen
scope.stop_areas.typeStringStop Area typeMETROSTN
scope.stop_pointsArrayThe affected stop point(s)
scope.stop_points.idIntegerStop point id222
scope.stop_points.nameStringStop point nameNorrö
scope.linesArray (Optional)The affected line(s)
scope.lines.idIntegerLine id17
scope.lines.transport_authorityIntegerLine transport authority1
scope.lines.designationString (Optional)Line designation17
scope.lines.transport_modeStringLine transport mode. Valid values: BUS, METRO, TRAM, TRAIN, SHIP, FERRY, TAXIMETRO
scope.lines.nameStringLine nameGröna linjen
scope.lines.group_of_linesStringName used to group linesGröna linjen

OpenAPI specification