If you are not yet familiar with GraphQL and GraphiQL it is highly recommended to review those pages at first.
The Routing API provides a few bicycle related query types:
Note: For more details about these query types you can use the Documentation Explorer provided in GraphiQL.
Note: City bike API data is realtime and it is always up to date.
Note: If the examples provided with an ID do not return what is expected then the ID in question may not be in use any more and you should try again with an existing ID.
{
bikeRentalStations {
name
stationId
}
}
{
bikeRentalStation(id:"070") {
stationId
name
bikesAvailable
spacesAvailable
lat
lon
allowDropoff
}
}
{
bikeParks {
bikeParkId
name
}
}
{
bikePark(id: "906") {
bikeParkId
name
spacesAvailable
lat
lon
}
}
Bike rental can be used by adding qualifier RENT to transportModes
argument
mode
in the results does not include information about qualifiersClick this link to run the query below in GraphiQL. It should plan an itinerary from Kamppi to Kasarmitori using city bike rental and show which rental stations are used.
{
plan(
fromPlace: "Kamppi, Helsinki::60.168992,24.932366",
toPlace: "Kasarmitori, Helsinki::60.165246,24.949128",
numItineraries: 1,
transportModes: [{mode: BICYCLE, qualifier: RENT}, {mode: WALK}],
) {
itineraries{
walkDistance
duration
legs {
mode
startTime
endTime
from {
lat
lon
name
bikeRentalStation {
stationId
name
}
}
to {
lat
lon
name
bikeRentalStation {
stationId
name
}
}
distance
legGeometry {
length
points
}
}
}
}
}
Note that transport mode WALK must not be used when planning an itinerary with personal bike, as otherwise the whole journey is done by walking
Click this link to run the query below in GraphiQL. It should fetch bicycle route from Kamppi to Pisa.
{
plan(
fromPlace: "Kamppi, Helsinki::60.168992,24.93236",
toPlace: "Pisa, Espoo::60.175294,24.68485",
transportModes: {mode: BICYCLE}
) {
itineraries{
walkDistance
duration
legs {
mode
startTime
endTime
from {
lat
lon
name
}
to {
lat
lon
name
}
distance
legGeometry {
length
points
}
}
}
}
}
Using qualifier PARK for BICYCLE mode plans an itinerary, which begins by bicycling to a bike park from which the journey is continued by public transportation
Click this link to run the query below in GraphiQL.
{
plan(
fromPlace: "Herttoniemenranta::60.18778,25.02987",
toPlace: "Itäkeskus::60.21109,25.08094",
numItineraries: 1,
transportModes: [{mode: BICYCLE, qualifier: PARK}, {mode: WALK}, {mode: TRANSIT}],
) {
itineraries{
walkDistance
duration
legs {
mode
startTime
endTime
from {
lat
lon
name
stop {
gtfsId
code
name
}
}
to {
lat
lon
name
bikePark {
bikeParkId
name
}
stop {
gtfsId
code
name
}
}
trip {
routeShortName
tripHeadsign
}
distance
legGeometry {
length
points
}
}
}
}
}
Argument optimize: SAFE
can be used to set preference for safer routes, i.e. avoid crossing streets and use bike paths when possible
Click this link to run the query below in GraphiQL. The returned itinerary should use Baana bike path.
{
plan(
fromPlace: "60.15978,24.91842"
toPlace: "60.18204,24.92756"
transportModes: [{mode: BICYCLE}]
optimize: SAFE
) {
itineraries {
legs {
mode
duration
distance
legGeometry {
points
}
}
}
}
}