Skip to content

GTFS GraphQL API

The GTFS GraphQL API is a general purpose API which was created for the Digitransit project and is used heavily by digitransit-ui.

otp-react-redux has also migrated to this API in 2023.

There is also a Java client available which makes it easy to use this API in a Java application.

URLs

Built-in API client

A browser based GraphQL API client is available at http://localhost:8080/graphiql

GraphiQL

curl example

A complete example that fetches the list of all stops from OTP is:

curl --request POST \
  --url http://localhost:8080/otp/gtfs/v1 \
  --header 'Content-Type: application/json' \
  --header 'OTPTimeout: 180000' \
  --data '{"query":"query stops {\n  stops {\n    gtfsId\n    name\n  }\n}\n","operationName":"stops"}'

Configuration

The API is enabled by default.

If you want to disable it, do it in otp-config.json:

// otp-config.json
{
  "otpFeatures" : {
    "GtfsGraphQlApi": false
  }
}