Topics:

Stops

If you are not yet familiar with GraphQL and GraphiQL it is highly recommended to review those pages at first.

Notes about stop IDs

  • Stop IDs are in FeedId:StopId format
  • HSL area feed ID is HSL
  • Stop ID is available from field gtfsId (note that field gtfsId also contains the feed ID)

Query examples

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

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.

Query all stops, returning their ID, name, location and zone

  • Value of zoneId tells which zone the stop is located in
  1. Click this link to run the query below in GraphiQL.
{
  stops {
    gtfsId
    name
    lat
    lon
    zoneId
  }
}
  1. Press play in GraphiQL to execute the query.

Query stop by ID

  1. Click this link to run the query below in GraphiQL.
{
  stop(id: "HSL:1140447") {
    name
    wheelchairBoarding
  }
}
  1. Press play in GraphiQL to execute the query.

Query stop by ID and information about routes that go through it

  1. Click this link to run the query below in GraphiQL.
{
  stop(id: "HSL:1140447") {
    gtfsId
    name
    lat
    lon
    patterns {
      code
      directionId
      headsign
      route {
        gtfsId
        shortName
        longName
        mode
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Query stops by name or number

  • Argument name can either be a part of the stop name (e.g. "hertton" or "rautatientori") or a stop number (e.g. "4040")
  1. Click this link to run the query below in GraphiQL.
{
  stops(name: "hertton") {
    gtfsId
    name
    code
    lat
    lon
  }
}
  1. Press play in GraphiQL to execute the query.

Query all stations and return list of stops within the stations

  • Station is a location, which contains stops

    • For example, a train station is a station and its platforms are stops
  1. Click this link to run the query below in GraphiQL.
{
  stations {
    gtfsId
    name
    lat
    lon
    stops {
      gtfsId
      name
      code
      platformCode
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Query stations by name

  1. Click this link to run the query below in GraphiQL.
{
  stations(name: "pasila") {
    gtfsId
    name
    lat
    lon
    stops {
      gtfsId
      name
      code
      platformCode
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Query stops by location and radius

  • If the argument first is not used in the query, all results will be on one page.
  • Note: argument radius is the maximum walking distance along streets and paths to the stop
  1. Click this link to run the query below in GraphiQL.
{
  stopsByRadius(lat:60.199, lon:24.938, radius:500) {
    edges {
      node {
        stop {
          gtfsId
          name
        }
        distance
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Query scheduled departure and arrival times of a stop

  • Value serviceDay in the response is Unix timestamp (local timezone) of the departure date
  • Values scheduledArrival, realtimeArrival, scheduledDeparture and realtimeDeparture in the response are seconds since midnight of the departure date

    • To get Unix timestamp (UTC time) of arrivals and departures, add these values to serviceDay

Next departures and arrivals

  1. Click this link to run the query below in GraphiQL.
{
  stop(id: "HSL:1140447") {
    name
      stoptimesWithoutPatterns {
      scheduledArrival
      realtimeArrival
      arrivalDelay
      scheduledDeparture
      realtimeDeparture
      departureDelay
      realtime
      realtimeState
      serviceDay
      headsign
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Departures and arrivals at specific time

  • Use argument startTime in stoptimes query

    • startTime is Unix timestamp (UTC timezone) in seconds
  1. Click this link to run the query below in GraphiQL.
{
  stop(id: "HSL:1140447") {
    name
    stoptimesWithoutPatterns(startTime: 1528633800) {
      scheduledArrival
      realtimeArrival
      arrivalDelay
      scheduledDeparture
      realtimeDeparture
      departureDelay
      realtime
      realtimeState
      serviceDay
      headsign
    }
  }
}
  1. Change argument startTime.
  2. Press play in GraphiQL to execute the query.

Query arrivals and departures from a station

  • Field platformCode contains the platform code used by the vehicle
  1. Click this link to run the query below in GraphiQL.
{
  station(id: "HSL:1000202") {
    name
    stoptimesWithoutPatterns(numberOfDepartures: 10) {
      stop {
        platformCode
      }
      serviceDay
      scheduledArrival
      scheduledDeparture
      trip {
        route {
          shortName
        }
      }
      headsign
    }
  }
}
  1. Press play in GraphiQL to execute the query.

Query departures near a specific location

  • Query type nearest can be used to query departure rows near a specific location
  • Departure row is a special location type, which lists departures of a certain route pattern from a certain stop
  • Querying nearest departure rows returns only one stop per pattern

    • i.e. if there are multiple stops that a certain pattern uses, only the closest stop is returned
  1. Click this link to run the query below in GraphiQL.
{
  nearest(lat: 60.19915, lon: 24.94089, maxDistance: 500, filterByPlaceTypes: DEPARTURE_ROW) {
    edges {
      node {
        place {
          ...on DepartureRow {
            stop {
              lat
              lon
              name
            }
            stoptimes {
              serviceDay
              scheduledDeparture
              realtimeDeparture
              trip {
                route {
                  shortName
                  longName
                }
              }
              headsign
            }
          }
        }
        distance
      }
    }
  }
}
  1. Press play in GraphiQL to execute the query.