HTTP Get interface
1 Instructions
1.1 General
Reittiopas API is located in the following address.
http://api.reittiopas.fi/hsl/prod/
The API server has the most recent timetable data provided by HRT. Due to security and load reasons the API server has been separated from other parts of the Reittiopas system. However, the API is automatically updated with new data simultaneously with the other parts. The timetable data is updated weekly. This does not affect the functioning of the service.
- The use of the interface requires a username and a password.
- UTF-8 encoding is used with all requests.
- Request type is given in URL parameter request=<request type>.
- Response format can be changed.
- URL parameter format=[json|xml], default response format is JSON.
- format=txt prints the response in a more human readable format, can be used for testing the responses.
- Coordinate system used in request and response can be changed.
- URL parameters epsg_in=<epsg code> and epsg_out=<epsg code>.
- Possible values are 2392 (KKJ2, default), 2391 (KKJ1), 2393 (KKJ3), 4326 (WGS84) and 3395 (Mercator).
- It is also possible to use the names of the coordinate systems (kk1, kkj2, kkj3, wgs84 and mercator) as value of epsg_in and epsg_out.
- Language used in the response can be changed.
- URL parameter lang=[fi|sv|en|slangi], default value is fi.
- N.B. mostly only points of interest have their names in all languages, stops and addresses have their names only in Finnish and Swedish.
- Lists as parameter values are separated with pipes ("|"), e.g. transport_types=bus|metro|train.
- If there are major changes it is possible to use an older version of the API.
- Versions are labeled with version numbers, such as 1_1_0.
- E.g. api.reittiopas.fi/hsl/1_1_0/?request=...
- Users are always notified about changes in the API.
- New features will be available for testing for a limited time.
- E.g. api.reittiopas.fi/hsl/beta/?request=...
- Production version will be available at api.reittiopas.fi/hsl/prod/?request=...
- In most queries it is possible to limit the values in the response with URL parameter p.
- E.g. p=110011 (as default the all fields in the response are returned).
- The order of the response fields is described for every query.
- New fields will be added to the end of the response.
- Incomplete limit parameters are filled with zeros.
- E.g. p=101 is interpreted as 101000 if there are six fields in the response.
- Queries where limit can be used:
- Geocode
- Reverse geocode
- Stop
- Stops by area
- Lines
Current versions of the API (changelog):
- 1_0_0
- 1_1_1
- 1_1_2
- 1_1_3 (prod)
1.2 Capacity restriction
The new version of the API has a new feature that makes it possible to restrict abuse of the system. Too many requests in a short time could flood the service and make it unavailable for other users. Capacity restriction limits the amount of requests per hour. Requests are weighted according to the cost that they have on the system. The weights for different requests are as follows:
- Geocoding = 1
- Reverse geocoding = 1
- Stop = 1
- Validity = 1
- Stats = 1
- Lines = 2
- Stops by area = 2
- Routing = 3
- Cycling route = 3
It is possible to check the remaining capacity with a request (api.reittiopas.fi/hsl/?request=stats).
1.3 Reittiopas API modules
Every request to Reittiopas API uses HTTP GET. Every request will need request parameter that contains the type of the request.
Modules of the Reittiopas API:
- Geocoding (request type geocode)
- Reverse geocoding (request type reverse_geocode)
- Stop information (request type stop)
- Stops in area (request type stops_area)
- Line information (request type lines)
- Routing between two points (request type route)
- Cycling route (request type cycling)
- Data validity (request type validity)
- User statistics (capacity used and available) (request type stats)
The parameters used for the requests and responses are explained in detail in the following chapters.
1.4 Geocoding
Geocoding returns the coordinates and the names of the POIs, stops and addresses. The search uses the same logic as the Reittiopas www-service. Locations have been classified to different categories.
The search term is provided through a variable that is added to the URL with the user credentials.
| Parameter |
Description
|
Type |
key
|
Search term |
String |
| cities |
List of city names |
Optional. List of strings separated by pipe ("|"). E.g. cities=espoo|helsinki. Default all cities. |
| loc_types |
Location types |
Optional. List of location types separated by pipe ("|"). E.g. loc_types=stop|address. Default all location types. |
| disable_error_correction |
Disable levenshtein error correction |
Optional. 1 = error correction is not in use, 0 = error correction is in use. Default 0. |
| disable_unique_stop_names |
Disable unique stop names in the result. |
Optional. 1 = all stops are shown in the result, 0 = only one stop is included in the result for stops with same name. Default 1.
|
Response fields:
| Field nr. |
Name |
Type |
Description |
| 1 |
locType |
String |
Type of the location: street, address, poi (point of interest) or stop
|
| 2 |
locTypeId |
Number
|
Location type id of the location (1-9 and 1008 = poi, 10 = stop, 900 = address) |
| 3 |
name |
String |
Name of the location. |
| 4 |
matchedName |
String |
Name of the location in that was matched with the search key. |
| 5 |
lang |
String |
Language of the matched name of the location. |
| 5 |
city |
String |
Name of the city the location is in. |
| 6 |
coords |
Coordinate |
Coordinates of the location (<x,y>, e.g. 2551217,6681725). |
| 7 |
details |
Array |
Detailed information about the location such as houseNumber for addresses, poiClass for POIs and codes for stops. |
Below are some search examples:
- A search that returns locations from all categories:
- api.reittiopas.fi/hsl/prod/?request=geocode&key=tee
- A search that returns a single stop (as there should be only one result found with the search term):
- api.reittiopas.fi/hsl/prod/?request=geocode&key=teekkarik
- If the search term includes a digit, the search is done mainly for streets:
- api.reittiopas.fi/hsl/prod/?request=geocode&key=tee+3
1.5 Reverse geocoding
Reverse geocoding searches for a street address, poi or stop closest to a given coordinate. The amount of locations can be limited as well as the radius of the search. Location types can be used to leave out unwanted locations from the result.
| Parameter |
Description |
Type |
coordinate
|
Coordinate |
Coordinates separated by comma (e.g. <x,y>) |
| limit |
Limit for the number of locations returned.
|
Optional, default 1
|
| radius |
Radius of the search in meters. |
Optional, default 1000, range 1-1000 |
| result_contains |
Limit the search to given location types. |
Optional, default address, other values: stop and poi.
|
Response fields:
| Field nr. |
Name |
Type |
Description |
| 1 |
locType |
String |
Type of the location: street, address, poi (point of interest) or stop
|
| 2 |
locTypeId |
Number
|
Location type id of the location (1-9 and 1008 = poi, 10 = stop, 900 = address) |
| 3 |
name |
String |
Name of the location. |
| 4 |
lang |
String |
Language of the name of the location. |
| 5 |
city |
String |
Name of the city the location is in. |
| 6 |
coords |
Coordinate |
Coordinates of the location (<x,y>, e.g. 2551217,6681725). |
| 7 |
details |
Array |
Detailed information about the location such as houseNumber for addresses, poiClass for POIs and codes for stops. |
Below are some search examples:
- A search for the nearest address for the coordinates given:
- api.reittiopas.fi/hsl/prod/?request=reverse_geocode&coordinate=2546445,6675512
1.6 Stop information
Stop request returns information about a given stop identified by its unique code. Information includes names, lines passing the stop, codes, coordinates, accessibility information and departures for a given time range.
| Parameter |
Description |
Type |
code
|
Search term for a stop search. |
Stop's long JORE code, short code, stop name or stop address. |
| date |
Start date for departure.
|
Optional, default current date, YYYYMMDD.
|
| time |
Start time for departures. |
Optional, default current time, HHMM.
|
| time_limit |
Time range for returned departures. |
Optional, default 120, max 360 minutes.
|
| dep_limit |
Limit the number of returned departures. |
Optional, default 10, range 1-20. |
Response fields:
| Field nr. |
Name |
Type |
Description |
| 1 |
code |
Number(7) |
Unique, long code of the stop, e.g. 1040602.
|
| 2 |
code_short |
String(4-6) |
Short code, e.g. 0013 or ki0468.
|
| 3 |
name_fi |
String |
Name of the stop in Finnish. |
| 4 |
name_sv |
String |
Name of the stop in Swedish. |
| 5 |
city_fi |
String |
Name of the city in Finnish. |
| 6 |
city_sv |
String |
Name of the city in Swedish. |
|
7
|
lines |
Array |
Array of lines that pass the stop with their destination, line code and it's destination are separated by ":", e.g. 2103 1:Pohjois-Tapiola |
| 8 |
coords |
Coordinate |
Coordinates of the stop (<x,y>, e.g. 2551217,6681725). The location specified in this field is slightly modified for mapping reasons. |
| 9 |
wgs_coords |
Coordinate |
Longitude and latitude of the stop (WGS84 coordinates, <lon,lat>). The location specified in this field is the measured point of the stop sign. |
| 10 |
accessibility |
Array |
Accessibility information of the stop, described in more detail below. |
| 11 |
departures |
Array |
Next departures leaving from the stop, array of line code, departure time and date. |
| 12 |
timetable_link |
String |
Link to the timetable page of the stop. |
| 13 |
omatlahdot_link |
String |
Link to the Omat lähdöt service. |
| 14 |
address_fi |
String |
Stop's address in Finnish. |
| 15 |
address_sv |
String |
Stop's address in Swedish. |
Accessibility fields:
| Field |
Description |
| width_tilt |
Tilt of the stop area towards the road. |
| length_tilt |
Tilt of the stop lengthwise.
|
| min_width |
Minimum width of the stop area from stop shelter wall to the road. |
| max_width |
Maximum width of the stop area from stop shelter wall to the road. |
| depth |
Depth of the stop area. |
| curb_height_road |
Curb height to the road. |
| curb_height_sidewalk |
Curb height to the sidewalk. |
| rear_railing_height |
Height of a rear railing. |
| protecting_height |
Height of the protecting part of the railing. |
| lower_moulding |
Height of the lower moulding of the railing. |
| bench_height |
Height of the bench in the shelter. |
| trash_can |
Trash can. |
| danger |
|
| shelter |
Shelter. |
| light |
Light. |
| warning_area |
|
| difference_warning_area |
|
| difference_waiting_area |
|
| unobstructed_access |
|
| cycle_track_included |
|
| cycle_track_position |
|
| stop_model |
|
| accessibility |
|
| class |
Accessibility class: 1, 2, 3, 4 or 5. |
| notes |
|
Below are some search examples:
- A search for a stop with a code:
- api.reittiopas.fi/hsl/prod/?request=stop&code=2222222
1.7 Stops in area
Reittiopas API can be used to search for stops within a square with a given diameter. Given point is the center of the square. Square’s side is the same as the length of the given diameter in meters.
| Parameter |
Description |
Type |
center_coordinate
|
Coordinate |
Coordinates separated by comma (e.g. <x,y>) |
| limit |
Limit the amount of stops.
|
Optional, no default value.
|
| diameter |
Length of the side of the square. |
Optional, default 1500, max 5000 meters.
|
Response fields:
| Field nr. |
Name |
Type |
Description |
| 1 |
code |
Number(7) |
Unique, long code of the stop, e.g. 1040602.
|
| 2 |
name |
String |
Name of the stop. |
| 3 |
city |
String |
City the stop is located in. |
|
4
|
coords |
Coordinate |
Coordinates of the stop (<x,y>, e.g. 2551217,6681725). |
| 5 |
dist |
Number |
Distance of the stop to the center coordinate. |
| 6 |
codeShort |
String(4-6) |
Stop's short code. |
| 7 |
address |
String |
Stop's address. |
Sample request:
api.reittiopas.fi/hsl/prod/?request=stops_area¢er_coordinate=2558009,6685216&radius=100
1.8 Line information
Detailed information on lines can be fetched with request type lines. The lines can be searched with JORE codes, short codes, parts line names or transport types. Parameter query must be set in all queries.
| Parameter |
Description |
Type |
query
|
List of strings |
List of query strings separated by pipe ("|"). Strings may be long JORE code, short code (like one shown on the bus) or string that will be searched from the name of the line (minimum length of the search string is 4). E.g. query=2102T 1|14|Tapiola
|
| transport_type |
List of numbers
|
Optional. List of transport type ids. Only lines that are of these types will be included in the result. E.g. transport_type=1|2. Possible values can be any of the following:
- 1 = Helsinki internal bus lines
- 2 = trams
- 3 = Espoo internal bus lines
- 4 = Vantaa internal bus lines
- 5 = regional bus lines
- 6 = metro
- 7 = ferry
- 8 = U-lines
- 12 = commuter trains
- 21 = Helsinki service lines
- 22 = Helsinki night buses
- 23 = Espoo service lines
- 24 = Vantaa service lines
- 25 = region night buses
- 36 = Kirkkonummi internal bus lines
- 39 = Kerava internal bus lines
|
Response fields:
| Field nr. |
Name |
Type |
Description |
| 1 |
code |
String(7) |
Unique, long code of the line, e.g. 2102T 1.
|
| 2 |
code_short |
String |
Short code of the line (shown on the bus, e.g. 102T.
|
| 3 |
transport_type_id |
Number
|
Transport type of the line. See above (parameter transport_type) for explanation of the codes. |
| 4 |
line_start |
String |
Name of the start stop. |
| 5 |
line_end |
String |
Name of the end stop. |
| 6 |
name |
String |
Name of the line. |
|
7
|
timetable_url |
String |
URL of the timetable page for the line. |
| 8 |
line_shape |
List of coordinates |
The shape of the line's route as a list of coordinates. |
| 9 |
line_stops |
Array
|
Array of stops the line passes.
|
| 9.1 |
code |
Number(7) |
Long code of the stop.
|
| 9.2 |
codeShort |
String(4-6) |
Stop's short code.
|
| 9.3 |
time |
Number |
Estimated time in minutes it takes for the bus to reach the stop.
|
| 9.4 |
address |
String |
Stop's address.
|
| 9.5 |
name |
String |
Stop's name.
|
| 9.6 |
coords |
Coordinate pair (x,y) |
Coordinates of the stop.
|
| 9.7 |
city_name |
String |
City that the stop is located in.
|
Sample request:
api.reittiopas.fi/hsl/prod/?request=lines&query=2102T 1|14|Tapiola&transport_type=1|3
1.9 Routing
Routing returns the route between two coordinate points. In routing it is recommended to use street addresses (their coordinates) as it is difficult for the end user to know where exactly a stop is located. There might be several stops with the same name that are located far away from each other (for example the stop “Sturenkatu” in Helsinki).
| Parameter |
Description |
Type |
from
|
Coordinate |
Coordinates separated by comma (e.g. <x,y>). |
| via |
Coordinate |
Optional, coordinates separated by comma (e.g. <x,y>). |
| to |
Coordinate |
Coordinates separated by comma (e.g. <x,y>). |
| date |
Number(8). |
Optional, default current date, YYYYMMDD.
|
| time |
Number(4) |
Optional, default current time, HHMM. |
| timetype |
String |
Time of the request is for "arrival" or "departure". Optional, default "departure".
|
| via_time |
Number
|
Minimum time spent at a via_point in minutes. |
| zone |
String |
Ticket zone:
- "helsinki" = Helsinki internal ticket
- "espoo" = Espoo internal ticket
- "vantaa" = Vantaa internal ticket
- "whole" = Helsinki, Espoo, Kauniainen, Vantaa, Kirkkonummi and Kerava. Whole region, excluding non HSL areas
- "region" = Helsinki, Espoo, Kauniainen and Vantaa region
Optional, default no restriction. |
| transport_types |
List of strings separated by pipe ("|") |
Transport types included in the request:
- "all" = all transport types are included (default)
- "bus"
- "train"
- "metro"
- "tram"
- "service"
- "uline"
- "ferry"
- "walk" = only walking
Optional, default "all", e.g. transport_types=bus|uline|service. |
| mode_cost_<transport_type_id> |
Number |
Mode costs for different transport types. Transport_type_id in the parameter name may be any of the following:
- 1 = Helsinki internal bus lines
- 2 = trams
- 3 = Espoo internal bus lines
- 4 = Vantaa internal bus lines
- 5 = regional bus lines
- 6 = metro
- 7 = ferry
- 8 = U-lines
- 12 = commuter trains
- 21 = Helsinki service lines
- 22 = Helsinki night buses
- 23 = Espoo service lines
- 24 = Vantaa service lines
- 25 = region night buses
- 36 = Kirkkonummi internal bus lines
- 39 = Kerava internal bus lines
Optional. These settings override previous values set with transport_types-parameter. Values may range from 0.1 to 10 or it can be -1 when the transport type is excluded from routing. |
| optimize |
String |
Routing profile:
- default: wait cost=1.0, walk cost=1.2, change cost=6
- fastest: wait cost=1.0, walk cost=1.0, change cost=0
- least_transfers:wait cost=1.0, walk cost=1.5, change cost=20
- least_walking:wait cost=1.0, walk cost=5.0, change cost=6
Optional, default "default" profile. |
| change_margin |
Number |
The minimum number of minutes between changes. Optional, default 3, range 0-10. |
| change_cost |
Number |
Penalty for a change, user is rather N minutes later at the destination than changes to another vehicle. Optional, default 5, range 1-99.
This parameter overrides the setting from optimize.
|
| wait_cost |
Number |
With this parameter you can weigh wait time cost when calculating fastest route. Optional, values can be between 0.1 – 10.0.
This parameter overrides optimize parameter.
|
| walk_cost |
Number |
With this parameter you can weight walk time cost when calculating fastest route. Optional, values can be between 0.1 – 10.0.
This parameter overrides optimize parameter.
|
| walk_speed |
Number |
Walking speed. Optional, default 70 m/min, range 1-500. |
| detail |
String |
Detail level of the response. Optional, default "normal", possible values:
- "limited" = only legs are returned
- "normal" = intermediate stops are included
- "full" = route shape coordinates are included
|
| show |
Number |
Number of routes in the response. Optional, default 3, max 5. |
Response is an array of routes. Via routes have two parts in the response. Some fields are available only in full or normal level od detail. Below are descriptions for the different fields that the routes (or in case of a via routing, parts of routes) have in the response:
| Field nr. |
Name |
Type |
Description |
| 1 |
length |
Number |
Length of the route in meters.
|
| 2 |
duration |
Number |
Duration of the route in seconds.
|
| 3 |
legs |
Array
|
Array of legs of the route. |
| 3.1 |
length |
Number |
Length of the leg in meters. |
| 3.2 |
duration |
Number |
Duration of the leg in seconds. |
| 3.3 |
type |
String/Number |
Type of the leg:
- walk
- transport type id (see parameter mode_cost above for explanation of the ids)
|
|
3.4
|
code |
String |
Line code. |
|
3.5
|
locs |
Array |
Array of locations on the leg (limited detail only lists start and end locations). |
| 3.6 |
shape |
List |
Shape (list of coordinates) of the leg (only in full detail). |
| 3.5.1 |
coord |
Coordinate |
Coordinate of the location.
|
| 3.5.2 |
arrTime |
Number |
Arrival time to the location, format YYYYMMDDHHMM.
|
| 3.5.3 |
depTime |
Number |
Departure time from the location, format YYYYMMDDHHMM.
|
| 3.5.4 |
name |
String |
Name of the location.
|
| 3.5.5 |
code |
Number(7) |
Long code of the stop.
|
| 3.5.6 |
shortCode |
String(4-6) |
Short code of the stop.
|
| 3.5.7 |
stopAddress |
String |
Address of the stop.
|
- A sample search that includes only coordinates. The system uses the current time as default; the time is fetched from the NTP –time server.
- api.reittiopas.fi/hsl/prod/?request=route&from=2546445,6675512&to=2549445,6675513
- A search done when the user wants to reach the destination at a certain time.
- api.reittiopas.fi/hsl/prod/?request=route&from=2546445,6675512&to=2549445,6675513&time=1030&timetype=arrival
1.10 Cycling route
Route search for cycling from coordinate to coordinate. It is possible to use different routing profiles to prefer different types of cycling paths and shortest route.
| Parameter |
Description |
Type |
from
|
Start point coordinate. |
Coordinates separated by comma (e.g. <x,y>). |
| to |
Destination point coordinate.
|
Coordinates separated by comma (e.g. <x,y>). |
| via |
List of via point coordinates. |
List of coordinates separated by comma (e.g. <x,y>). List members are separated by pipes ("|"). Optional, maximum number of via points is 5. |
profile
|
String |
Optional, routing profile:
- kleroweighted = default profile
- klerotarmac = prefers cycle paths with tarmac
- klerosand = prefers gravel paths
- kleroshortest = prefers shortest route
|
| elevation |
0 or 1.
|
Optional, default value 0. If 1, elevation information of the route will be shown in the result. |
Response:
| Field nr. |
Name |
Type |
Description |
| 1 |
length |
Number |
Length of the whole route in meters.
|
| 2 |
path |
List |
List of parts of the route.
|
| 2.1 |
length |
Number
|
Length of the part in meters. |
| 2.2 |
name |
String |
Name of the area the part of the route is in. |
| 2.3 |
type |
String |
Paving type of the part of the route:
|
| 2.4 |
points |
List |
List of coordinates <x,y> the part of the route consists of. If elevation is shown format is <x,y,z> |
| 2.5 |
passtype |
String |
Pass type of the part of the route:
- underpass
- overpass
- if field is not available it is neither
|
- A sample search that includes only coordinates.
- api.reittiopas.fi/hsl/prod/?request=cycling&from=2546445,6675512&to=2549445,6675513
- A search with a tarmac preferring routing profile and two via points.
- api.reittiopas.fi/hsl/prod/?request=cycling&from=2546445,6675512&to=2549445,6675513&via=2543445,6674512|2548445,6674513&profile=klerotarmac
1.11 Validity
It is possible to check the date range of valid data that is in use in the API. No additional url-parameters are needed (just request=validity and authentication).
Response:
| Field nr. |
Name |
Type |
Description |
| 1 |
from |
Date
|
Date from which the data is valid.
|
| 2 |
to |
Date |
Date to which the data is valid.
|
1.12 Statistics
Used and available capacity can be checked with a request. No additional parameters are needed (apart from request=stats and authentication).
Response:
| Field nr. |
Name |
Type |
Description |
| 1 |
max |
Number
|
Maximum capacity.
|
| 2 |
used |
Number |
Used capacity.
|
2 Frequently asked questions
- Is it possible to do a search by place names or addresses?
The route search cannot be done with an address. Geocoding search needs to be done first. After geocoding the route search can be done with the fetched coordinates.
- How can the route be shown on a map?
To get the route to be shown on a map, the coordinates for all intermediate stops and points should be parsed from the response. With the coordinates it is possible to draw the route on a map. There is no open interface for the maps used in Reittiopas.
- Is it possible to do requests in XML format?
Doing requests in XML format is not possible, as the requests are run through an http filter. Thus there is also no need to make firewall openings. The filter performs checks so that only complete requests go to the algorithm so the load on the server is as low as possible.
- Is it possible to use the map images from Reittiopas?
The maps used in Reittiopas are not open for any other use due to contractual restrictions. The use of the maps requires an agreement with HSL.
- Codes of the vehicles?
Line code in the routing response is a unique code from the Register of Public Transport (JORE). The code the passengers know and which can be seen on the bus can be parsed from the JORE-code with the help of transport type id (attribute type in the response).
Please note that there are some special cases such as 1300-series (subway), 1100-series (Helsinki night buses) and 1019 (ferry to Suomenlinna).
JORE line codes are always 7 characters long. For example “2102T 1” which is JORE code for line 102T.
The code consists of following parts:
1. character = area/transport type code (e.g. 2)
2.-4. character = line code (e.g. 102)
5. character = letter variant (e.g. T)
6. character = letter variant or numeric variant (numeric variants are usually not used for base routes and are not shown to the end users)
7. character = direction (always 1 or 2), not shown to end users
More detailed instructions can be asked from HSL.
Area/transport types are:
1=Helsinki internal traffic
2=Espoo internal bus traffic and regional bus traffic from Helsinki to Espoo
3=Local trains
4=Vantaa internal bus traffic and regional bus traffic from Helsinki to Vantaa
5=Regional transverse traffic in Espoo - Helsinki - Vantaa
6=not in use
7=U-lines (buses that drive also outside the YTV area of service)
Transport types:
1 Helsinki/bus
2 Helsinki/tram
3 Espoo internal
4 Vantaa internal
5 Regional traffic
6 Metro traffic
7 Ferry
8 U-lines
9 Other local traffic
10 Long-distance traffic
11 Express
12 VR local traffic
13 VR long-distance traffic
14 All
21 Helsinki service lines
22 Helsinki night traffic
23 Espoo service lines
24 Vantaa service lines
25 Regional night traffic
36 Kirkkonummi internal
38 Sipoo internal
39 Kerava internal
(types 9,10,11,13,14 are not used in the data)
3 Changelog
|