SL's APIs
SL Nearby stops 2
Description
Using this API, you can find SL stops near a pair of coordinates.
URL
https://journeyplanner.integration.sl.se/v1/nearbystopsv2.<FORMAT>?key=TRAFIKLAB-SLAPI-INTEGRATION-2024&originCoordLat=<LAT>&originCoordLong=<LONG>&maxNo=<MAX ANTAL SVAR>&r=<RADIUS I METER>
The old
URL
https://api.sl.se/api2/nearbystopsv2.<FORMAT>?key=TRAFIKLAB-SLAPI-INTEGRATION-2024&originCoordLat=<LAT>&originCoordLong=<LONG>&maxNo=<MAX ANTAL SVAR>&r=<RADIUS I METER>
has
changed on December 4rd, and will stop working on March 15th.
Query parameters, response bodies and API keys remain unchanged.Format
Json or xml, as specified in the API request.
Request
Parameters
Namn | Type | Required | Description |
---|---|---|---|
Key | String | Yes | The API key, TRAFIKLAB-SLAPI-INTEGRATION-2024 for new users since oktober 1st 2024. |
originCoordLat | String | Yes | Latitude |
originCoordLong | String | Yes | Longitude |
maxNo | Integer | No | The desired number of results. Default 9, maximum value 1000. |
r | Integer | No | Radius defining how far to search from the given coordinate, in meters. 1000 is default, 2000 is the maximum value.. |
products | Integer | No | Product filter specifying which stations to include. The value is obtained by summing the desired values:
|
type | String | No | Type filter for stops:
|
Example call
1https://journeyplanner.integration.sl.se/v1/nearbystopsv2.json?originCoordLat=59.328284&originCoordLong=18.016154&key=TRAFIKLAB-SLAPI-INTEGRATION-2024
1https://journeyplanner.integration.sl.se/v1/nearbystopsv2.xml?originCoordLat=59.328284&originCoordLong=18.016154&key=TRAFIKLAB-SLAPI-INTEGRATION-2024
Response
Structure
Name | Type | Description |
---|---|---|
serverVersion | String | Technical version information |
dialectVersion | String | Technical version information |
requestId | Long | A technical id identifying the request |
stopLocationOrCoordLocation | StopLocation | Contains the actual response data |
stopLocationOrCoordLocation
Name | Type | Description |
---|---|---|
stopLocationOrCoordLocation | List | List of the found places. All items are either a ”StopLocation” or a ”CoordLocation”, described below. |
StopLocation
Name | Type | Description |
---|---|---|
Id | String | Reconstruction Id, see travel planner API |
Name | String | Stop name |
extId | String | HafasId for this stop. See “HafasId and SiteId” below. |
mainMastExtId | Integer | SiteId for use with SL Route-planner. See “HafasId and SiteId” below. |
Lat | Double | Latitude |
Lon | Double | Longitude |
Weight | Integer | How trafficked a station is. Higher means more traffic. |
Dist | Integer | Distance between the requested coordinate and this stop, in meters. |
Products | Integer | See description for request parameters |
Coordlocation
Name | Type | Description |
---|---|---|
Id | String | Reseplanerar reconstruction Id, se reseplanerarens documentation |
Name | String | Namn för POI. |
Lat | String | Lat. |
Lon | String | Long. |
Dist | String | Distans i meter från försedd koordinat i anropet. |
Type | String | Visar i nuläget endast ”POI” |
LocationNotes | Lista av element | Se nedan |
LocationNote
These values are examples and subject to change.
Key | Value |
---|---|
PI | Unique id |
PC | POI type:Amenity, Historic, Leisure, Shop or Tourism |
PT | POI type: Hospital, School, Theatre, University, Castle, Park, Library, Mall, Attraction, Chalet, Museum, Viewpoint eller Zoo |
CN | Name of the municipality in which the POI is located |
HafasId och SiteId
Information regarding how ids relate to Hafas ids used in the route planner API.
Type | Description | Example |
---|---|---|
SiteId | 3BA1CDEFG where ABCDEFG are the 7 last digits of site.number padded with zeroes. Note the first two digits which change place! | SiteId: 9600 → HafasId: 300109600 |
StopId | 4BA1CDEFG where ABCDEFG are the 7 last digits of JourneyPatternPoint.number padded with zeroes. | JourneyPatternPoint.Number: 56789 → HafasId: 400156789 |
StopAreaId | 2BA1CDEFG where ABCDEFG are the 7 last digits of StopArea.number padded with zeroes. | StopArea.number: 81025 → HafasId: 200181025 |
Example response
1{
2 "stopLocationOrCoordLocation": [
3 {
4 "StopLocation": {
5 "id": "A=1@O=Marieberg@X=18016154@Y=59328284@u=0@U=74@L=400110905@",
6 "extId": "400110905",
7 "hasMainMast": true,
8 "mainMastId": "A=1@O=Marieberg (Stockholm)@X=18015533@Y=59328410@U=74@L=300101273@",
9 "mainMastExtId": "300101273",
10 "name": "Marieberg",
11 "lon": 18.016154,
12 "lat": 59.328284,
13 "weight": 388,
14 "dist": 0,
15 "products": 8
16 }
17 },
18 {
19 "StopLocation": {
20 "id": "A=1@O=Wennerbergsgatan@X=18014140@Y=59328347@u=0@U=74@L=400110903@",
21 "extId": "400110903",
22 "hasMainMast": true,
23 "mainMastId": "A=1@O=Wennerbergsgatan (Stockholm)@X=18013061@Y=59328518@U=74@L=300101263@",
24 "mainMastExtId": "300101263",
25 "name": "Wennerbergsgatan",
26 "lon": 18.01414,
27 "lat": 59.328347,
28 "weight": 388,
29 "dist": 114,
30 "products": 8
31 }
32 },
33 {
34 "StopLocation": {
35 "id": "A=1@O=Fria Ukrainas plats@X=18017871@Y=59327286@u=0@U=74@L=400110729@",
36 "extId": "400110729",
37 "hasMainMast": true,
38 "mainMastId": "A=1@O=Fria Ukrainas plats (Stockholm)@X=18017592@Y=59327124@U=74@L=300101271@",
39 "mainMastExtId": "300101271",
40 "name": "Fria Ukrainas plats",
41 "lon": 18.017871,
42 "lat": 59.327286,
43 "weight": 1465,
44 "dist": 147,
45 "products": 8
46 }
47 },
48 {
49 "StopLocation": {
50 "id": "A=1@O=Västerbroplan@X=18020109@Y=59328302@u=0@U=74@L=400110727@",
51 "extId": "400110727",
52 "hasMainMast": true,
53 "mainMastId": "A=1@O=Västerbroplan (Stockholm)@X=18021125@Y=59328176@U=74@L=300101270@",
54 "mainMastExtId": "300101270",
55 "name": "Västerbroplan",
56 "lon": 18.020109,
57 "lat": 59.328302,
58 "weight": 1465,
59 "dist": 224,
60 "products": 8
61 }
62 },
63 {
64 "StopLocation": {
65 "id": "A=1@O=Wivalliusgatan@X=18013205@Y=59326558@u=0@U=74@L=400110450@",
66 "extId": "400110450",
67 "hasMainMast": true,
68 "mainMastId": "A=1@O=Wivalliusgatan (Stockholm)@X=18013196@Y=59326540@U=74@L=300101272@",
69 "mainMastExtId": "300101272",
70 "name": "Wivalliusgatan",
71 "lon": 18.013205,
72 "lat": 59.326558,
73 "weight": 1465,
74 "dist": 254,
75 "products": 8
76 }
77 }
78 ],
79 "serverVersion": "1.4",
80 "dialectVersion": "1.23",
81 "requestId": "1701701254662"
82}
1<?xml version="1.0" encoding="UTF-8"?>
2<LocationList serverVersion="1.4" dialectVersion="1.23" requestId="1701701276854" xmlns="hafas_rest">
3 <StopLocation id="A=1@O=Marieberg@X=18016154@Y=59328284@u=0@U=74@L=400110905@" extId="400110905" name="Marieberg" hasMainMast="true"
4 mainMastId="A=1@O=Marieberg (Stockholm)@X=18015533@Y=59328410@U=74@L=300101273@" mainMastExtId="300101273" lon="18.016154" lat="59.328284"
5 weight="388" products="8" dist="0"/>
6 <StopLocation id="A=1@O=Wennerbergsgatan@X=18014140@Y=59328347@u=0@U=74@L=400110903@" extId="400110903" name="Wennerbergsgatan" hasMainMast="true"
7 mainMastId="A=1@O=Wennerbergsgatan (Stockholm)@X=18013061@Y=59328518@U=74@L=300101263@" mainMastExtId="300101263" lon="18.01414"
8 lat="59.328347" weight="388" products="8" dist="114"/>
9 <StopLocation id="A=1@O=Fria Ukrainas plats@X=18017871@Y=59327286@u=0@U=74@L=400110729@" extId="400110729" name="Fria Ukrainas plats" hasMainMast="true"
10 mainMastId="A=1@O=Fria Ukrainas plats (Stockholm)@X=18017592@Y=59327124@U=74@L=300101271@" mainMastExtId="300101271" lon="18.017871"
11 lat="59.327286" weight="1465" products="8" dist="147"/>
12 <StopLocation id="A=1@O=Västerbroplan@X=18020109@Y=59328302@u=0@U=74@L=400110727@" extId="400110727" name="Västerbroplan" hasMainMast="true"
13 mainMastId="A=1@O=Västerbroplan (Stockholm)@X=18021125@Y=59328176@U=74@L=300101270@" mainMastExtId="300101270" lon="18.020109" lat="59.328302"
14 weight="1465" products="8" dist="224"/>
15 <StopLocation id="A=1@O=Wivalliusgatan@X=18013205@Y=59326558@u=0@U=74@L=400110450@" extId="400110450" name="Wivalliusgatan" hasMainMast="true"
16 mainMastId="A=1@O=Wivalliusgatan (Stockholm)@X=18013196@Y=59326540@U=74@L=300101272@" mainMastExtId="300101272" lon="18.013205"
17 lat="59.326558" weight="1465" products="8" dist="254"/>
18</LocationList>
XSD
https://api.sl.se/api2/nearbystops/xsd.xml?key=TRAFIKLAB-SLAPI-INTEGRATION-2024&xsdname=hafasRestLocation.xsd</p>
Error messages
The language in the response matches the language in the request.
Statuskod | Meddelande |
---|---|
1001 | problem with request: Key is undefinedNyckel har ej skickats med. |
1002 | problem with request: Key is invalidNyckel är ogiltig |
1003 | Invalid apiOgiltigt api |
1004 | problem with request: This api is currently not available for keys with priority above 2 |
1005 | Nyckel finns, men ej för detta apiproblem with request: Invalid api for key |
1006 | To many requests per minuteFör många anrop per minut, för den profil som används |
1007 | To many requests per monthFör många anrop per månad, för den profil som används |
R0001 | Unknown service method |
R0002 | Invalid or missing request parameters. |
R0007 | Internal communication error. |