Routing API enables developers to query routes and timetable related information using either REST or GraphQL interfaces.
Routing API is implemented using OpenTripPlanner.
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.
If you need to make a 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:prod
After OpenTripPlanner has built the routing graph, the API can be accessed from http://localhost:9080/otp/routers/hsl/index/graphql
REST interface is provided as it is available in OpenTripPlanner. First thing to do is to familiarize yourself with OpenTripPlanner documentation:
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 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
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 |
Asset | Url |
---|---|
source | https://github.com/HSLdevcom/OpenTripPlanner |
DockerHub | https://hub.docker.com/r/hsldevcom/opentripplanner/ |
Dockerfile | https://github.com/HSLdevcom/OpenTripPlanner/blob/master/Dockerfile |
The resulting Docker image is called hsldevcom/opentripplanner and it is available at DockerHub. The image can be built using this build script.
To run Docker container, run:
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:prod
To access Docker container:
http://localhost:9080/routers/
For More information about how to use Docker see docker info.