SL Stops and lines 2

Listing of Stops and Lines in Stockholm County

To describe traffic information consistently, clear and distinct concepts and definitions are necessary. The key terms for this service are presented below.

This API will be shut down at the end of March 2024. It is replaced by SL’s new transport API.
TermDescription
SiteA Site is a grouping of StopAreas used to simplify searches in the journey planner.
StopAreaStopArea is a grouping of StopPoints with the same mode of transport and name within a defined geographical area, such as a terminal.
StopPointA StopPoint is a stopping point and is part of a StopArea.
LineLine advertised to the traveler
JourneyPatternA unique route for a line
JourneyPatternPointOnLineContains all stopping points served by a particular line
TransportmodeMode of transport

API

Access

URLs for calls are specified below:

https://api.sl.se/api2/LineData.json?model=[model]&key=[key]

https://api.sl.se/api2/LineData.json?model=[model]&key=[key]
https://api.sl.se/api2/LineData.xml?model=[model]&key=[key]

Note that it is the extension in the call that determines the formatting of the response.

API Keys, Authorization

API keys can be obtained via the Trafiklab developer portal. An API key should be used in the URL for an API call.

Key Levels

LevelMax calls/minuteMax calls/month
Bronze5500

Format

The API supports XML and JSON data formatting. The desired formatting is specified in the URL for an API call.

Data Types

All data types are always represented in string form for respective formats. The type indicated in model descriptions only suggests a suitable data type to convert the value to in a given programming language.

TypeExampleDescription
Int123All data types are always represented in string form. However, it can be converted to the Int data type if supported by the programming language.

Data Filtering

For the line and journey models, it is desirable to distinguish which traffic type the data refers to. This can be achieved by including the optional parameter DefaultTransportModeCode, which can contain any of the Transportmode values returned when calling the transportmode model, such as “BUS” or “METRO”. For example:

https://api.sl.se/api2/linedata.xml?key=[key]&model=line&DefaultTransportModeCode=METRO https://api.sl.se/api2/linedata.xml?key=[key]&model=jour&DefaultTransportModeCode=BUS

Character Encoding

UTF-8 is used for both XML and Json.

Performance

Since calls return a relatively large amount of data, it is strongly recommended that the call includes the following HEADER parameter to enable GZIP compression in the response.

KeyValue
Accept-Encodinggzip, deflate

Update Frequency

The API portal updates data once a day between 0:00-2:00 every day.

API Model

Calls to https://api.sl.se/api2/LineData always return an API model (base model), regardless of the specific data model requested in the call.

KeyTypeExampleDescription
StatusCodeInt00 if the call has succeeded, otherwise an error code that cannot be corrected, for example, by a modified call
ExecutionTimeInt267Number of milliseconds it took to generate a response on the server
ResponseDataObjectContainer object containing attributes and data
VersionString2014-06-27 14:03:39.103Last modified. Normally updated only once a day
TypeStringDataModelTypeSpecifies the type of data model the response contains: Site, StopPoint, Line, JourneyPatternPointOfLine, TransportMode
ResponseDataObjectContainer object containing typed data

{
  "StatusCode": 0,
  "ExecutionTime": 282,
  "ResponseData": {
    "Version": "2014-10-09 01:05",
    "Type": "DataModelType",
    "Result": [
      DataModel,
      ...,
      DataModel
    ]
  }
}

<ResponseOfPwsResult>"https://www.w3.org/2001/XMLSchema"</strong> xmlns:xsi=<strong>"https://www.w3.org/2001/XMLSchema-instance"</strong>> <StatusCode>
<strong>0</strong>
</StatusCode> <ExecutionTime>
<strong>267</strong>
</ExecutionTime> <ResponseData>
<Version xmlns=
<strong>"https://api.sl.se/api/pws"</strong>>
<strong>2014-10-09 01:05</strong>
</Version> <Type xmlns=<strong>"https://api.sl.se/api/pws"</strong>><strong>DataModelType
</strong></Type> <strong><!--DataModel></DataModel></strong> <strong>...</strong> <strong> <DataModel></DataModel--></strong> </ResponseData> </ResponseOfPwsResult>

