What does this API provide?

ResRobot stop lookup provides information about stops, including their ids and position, by searching based on their name.

Data format

The data is formatted as JSON or XML, depending on the format query parameter.

Updates

The static data used for this API is updated when changes are made, at most once per day.

Operators covered by this dataset

All operators which operate in Sweden are covered by the ResRobot APIs.

Breaking changes

This API has the stable status. When breaking changes are made, we strive to have a 6 months transition period for users to update their implementations. Examples of breaking changes are the changes to existing fields or query parameters, or in case new query parameters are required to keep the results the same. The addition of new fields isn’t considered a breaking change, and can happen without warning.

Using ResRobot Stop lookup

ResRobot Stop lookup takes the search string and the wanted number of results as parameters, and returns a list of matching stations with their location, name and id. Users can choose between exact matching and approximate matching by adding a question mark to the end of the search string.

Only the most important parameters and response variables are described on this page. Looking for more technical details? These can be found in the OpenAPI specification.
Instead of using the station lookup endpoint, you can also use the stops.txt file from GTFS Sverige 2. This way you can provide autocomplete and other search functions without internet access. It will make your application more responsive and more reliable as you don’t have to wait for API responses. See Combining data and APIs for more information.

Example calls

Exact search returns only stations that match exactly with the search string.

Call

1https://api.resrobot.se/v2.1/location.name?input=Göteborg&format=json&accessId=API_KEY
1https://api.resrobot.se/v2.1/location.name?input=Göteborg&format=xml&accessId=API_KEY

Request parameters

Changes compared to ResRobot v2.0:

  • The key parameter has been renamed to accessId.
NameTypeRequiredDescription
accessIdStringYesYour API key
inputStringYesThe search string. Append a question mark for fuzzy search.
maxNoIntegerNoThe maximum number of results to return, default 10, maximum 1000
langStringNoLanguage (sv/en/de), default sv. Affects both data (names for different transport types) and error messages.
formatStringNoJson or Xml

Response

 1{
 2  "StopLocation": [
 3    {
 4      "id": "740098001",
 5      "extId": "740098001",
 6      "name": "GÖTEBORG",
 7      "lon": 11.973479,
 8      "lat": 57.708895,
 9      "weight": 22332,
10      "products": 254
11    }
12  ]
13}
1<?xml version="1.0" encoding="UTF-8"?>
2<LocationList xmlns="hafas_rest_v1">
3    <StopLocation id="740098001" extId="740098001" name="GÖTEBORG" lon="11.973479" lat="57.708895" weight="22332" products="254"/>
4</LocationList>
All-caps stations, like GÖTEBORG in the example above, are virtual stations. These are a group of stations, for example to group stops which are close to each other or to group several stops serving the same area. This is especially useful for people who are not familiar with the environment. Instead of having to choose between several stops which they don’t know, they can simply search for trips to “Göteborg”.

By adding a question mark to the query string, fuzzy matching is used instead of exact matching. This will return stations which name is an exact or near match to the input string.

Call

1https://api.resrobot.se/v2.1/location.name?input=Göteborg?&format=json&accessId=API_KEY
1https://api.resrobot.se/v2.1/location.name?input=Göteborg?&format=xml&accessId=API_KEY

