Entur Developer
Open services

Vehicle Positions

The Vehicle Positions API is a GraphQL service that provides real-time positions and status for public transport vehicles across Norway. It enables fetching and streaming live vehicle data including location, delays, occupancy, and journey information.

API Reference

Base URL: https://api.entur.io/realtime/v2/vehicles/graphql

GraphQL IDE: https://api.entur.io/graphql-explorer/vehicles-v2

Are you new to GraphQL? You can read more about it here: https://graphql.org/

Authentication

Vehicle Positions is an Open Service licensed under NLOD and requires the ET-Client-Name header for all requests.

Use a value that uniquely identifies your company and application, in the form <company>-<application> (lowercase, no spaces).

For detailed authentication instructions and requirements, see Authentication.

Query

Fetch the current state of vehicles with a GraphQL query.

POST https://api.entur.io/realtime/v2/vehicles/graphql

Headers

  • Content-Type: application/json
  • ET-Client-Name: <company>-<application>

Example

Fetch all vehicles for a given codespace:

GraphQLCode
{ vehicles(codespaceId: "ATB") { vehicleId lastUpdated line { lineRef lineName publicCode } location { latitude longitude } bearing speed delay occupancyStatus } }

Filtering

The vehicles query accepts several arguments for narrowing the result set, including:

  • codespaceId - all vehicles for a codespace (e.g. ATB, RUT, SKY)
  • lineRef / lineName - vehicles on a specific line
  • mode - filter by transport mode (e.g. bus, rail, tram)
  • boundingBox - vehicles within a geographic area
  • monitored - only vehicles with active real-time monitoring
  • maxDataAge - maximum age of data as an ISO-8601 duration (e.g. PT1M)

To discover the available codespaces to filter by:

GraphQLCode
{ codespaces { codespaceId } }

WebSocket Subscriptions

For real-time streaming updates, the API provides GraphQL subscriptions over WebSocket:

WebSocket URL: wss://api.entur.io/realtime/v2/vehicles/subscriptions

Subscriptions allow your application to receive continuous updates as vehicle positions change, rather than polling for data. The connection uses the graphql-ws protocol, and the ET-Client-Name header must be included in the initial connection request.

Example Subscription

Subscribe to vehicle updates within a geographic bounding box:

GraphQLCode
subscription { vehicles( boundingBox: { minLat: 59.9 maxLat: 60.0 minLon: 10.7 maxLon: 10.8 } ) { vehicleId location { latitude longitude } bearing delay line { publicCode } } }

Updates are buffered before being pushed to the client. Use the bufferSize and bufferTime arguments on the subscription to tune how frequently batches are delivered.

Additional Resources

Last modified on
Did you find what you were looking for?