Digitransit APIs require registration. More information
Topics:

Bicycles, cars and e-scooters

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 related query types:

  • Query type planConnection can be used to query routes using either a rented vehicle (bicycle, car or e-scooter) or your personal vehicle (bicycle or car).
  • Query types vehicleRentalStation and vehicleRentalStations can be used to query rental stations, and their capacity and availability.
  • Query types rentalVehicle and rentalVehicles can be used to query floating rental vehicles (i.e. those that are not connected to a physical station).
  • Query types vehicleParking and vehicleParkings can be used to query parks that are available and sometimes the availability of parking spaces.

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

Query examples

Vehicle rental

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. Rental services are also often seasonal in Finland, which means that the stations or vehicles are not always available from the API.

Fetch all rental stations

  1. Click this link to run the query below in GraphiQL. It should fetch all available vehicle rental station stations.
{
  vehicleRentalStations {
    stationId
    name
    allowPickup
    availableVehicles {
      byType {
        count
        vehicleType {
          formFactor
        }
      }
    }
  }
}
  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.
{
  vehicleRentalStation(id: "smoove:396") {
    stationId
    name
    availableVehicles {
      byType {
        count
        vehicleType {
          formFactor
        }
      }
    }
    availableSpaces {
      byType {
        count
        vehicleType {
          formFactor
        }
      }
    }
    lat
    lon
    allowDropoff
  }
}
  1. Press play in GraphiQL to execute the query.

Fetch all floating rental vehicles

  1. Click this link to run the query below in GraphiQL. It should fetch all floating rental vehicles, their availability and vehicle type.
{
  rentalVehicles {
    vehicleId
    vehicleType {
      formFactor
      propulsionType
    }
    operative
  }
}
  1. Press play in GraphiQL to execute the query.

Fetch all scooters

  1. Click this link to run the query below in GraphiQL. It should fetch all scooters and some of their available information.
{
  rentalVehicles(formFactors: [SCOOTER, SCOOTER_SEATED, SCOOTER_STANDING]) {
    vehicleId
    vehicleType {
      formFactor
      propulsionType
    }
    operative
  }
}
  1. Press play in GraphiQL to execute the query.

Fetch a specific scooter

Note: IDs of floating vehicles tend to change constantly.

  1. Click this link to run the query below in GraphiQL. It should fetch a specific scooter and some of its available information.
{
  rentalVehicle(id:"bolt_helsinki:04928ae0-aebc-4044-bd95-e5199e7fd0d8") {
    vehicleId
    vehicleType {
      formFactor
      propulsionType
    }
    allowPickupNow
  }
}
  1. Press play in GraphiQL to execute the query.

Vehicle parking

The vehicle parking areas that can be found from the APIs are meant for park and ride. Other types of parking areas might not be found. Parking data is not available in every routing endpoint.

Fetch all vehicle parking areas

  1. Click this link to run the query below in GraphiQL. It should fetch all available vehicle parks.
{
  vehicleParkings {
    vehicleParkingId
    name
    state
    availability {
      carSpaces
      bicycleSpaces
      wheelchairAccessibleCarSpaces
    }
    capacity {
      carSpaces
      bicycleSpaces
      wheelchairAccessibleCarSpaces
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Fetch a single bicycle park

  1. Click this link to run the query below in GraphiQL. It should fetch the bike park and its current space availability details.
{
  vehicleParking(id:"liipi:974") {
    vehicleParkingId
    name
    state
    availability {
      bicycleSpaces
    }
    capacity {
      bicycleSpaces
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Itinerary planning

Plan an itinerary from Kaartinkaupunki to Otaniemi using city bike rental

  • Bike rental can be used by adding mode BICYCLE_RENTAL to modes.

    • Note that the response field mode does not differentiate between a rental bicycle and a personal bicycle.
    • Note that availability information of a station is only used if the search arrival or departure time is within the next 15 hours
    • If it doesn't make sense to use rental, no rental will be used in the suggestions.
  • 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.
{
  planConnection(
    origin: {location: {coordinate: {latitude: 60.1641516457, longitude: 24.95003700}}}
    destination: {location: {coordinate: {latitude: 60.188229950, longitude: 24.83785629272}}}
    first: 1
    modes: {direct: [BICYCLE_RENTAL, WALK], transit: {access: [BICYCLE_RENTAL, WALK], egress: [BICYCLE_RENTAL, WALK]}}
  ) {
    edges {
      node {
        start
        end
        legs {
          duration
          mode
          distance
          from {
            lat
            lon
            vehicleRentalStation {
              stationId
              availableVehicles {
                byType {
                  vehicleType {
                    propulsionType
                  }
                  count
                }
              }
            }
          }
          to {
            lat
            lon
            vehicleRentalStation {
              stationId
            }
          }
          start {
            scheduledTime
          }
          end {
            scheduledTime
          }
        }
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Plan an itinerary riding your personal bike

  • Note that directOnly must be used to avoid itineraries using public transport
  • Click this link to run the query below in GraphiQL. It should fetch bicycle route from Kamppi to Pisa.
{
  planConnection(
    origin: {location: {coordinate: {latitude: 60.168992, longitude: 24.932366}}}
    destination: {location: {coordinate: {latitude: 60.165246, longitude: 24.949128}}}
    modes: {direct: [BICYCLE], directOnly: true}
    first: 1
  ) {
    edges {
      node {
        legs {
          duration
          mode
          distance
          from {
            lat
            lon
            name
          }
          to {
            lat
            lon
            name
          }
          legGeometry {
            points
            length
          }
        }
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Plan an itinerary with boarding transit with your personal bike

  • Note that directOnly must be used to avoid itineraries using public transport
  • Click this link to run the query below in GraphiQL. It should fetch bicycle route from Rautatieasema to Pasila.
{
  planConnection(
    origin: {location: {coordinate: {latitude: 60.1675747130, longitude: 24.9437713623}}}
    destination: {location: {coordinate: {latitude: 60.20011132, longitude: 24.93553161}}}
    modes: {transitOnly:true, transit: {access: BICYCLE, transfer: BICYCLE, egress: BICYCLE}}
    first: 1
  ) {
    edges {
      node {
        legs {
          duration
          mode
          distance
          from {
            lat
            lon
            name
            stop {
              name
            }
          }
          to {
            lat
            lon
            name
            stop {
              name
            }
          }
          legGeometry {
            points
            length
          }
        }
      }
    }
  }
}
  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 argument modes: {transit: {access: [BICYCLE_PARKING]}} returns 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.
{
  planConnection(
    origin: {location: {coordinate: {latitude: 60.18778, longitude: 25.02987}}}
    destination: {location: {coordinate: {latitude: 60.21109, longitude: 25.08094}}}
    first: 3
    modes: {transit: {access: [BICYCLE_PARKING]}}
  ) {
    edges {
      node {
        start
        end
        legs {
          duration
          mode
          distance
          from {
            lat
            lon
          }
          to {
            lat
            lon
            vehicleParking {
              vehicleParkingId
            }
          }
          start {
            scheduledTime
          }
          end {
            scheduledTime
          }
        }
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.
© Digitransit 2024