Topics:

Routing API

Routing API enables developers to query routes and timetable related information using either REST or GraphQL interfaces.

edit architecture image

Service Architecture

Routing API is implemented using OpenTripPlanner.

http://www.opentripplanner.org/

Static and realtime information

OpenTripPlanner APIs provide access to static and realtime routing and transit information. Routing and timetable data is based on static GTFS and it is enriched by realtime information for those departures that have realtime information available. This means that results returned by OpenTripPlanner always contain realtime information should it be available.

Hosting the API locally

If you need to make large amount of requests (e.g. requesting schedules from all stops) to the API, you might want to host the API locally. To run OpenTripPlanner with Docker, use command:

docker run --rm --name otp-hsl -p 9080:8080 -e ROUTER_NAME=hsl -e JAVA_OPTS=-Xmx5g -e ROUTER_DATA_CONTAINER_URL=https://api.digitransit.fi/routing-data/v2/hsl hsldevcom/opentripplanner

After OpenTripPlanner has built the routing graph, the API can be accessed from http://localhost:9080/otp/routers/hsl/index/graphql

API Documentation

REST

REST interface is provided as it is available in OpenTripPlanner. First thing to do is to familiarize yourself with OpenTripPlanner documentation:

http://docs.opentripplanner.org/en/latest/

OpenTripPlanner requires developers to make API requests through routers. Digitransit providers routers for Helsinki region, the Waltti regions and entire Finland:

Region Router URL
Helsinki region http://api.digitransit.fi/routing/v1/routers/hsl/
Waltti regions http://api.digitransit.fi/routing/v1/routers/waltti/
Entire Finland http://api.digitransit.fi/routing/v1/routers/finland/

GraphQL

GraphQL API is built by us. Similarly to REST, GraphQL has different router endpoints for Helsinki region, the Waltti regions and entire Finland.

For more details about the GraphQL you can go to our GraphQL page

Introspection query

You can get access to GraphQL schema by running this example in GraphQL console

URL Project description
https://github.com/opentripplanner/OpenTripPlanner OpenTripPlanner upstream development on GitHub
https://groups.google.com/forum/#!forum/opentripplanner-dev OpenTripPlanner forum for developers
https://groups.google.com/forum/#!forum/opentripplanner-users OpenTripPlanner forum for end users
https://onebusaway.org/ OneBusAway: The Open Source platform for Real Time Transit Info
https://github.com/OneBusAway?utf8=✓&query=gtfs GTFS related projects: Open-source transit app for real-time information
https://developers.google.com/transit/ Google developers transit community: Making public transit data universally accessible
https://github.com/conveyal/r5 Conveyal R5 development on GitHub: Rapid Realistic Routing on Real-world and Reimagined networks
https://blog.conveyal.com/ Conveyal blog

Docker image

The resulting Docker image is called hsldevcom/opentripplanner and it is available at DockerHub. The image can be built using this build script. You might also want to take a look at the Travis build and configuration.

To run Docker container, run:

docker run -e OTP_DATA_CONTAINER_URL=http://otp-data-container:8080 -p 8080:8080 hsldevcom/opentripplanner

To access Docker container:

http://localhost:8080/routers/

For More information about how to use Docker see docker info.