API Model for JSON

Specification for data models

The API provides the following data models:

KeyValueDescription
modelsiteReturns response with a Site object
modelstopReturns response with a StopPoint object
modellineReturns response with a Line object
modeljourReturns response with a JourneyPatternPointOnLine object
modeltranReturns response with a TransportMode object

The desired data model is specified in the URL for an API call.

api.sl.se/api2/LineData.xml?model=[model]&key=[key]

Examples

https://api.sl.se/api2/LineData.xml?model=site

Site

Description

Site is a grouping of StopAreas used to simplify searching in the journey planner.

Properties

PropertyCan be converted toExampleDescription
SiteIdInt1002Unique identification number for a Site
SiteNameStringCentralenName of the area
StopAreaNumberInt1051Unique identification number for a stop area
LastModifiedUtcDateTimeDateTime2014-06-27 14:03:39.103Last modified
ExistsFromDateDateTime2014-06-28 00:00:00.000Effective from date

Object Structure

{
  "SiteId": "1002",
  "SiteName": "Centralen",
  "StopAreaNumber": "1051",
  "LastModifiedUtcDateTime": "2014-06-27 14:03:39.103",
  "ExistsFromDate": "2014-06-28 00:00:00.000"
}

<Site xmlns="https://api.sl.se/api/pws">
    <SiteId>1002</SiteId>
    <SiteName>Centralen</SiteName>
    <StopAreaNumber>1051</StopAreaNumber>
    <LastModifiedUtcDateTime>2014-06-27 14:03:39.103</LastModifiedUtcDateTime>
    <ExistsFromDate>2014-06-28 00:00:00.000</ExistsFromDate>
</Site>

StopPoint

Description

StopPoints are part of a StopArea.

Properties

PropertyCan be converted toExampleDescription
StopPointNumberInt1051Unique identification number for a stop point
StopPointNameStringT-CentralenName of the stop point
StopAreaNumberInt1051Number for StopArea
LocationNorthingCoordinateDouble59.3313179695028Coordinate in WGS84 format
LocationEastingCoordinateDouble18.0616773959365Coordinate in WGS84 format
ZoneShortNameStringATaxi zone. A, B, or C
StopAreaTypeCodeStringMETROSTNUsage of the stop. BUSSTERM, TRAMSTN, METROSTN, RAILWSTN, SHIPBER, or FERRYBER
LastModifiedUtcDateTimeDateTime2014-06-03 00:00:00.000Last modified
ExistsFromDateDateTime2014-06-03 00:00:00.000Effective from date

Object Structure

{
  "StopPointNumber": "1051",
  "StopPointName": "T-Centralen",
  "StopAreaNumber": "1051",
  "LocationNorthingCoordinate": "59.3313179695028",
  "LocationEastingCoordinate": "18.0616773959365",
  "ZoneShortName": "A",
  "StopAreaTypeCode": "METROSTN",
  "LastModifiedUtcDateTime": "2014-06-03 00:00:00.000",
  "ExistsFromDate": "2014-06-03 00:00:00.000"
}

<StopPoint xmlns="https://api.sl.se/api/pws">
    <StopPointNumber>1051</StopPointNumber>
    <StopPointName>T-Centralen</StopPointName>
    <StopAreaNumber>1051</StopAreaNumber>
    <LocationNorthingCoordinate>59.3313179695028</LocationNorthingCoordinate>
    <LocationEastingCoordinate>18.0616773959365</LocationEastingCoordinate>
    <ZoneShortName>A</ZoneShortName>
    <StopAreaTypeCode>METROSTN</StopAreaTypeCode>
    <LastModifiedUtcDateTime>2014-06-03 00:00:00.000</LastModifiedUtcDateTime>
    <ExistsFromDate>2014-06-03 00:00:00.000</ExistsFromDate>
</StopPoint>

Line

Description

Returns a description of a line. Contains references to transport modes.

Properties

PropertyCan be converted toExampleDescription
LineNumberInt3Unique identification number for a line
LineDesignationString3Line designation
DefaultTransportModeStringblåbussGrouping of lines for presentation
DefaultTransportModeCodeStringBUSTransport mode
LastModifiedUtcDateTimeDateTime2007-08-24 00:00:00.000Last modified
ExistsFromDateDateTime2007-08-24 00:00:00.000Effective from date

