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

NamnTypeRequiredDescription
KeyStringYesThe API key, TRAFIKLAB-SLAPI-INTEGRATION-2024 for new users since oktober 1st 2024.
originCoordLatStringYesLatitude
originCoordLongStringYesLongitude
maxNoIntegerNoThe desired number of results. Default 9, maximum value 1000.
rIntegerNoRadius defining how far to search from the given coordinate, in meters. 1000 is default, 2000 is the maximum value..
productsIntegerNoProduct filter specifying which stations to include. The value is obtained by summing the desired values:
  • Commuter train (1)
  • Underground (2)
  • Tram and light rail (4)
  • Bus (8)
  • Boat/Ferry typ (64)
  • Nearby traffic (Närtafik) (128)
For example, bus and boat results in 8+64 = 72
typeStringNoType filter for stops:
  • S: Stations only
  • P: Points of interests (POI) only
  • SP: Stations and POIs

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

NameTypeDescription
serverVersionStringTechnical version information
dialectVersionStringTechnical version information
requestIdLongA technical id identifying the request
stopLocationOrCoordLocationStopLocationContains the actual response data

stopLocationOrCoordLocation

NameTypeDescription
stopLocationOrCoordLocationListList of the found places. All items are either a ”StopLocation” or a ”CoordLocation”, described below.

StopLocation

NameTypeDescription
IdStringReconstruction Id, see travel planner API
NameStringStop name
extIdStringHafasId for this stop. See “HafasId and SiteId” below.
mainMastExtIdIntegerSiteId for use with SL Route-planner. See “HafasId and SiteId” below.
LatDoubleLatitude
LonDoubleLongitude
WeightIntegerHow trafficked a station is. Higher means more traffic.
DistIntegerDistance between the requested coordinate and this stop, in meters.
ProductsIntegerSee description for request parameters

Coordlocation

NameTypeDescription
IdStringReseplanerar reconstruction Id, se reseplanerarens documentation
NameStringNamn för POI.
LatStringLat.
LonStringLong.
DistStringDistans i meter från försedd koordinat i anropet.
TypeStringVisar i nuläget endast ”POI”
LocationNotesLista av elementSe nedan

LocationNote

These values are examples and subject to change.

KeyValue
PIUnique id
PCPOI type:Amenity, Historic, Leisure, Shop or Tourism
PTPOI type: Hospital, School, Theatre, University, Castle, Park, Library, Mall, Attraction, Chalet, Museum, Viewpoint eller Zoo
CNName 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.

TypeDescriptionExample
SiteId3BA1CDEFG 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
StopId4BA1CDEFG where ABCDEFG are the 7 last digits of JourneyPatternPoint.number padded with zeroes.JourneyPatternPoint.Number: 56789 → HafasId: 400156789
StopAreaId2BA1CDEFG 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.

StatuskodMeddelande
1001problem with request: Key is undefinedNyckel har ej skickats med.
1002problem with request: Key is invalidNyckel är ogiltig
1003Invalid apiOgiltigt api
1004problem with request: This api is currently not available for keys with priority above 2
1005Nyckel finns, men ej för detta apiproblem with request: Invalid api for key
1006To many requests per minuteFör många anrop per minut, för den profil som används
1007To many requests per monthFör många anrop per månad, för den profil som används
R0001Unknown service method
R0002Invalid or missing request parameters.
R0007Internal communication error.