Obs: Detta innehåll finns inte tillgängligt på svenska. Därför ser du engelska versionen. Om du tycker att denna sida borde översättas till svenska, kan du skriva till oss på support.trafiklab.se.

Om du vill se webbsidan på engelska, klicka här.

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. It does not require an API key.

URL

1https://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 (4-7 digits), 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

 1[
 2  {
 3    "version": 1,
 4    "created": "2022-03-03T19:03:48.713+01:00",
 5    "modified": "2022-03-03T19:03:48.713+01:00",
 6    "deviation_case_id": 52432153,
 7    "publish": {
 8      "from": "2022-03-03T19:03:48.700+01:00",
 9      "upto": "2022-03-03T20:03:00.000+01:00"
10    },
11    "priority": {
12      "importance_level": 2,
13      "influence_level": 3,
14      "urgency_level": 1
15    },
16    "message_variants": [
17      {
18        "header": "Entré vid Medborgarplatsen stängd",
19        "details": "Vid Medborgarplatsen är entrén från Folkungagatan stängd på grund av underhållsarbete.",
20        "scope_alias": "tunnelbanans röda linje 13",
21        "weblink": "https://sl.se",
22        "language": "sv"
23      }
24    ],
25    "scope": {
26      "stop_areas": [
27        {
28          "id": 1511,
29          "transport_authority": 1,
30          "name": "Medborgarplatsen",
31          "type": "METROSTN",
32          "stop_points": [
33            {
34              "id": 222,
35              "name": "Norrö"
36            }
37          ]
38        }
39      ],
40      "lines": [
41        {
42          "id": 17,
43          "transport_authority": 1,
44          "designation": "17",
45          "transport_mode": "METRO",
46          "name": "Gröna linjen",
47          "group_of_lines": "Tunnelbanans gröna linje"
48        }
49      ]
50    }
51  }
52]

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
modifiedDateTimeWhen the message was last updated, if it has been updated2022-03-03T19:03:48.713+01:00
deviation_case_idIntegerThe id for the deviation52432153
publish.fromDateTimeStart of the period when this deviation message version is valid2022-03-03T19:03:48.700+01:00
publish.uptoDateTimeEnd 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
scopeObjectThe stop(s) and/or line(s) affected by the deviation
scope.stop_areasArrayThe 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.linesArrayThe affected line(s)
scope.lines.idIntegerLine id17
scope.lines.transport_authorityIntegerLine transport authority1
scope.lines.designationStringLine 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