Response

 1{
 2  "StopLocation": [
 3    {
 4      "id": "740098001",
 5      "extId": "740098001",
 6      "name": "GÖTEBORG",
 7      "lon": 11.973479,
 8      "lat": 57.708895,
 9      "weight": 22332,
10      "products": 254
11    },
12    {
13      "id": "740000002",
14      "extId": "740000002",
15      "name": "Göteborg Centralstation",
16      "lon": 11.973479,
17      "lat": 57.708895,
18      "weight": 17428,
19      "products": 182
20    },
21    {
22      "id": "740098526",
23      "extId": "740098526",
24      "name": "GÖTEBORG GAMLESTADEN",
25      "lon": 12.004411,
26      "lat": 57.729148,
27      "weight": 16810,
28      "products": 112
29    },
30    {
31      "id": "740016365",
32      "extId": "740016365",
33      "name": "Göteborg Sävenäs lokstation",
34      "lon": 12.021077,
35      "lat": 57.725993,
36      "weight": 13,
37      "products": 128
38    },
39    {
40      "id": "740025610",
41      "extId": "740025610",
42      "name": "Göteborg Berzeliigatan",
43      "lon": 11.981884,
44      "lat": 57.698504,
45      "weight": 4917,
46      "products": 200
47    },
48    {
49      "id": "740015578",
50      "extId": "740015578",
51      "name": "Göteborg Korsvägen",
52      "lon": 11.986909,
53      "lat": 57.696625,
54      "weight": 4917,
55      "products": 200
56    },
57    {
58      "id": "740016358",
59      "extId": "740016358",
60      "name": "Göteborg Kungsportsplatsen",
61      "lon": 11.969748,
62      "lat": 57.704023,
63      "weight": 4917,
64      "products": 200
65    },
66    {
67      "id": "740072430",
68      "extId": "740072430",
69      "name": "Göteborg Stenpiren",
70      "lon": 11.957424,
71      "lat": 57.705803,
72      "weight": 4669,
73      "products": 448
74    },
75    {
76      "id": "740025609",
77      "extId": "740025609",
78      "name": "Göteborg Bellevue",
79      "lon": 12.023477,
80      "lat": 57.732456,
81      "weight": 4488,
82      "products": 192
83    },
84    {
85      "id": "740020752",
86      "extId": "740020752",
87      "name": "Göteborg Brunnsparken",
88      "lon": 11.967843,
89      "lat": 57.706945,
90      "weight": 4488,
91      "products": 192
92    }
93  ]
94}
 1<?xml version="1.0" encoding="UTF-8"?>
 2<LocationList xmlns="hafas_rest_v1">
 3    <StopLocation id="740098001" extId="740098001" name="GÖTEBORG" lon="11.973479" lat="57.708895" weight="22332" products="254"/>
 4    <StopLocation id="740000002" extId="740000002" name="Göteborg Centralstation" lon="11.973479" lat="57.708895" weight="17428" products="182"/>
 5    <StopLocation id="740098526" extId="740098526" name="GÖTEBORG GAMLESTADEN" lon="12.004411" lat="57.729148" weight="16810" products="112"/>
 6    <StopLocation id="740016365" extId="740016365" name="Göteborg Sävenäs lokstation" lon="12.021077" lat="57.725993" weight="13" products="128"/>
 7    <StopLocation id="740025610" extId="740025610" name="Göteborg Berzeliigatan" lon="11.981884" lat="57.698504" weight="4917" products="200"/>
 8    <StopLocation id="740015578" extId="740015578" name="Göteborg Korsvägen" lon="11.986909" lat="57.696625" weight="4917" products="200"/>
 9    <StopLocation id="740016358" extId="740016358" name="Göteborg Kungsportsplatsen" lon="11.969748" lat="57.704023" weight="4917" products="200"/>
10    <StopLocation id="740072430" extId="740072430" name="Göteborg Stenpiren" lon="11.957424" lat="57.705803" weight="4669" products="448"/>
11    <StopLocation id="740025609" extId="740025609" name="Göteborg Bellevue" lon="12.023477" lat="57.732456" weight="4488" products="192"/>
12    <StopLocation id="740020752" extId="740020752" name="Göteborg Brunnsparken" lon="11.967843" lat="57.706945" weight="4488" products="192"/>
13</LocationList>

Response Data fields

Changes compared to ResRobot v2.0:

  • The root object now contains an array of stopLocationOrCoordLocation instead of an array of stopLocation.
  • stopLocation can now be found in the items present in the stopLocationOrCoordLocation array.
  • The products field has been replaced with an array of Products. Instead of accessing the sum of all products through products, you can now obtain all the individual products through ProductAtStop[].cls
  • timezoneOffset has been added to each StopLocation.
NameData typeDescription
stopLocationOrCoordLocationstopLocationOrCoordLocation[]List with results
stopLocationOrCoordLocation.StopLocationStopLocationActual data is contained in the StopLocation property
StopLocationObjectObject containing a single stop
StopLocation.nameStringStop name
StopLocation.extIdStringStop id for use in other ResRobot APIs.
StopLocation.idStringInternal id. Do not use.
StopLocation.distIntegerDistance from the queried coordinates, in meters.
StopLocation.latStringLatitude (WGS84, decimal degree) for this stop, eg 59.293611
StopLocation.lonStringLongitude (WGS84, decimal degree) for this stop, eg 18.083056
StopLocation.productAtStopProduct[]See common data types. Only the cls field of each product will contain actual data.
StopLocation.weightIntegerShows how much traffic is handled at this stop, a stop with more traffic gets a higher weight. Between 0 and 32767.