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=<DIN NYCKEL>&originCoordLat=<LAT>&originCoordLong=<LONG>&maxNo=<MAX ANTAL SVAR>&r=<RADIUS I METER>

The old URL https://api.sl.se/api2/nearbystopsv2.<FORMAT>?key=<DIN NYCKEL>&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

API key quota levels

LevelMax requests/minuteMax requests/month
Bronze3010 000
Silver60500 000
GoldAs needed

Parameters

NamnTypeRequiredDescription
KeyStringYesYour API key
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
  • A: Addresses only
  • SP: Stations and POIs
  • SA: Stations and addresses
  • AP: Addresses and POI
  • ALL: Stations, Addresses and POI

Example call

https://journeyplanner.integration.sl.se/v1/nearbystopsv2.json?originCoordLat=59.328284&originCoordLong=18.016154&key=<YOUR KEY>
https://journeyplanner.integration.sl.se/v1/nearbystopsv2.xml?originCoordLat=59.328284&originCoordLong=18.016154&key=<YOUR KEY>

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

{
  "stopLocationOrCoordLocation": [
    {
      "StopLocation": {
        "id": "A=1@O=Marieberg@X=18016154@Y=59328284@u=0@U=74@L=400110905@",
        "extId": "400110905",
        "hasMainMast": true,
        "mainMastId": "A=1@O=Marieberg (Stockholm)@X=18015533@Y=59328410@U=74@L=300101273@",
        "mainMastExtId": "300101273",
        "name": "Marieberg",
        "lon": 18.016154,
        "lat": 59.328284,
        "weight": 388,
        "dist": 0,
        "products": 8
      }
    },
    {
      "StopLocation": {
        "id": "A=1@O=Wennerbergsgatan@X=18014140@Y=59328347@u=0@U=74@L=400110903@",
        "extId": "400110903",
        "hasMainMast": true,
        "mainMastId": "A=1@O=Wennerbergsgatan (Stockholm)@X=18013061@Y=59328518@U=74@L=300101263@",
        "mainMastExtId": "300101263",
        "name": "Wennerbergsgatan",
        "lon": 18.01414,
        "lat": 59.328347,
        "weight": 388,
        "dist": 114,
        "products": 8
      }
    },
    {
      "StopLocation": {
        "id": "A=1@O=Fria Ukrainas plats@X=18017871@Y=59327286@u=0@U=74@L=400110729@",
        "extId": "400110729",
        "hasMainMast": true,
        "mainMastId": "A=1@O=Fria Ukrainas plats (Stockholm)@X=18017592@Y=59327124@U=74@L=300101271@",
        "mainMastExtId": "300101271",
        "name": "Fria Ukrainas plats",
        "lon": 18.017871,
        "lat": 59.327286,
        "weight": 1465,
        "dist": 147,
        "products": 8
      }
    },
    {
      "StopLocation": {
        "id": "A=1@O=Västerbroplan@X=18020109@Y=59328302@u=0@U=74@L=400110727@",
        "extId": "400110727",
        "hasMainMast": true,
        "mainMastId": "A=1@O=Västerbroplan (Stockholm)@X=18021125@Y=59328176@U=74@L=300101270@",
        "mainMastExtId": "300101270",
        "name": "Västerbroplan",
        "lon": 18.020109,
        "lat": 59.328302,
        "weight": 1465,
        "dist": 224,
        "products": 8
      }
    },
    {
      "StopLocation": {
        "id": "A=1@O=Wivalliusgatan@X=18013205@Y=59326558@u=0@U=74@L=400110450@",
        "extId": "400110450",
        "hasMainMast": true,
        "mainMastId": "A=1@O=Wivalliusgatan (Stockholm)@X=18013196@Y=59326540@U=74@L=300101272@",
        "mainMastExtId": "300101272",
        "name": "Wivalliusgatan",
        "lon": 18.013205,
        "lat": 59.326558,
        "weight": 1465,
        "dist": 254,
        "products": 8
      }
    }
  ],
  "serverVersion": "1.4",
  "dialectVersion": "1.23",
  "requestId": "1701701254662"
}
<?xml version="1.0" encoding="UTF-8"?>
<LocationList serverVersion="1.4" dialectVersion="1.23" requestId="1701701276854" xmlns="hafas_rest">
    <StopLocation id="A=1@O=Marieberg@X=18016154@Y=59328284@u=0@U=74@L=400110905@" extId="400110905" name="Marieberg" hasMainMast="true"
                  mainMastId="A=1@O=Marieberg (Stockholm)@X=18015533@Y=59328410@U=74@L=300101273@" mainMastExtId="300101273" lon="18.016154" lat="59.328284"
                  weight="388" products="8" dist="0"/>
    <StopLocation id="A=1@O=Wennerbergsgatan@X=18014140@Y=59328347@u=0@U=74@L=400110903@" extId="400110903" name="Wennerbergsgatan" hasMainMast="true"
                  mainMastId="A=1@O=Wennerbergsgatan (Stockholm)@X=18013061@Y=59328518@U=74@L=300101263@" mainMastExtId="300101263" lon="18.01414"
                  lat="59.328347" weight="388" products="8" dist="114"/>
    <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"
                  mainMastId="A=1@O=Fria Ukrainas plats (Stockholm)@X=18017592@Y=59327124@U=74@L=300101271@" mainMastExtId="300101271" lon="18.017871"
                  lat="59.327286" weight="1465" products="8" dist="147"/>
    <StopLocation id="A=1@O=Västerbroplan@X=18020109@Y=59328302@u=0@U=74@L=400110727@" extId="400110727" name="Västerbroplan" hasMainMast="true"
                  mainMastId="A=1@O=Västerbroplan (Stockholm)@X=18021125@Y=59328176@U=74@L=300101270@" mainMastExtId="300101270" lon="18.020109" lat="59.328302"
                  weight="1465" products="8" dist="224"/>
    <StopLocation id="A=1@O=Wivalliusgatan@X=18013205@Y=59326558@u=0@U=74@L=400110450@" extId="400110450" name="Wivalliusgatan" hasMainMast="true"
                  mainMastId="A=1@O=Wivalliusgatan (Stockholm)@X=18013196@Y=59326540@U=74@L=300101272@" mainMastExtId="300101272" lon="18.013205"
                  lat="59.326558" weight="1465" products="8" dist="254"/>
</LocationList>

XSD

https://api.sl.se/api2/nearbystops/xsd.xml?key=<DIN API NYCKEL>&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.