Digitransit APIs require registration. More information
Topics:

Bicycling

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:

  • Query type plan can be used to query bicycling routes using either a city bike or your personal bike
  • Query types bikeRentalStation and bikeRentalStations can be used to query city bike rental stations and bikes that are available
  • Query types bikePark and bikeParks can be used to query bike parks that are available

Note: For more details about these query types you can use the Documentation Explorer provided in GraphiQL.

City bikes

Note: City bike API data is realtime and it is always up to date.

https://www.hsl.fi/en/citybikes

citybikes

Query examples

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.

All available city bike stations

  1. Click this link to run the query below in GraphiQL. It should fetch all available city bike stations.
{
  bikeRentalStations {
    name
    stationId
  }
}
  1. Press play in GraphiQL to execute the query.

Single city bike station and its current bike availability details

  1. Click this link to run the query below in GraphiQL. It should fetch the city bike station and its current bike availability details.
{
  bikeRentalStation(id:"070") {
    stationId
    name
    bikesAvailable
    spacesAvailable
    lat
    lon
    allowDropoff
  }
}
  1. Press play in GraphiQL to execute the query.

All available bike parks

  1. Click this link to run the query below in GraphiQL. It should fetch all available bike parks.
{
  bikeParks {
    bikeParkId
    name
  }
}
  1. Press play in GraphiQL to execute the query.

Single bike park

  1. Click this link to run the query below in GraphiQL. It should fetch the bike park and its current space availability details.
{
  bikePark(id: "906") {
    bikeParkId
    name
    spacesAvailable
    lat
    lon
  }
}
  1. Press play in GraphiQL to execute the query.

Plan an itinerary from Kamppi to Kasarmitori using city bike rental

  • Bike rental can be used by adding qualifier RENT to transportModes argument

    • Note that field mode in the results does not include information about qualifiers
  • Click 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
        }
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Plan an itinerary from Kamppi to Pisa riding your personal bike

  • 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
        }
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Plan an itinerary from Herttoniemenranta to Itäkeskus and use your personal bike for the first part of the journey

  • 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
        }
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Plan an itinerary from Jätkäsaari to Ooppera using personal bike and optimizing for safety

  • 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
        }
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.
© Digitransit 2024