SL's APIs
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. 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
Namn | Type | Required | Default value | Description |
---|---|---|---|---|
future | Boolean | No | False | Include future deviations |
site | Integer (4-7 digits), can be specified multiple times | No | Empty (all sites) | Only include results with these site ids |
line | Integer, can be specified multiple times | No | Empty (all lines) | Only include results with these line ids |
transport_authority | integer | No | Empty (all transport authorities) | Only include results with this transport authority |
transport_mode | String, can be specified multiple times | No | Empty (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.
Header | Description |
---|---|
Accept-Encoding | Controls 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. |
age | Useful for caching responses. The time in seconds since the cached response was generated at first. |
Response
Response codes
Code | Description |
---|---|
200 | Ok, a valid API response is returned. |
400 | Bad request, one of the request parameters contains an invalid value. |
404 | Not found, the URL is incorrect |
500 | Error on the server side |
502 | Error on the server side |
503 | Error on the server side |
504 | Service temporary unavailable |
Headers
Header | Description |
---|---|
Content-Encoding | Content-Encoding of response to enable gzip compressed responses for client that accept it |
Cache-Control | Useful 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:
Name | Type | Description | Example value |
---|---|---|---|
version | Integer | The message version (sequential) | 1 |
created | DateTime | When the message was created | 2022-03-03T19:03:48.713+01:00 |
modified | DateTime | When the message was last updated, if it has been updated | 2022-03-03T19:03:48.713+01:00 |
deviation_case_id | Integer | The id for the deviation | 52432153 |
publish.from | DateTime | Start of the period when this deviation message version is valid | 2022-03-03T19:03:48.700+01:00 |
publish.upto | DateTime | End of the period when this deviation message version is valid | 2022-03-03T19:03:48.700+01:00 |
priority. | Integer | The 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. | Integer | The 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. | Integer | The 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_variants | Array | Variants of a message in different languages | |
message_variants. | String | The header of the message | Entré vid Medborgarplatsen stängd |
message_variants. | String | The full contents of the message | Vid Medborgarplatsen är entrén från Folkungagatan stängd på grund av underhållsarbete. |
message_variants. | String | A readable representation of the scope | Tunnelbanans röda linje 13 |
message_variants. | String | The header of the message | https://sl.se |
message_variants. | String | The language of the message | sv |
scope | Object | The stop(s) and/or line(s) affected by the deviation | |
scope. | Array | The affected stop area(s) | |
scope. | Integer | Stop Area transport authority id | 1 |
scope. | Integer | Stop Area id | 1511 |
scope. | String | Stop Area name | Medborgarplatsen |
scope. | String | Stop Area type | METROSTN |
scope. | Array | The affected stop point(s) | |
scope. | Integer | Stop point id | 222 |
scope. | String | Stop point name | Norrö |
scope. | Array | The affected line(s) | |
scope. | Integer | Line id | 17 |
scope. | Integer | Line transport authority | 1 |
scope. | String | Line designation | 17 |
scope. | String | Line transport mode. Valid values: BUS, METRO, TRAM, TRAIN, SHIP, FERRY, TAXI | METRO |
scope. | String | Line name | Gröna linjen |
scope. | String | Name used to group lines | Gröna linjen |