Object Structure

{
  "LineNumber": "3",
  "LineDesignation": "3",
  "DefaultTransportMode": "blåbuss",
  "DefaultTransportModeCode": "BUS",
  "LastModifiedUtcDateTime": "2007-08-24 00:00:00.000",
  "ExistsFromDate": "2007-08-24 00:00:00.000"
}

<Line xmlns="https://api.sl.se/api/pws">
    <LineNumber>3</LineNumber>
    <LineDesignation>3</LineDesignation>
    <DefaultTransportMode>blåbuss</DefaultTransportMode>
    <DefaultTransportModeCode>BUS</DefaultTransportModeCode>
    <LastModifiedUtcDateTime>2007-08-24 00:00:00.000</LastModifiedUtcDateTime>
    <ExistsFromDate>2007-08-24 00:00:00.000</ExistsFromDate>
</Line>

JourneyPatternPointOnLine

Description

Returns the connection between a stop point and a line. Contains all stop points served by a particular line.

Properties

PropertyCan be converted toExampleDescription
LineNumberInt1Unique identification number for a line
DirectionCodeInt1Line direction
JourneyPatternPointNumberInt10008Unique identification number for a stop point
LastModifiedUtcDateTimeDateTime2012-06-23 00:00:00.000Last modified
ExistsFromDateDateTime2012-06-23 00:00:00.000Effective from date

XML Object Structure

{
  "LineNumber": "1",
  "DirectionCode": "1",
  "JourneyPatternPointNumber": "10008",
  "LastModifiedUtcDateTime": "2012-06-23 00:00:00.000",
  "ExistsFromDate": "2012-06-23 00:00:00.000"
}

<JourneyPatternPointOnLine xmlns="https://api.sl.se/api/pws">
    <LineNumber>1</LineNumber>
    <DirectionCode>1</DirectionCode>
    <JourneyPatternPointNumber>10008</JourneyPatternPointNumber>
    <LastModifiedUtcDateTime>2012-06-23 00:00:00.000</LastModifiedUtcDateTime>
    <ExistsFromDate>2012-06-23 00:00:00. "000"</ExistsFromDate>
</JourneyPatternPointOnLine>

Complete example

{
  "StatusCode": 0,
  "ExecutionTime": 327,
  "ResponseData": {
    "Version": "2014-10-09 18:05",
    "Type": "TransportMode",
    "Result": [
      {
        "DefaultTransportModeCode": "BUS",
        "DefaultTransportMode": "buss",
        "StopAreaTypeCode": "BUSTERM",
        "LastModifiedUtcDateTime": "2007-08-24 00:00:00.000",
        "ExistsFromDate": "2007-08-24 00:00:00.000"
      }
      // Additional result objects for different modes
    ]
  }
}

<ResponseOfPwsResult xmlns="https://www.w3.org/2001/XMLSchema">
    <StatusCode>0</StatusCode>
    <ExecutionTime>277</ExecutionTime>
    <ResponseData>
        <Version xmlns="https://api.sl.se/api/pws">2014-10-09 18:05</Version>
        <Type xmlns="https://api.sl.se/api/pws">TransportMode</Type>

        <TransportMode xmlns="https://api.sl.se/api/pws">
            <DefaultTransportModeCode>BUS</DefaultTransportModeCode>
            <DefaultTransportMode>buss</DefaultTransportMode>
            <StopAreaTypeCode>BUSTERM</StopAreaTypeCode>
            <LastModifiedUtcDateTime>2007-08-24 00:00:00.000</LastModifiedUtcDateTime>
            <ExistsFromDate>2007-08-24 00:00:00.000</ExistsFromDate>
        </TransportMode>

        <!-- Additional TransportMode elements for different modes -->

    </ResponseData>
</ResponseOfPwsResult>

Support

If you need more help you can search through existing questions on our support forum. If you don’t find the answer to your question their, you can create your own post and we’ll try to help you as soon as possible.