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
  • Timisoara area feed ID is stpt
  • 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
  • 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: "stpt:2987") {
    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: "stpt:2987") {
    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. "complex" or "iulius") or a stop number (e.g. "4040")
  • Click this link to run the query below in GraphiQL.
{
  stops(name: "complex") {
    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
  • 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: "Pantelimon") {
    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
  • 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: "stpt:2987") {
    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
  • Click this link to run the query below in GraphiQL.
{
  stop(id: "stpt:2987") {
    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
  • Click this link to run the query below in GraphiQL.
{
  station(id: "stpt: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
  • Click this link to run the query below in GraphiQL.
{
	nearest(lat: 45.7410432, lon: 21.14655, 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.