Skip to content

Real-time Transit Information (RTTI)

The Real-Time Transit Information Open API is REST (Representational State Transfer); however this API is read only, i.e. http get calls.

  1. The API default is to return XML data, however, it can return JSON if the content-type: application/JSON or accept: application/JSON is set in the http request header.

  2. The API will require a unique API key to request for data.

  3. The API key will authorize to offer a maximum of 1,000 requests per day for use of the Data. This is to prevent malicious users from abusing our service. This might change and is open for discussion.

  4. The API will provide services for Stops, Buses, Stop Estimates, and Route details.

  5. Route url site will be http://api.translink.ca.

Query Types and Parameters

There are two main types of queries, ID queries and Filter queries.

ID Queries

ID queries return a single result. They specify the ID of the desired resource.
E.g. http://api.translink.ca/RTTIAPI/V1/stops/55612?apiKey=[APIKey]

Filter Queries

Filter queries specify the results by passing in URL parameters. You can, for example, filter bus results according to a given stop number and route number.
E.g. http://api.translink.ca/RTTIAPI/V1/stops?apiKey=[APIKey]&lat=49.187706&long=-122.850060

Mandatory Parameter

The API key (apikey) is a mandatory parameter that is required in every request. Failure to provide a valid or active API key will result in a 403 HTTP response.

XML or JSON Specification

You can choose to either have the result set delivered as XML or JSON. This is done by specifying the "content-type" or "accept" in the http header as "application/XML" or "application/JSON". If this is left out of the http request, the result set will return XML.


RTTI API Reference


Stops

Stops are locations where buses provide scheduled service.

Parameter

ApiKey (string) Your ApiKey received during registration

Identity

StopNo (int) A five-digit stop number

Filters

Lat (decimal) The latitude of your search (must be combined with long)
Long (decimal) The longitude of your search (must be combined with lat)
Radius (int) If present, will search a radius for stops (must be combined with lat and long). Default 500. Maximum 2000.
RouteNo (string) If present, will search for stops specific to route

Response Fields

Stops The element containing the list of stops
Stop The element containing the stop information
StopNo The 5-digtal stop number
Name The stop name
BayNo The bay number, if applicable
City The city in which the stop is located
OnStreet The street name the stop is located on
AtStreet The intersecting street of the stop
Latitude The latitude of the stop
Longitude The longitude of the stop
WheelchairAccess Specifies wheelchair accessible stop. 1 indicates stop is wheelchair accessible
Distance Distance away from the search location
Routes The list of routes that the stop services

Error Codes

10001 Invalid API key
10002 Database connection error
1001 Invalid stop number
1002 Stop number not found
1003 Unknown stop check error
1004 Unknown get stop error
1011 Invalid latitude/longitude
1012 No stops found
1013 Unknown get stops error
1014 Radius too large
1015 Invalid route number

Examples

  • https://api.translink.ca/rttiapi/v1/stops/55612?apikey=[APIKey]
    - Returns stop details for stop 55612

  • https://api.translink.ca/rttiapi/v1/stops?apikey=[APIKey]&lat=49.187706&long=-122.850060
    - Returns stops near latitude/longitude coordinates, radius is defaulted to 500 meters

  • https://api.translink.ca/rttiapi/v1/stops?apikey=[APIKey]&lat=49.187706&long=-122.850060&routeNo=590
    - Returns stops near latitude/longitude coordinates, radius is defaulted to 500 meters and filtered to only show stops serving route 590

  • https://api.translink.ca/rttiapi/v1/stops?apikey=[APIKey]&lat=49.248523&long=-123.108800&radius=500
    - Returns stops near latitude/longitude coordinates, radius is 500 meters


Stop Estimates

Gets the next bus estimates for a particular stop. Returns schedule data if estimates are not available.

Parameter

ApiKey (string) Your ApiKey received during registration

Identity

StopNo (int) A five-digit stop number

Filters

Count (int) The number of buses to return. Default 6
TimeFrame (int) The search time frame in minutes. Default 120
RouteNo (string) If present, will search for stops specific to route

Response Fields

NextBuses The element containing the list of next buses
NextBus The element containing the next bus information
RouteNo The bus route number
RouteName The bus route name
Direction The direction of the route at the specific stop
RouteMap The element containing the route map information
Href The location of the route map file in KMZ format
Schedules The element containing the list of schedules
Schedule The element containing the schedule information
Pattern The pattern of the specific trip
Destination The destination of the trip
ExpectedLeaveTime The expected departure time of the trip at the specific stop
ExpectedCountdown The expected departure time in minutes
ScheduleStatus The status of the trip. * indicates scheduled time. - indicates delay. + indicates bus is running ahead of schedule
CancelledTrip Indicates if trip is cancelled
CancelledStop Indicates if stop is cancelled
AddedTrip Indicates if trip is added
AddedStop Indicates if stop is added
LastUpdate The last updated time of the trip

Error Codes

10001 Invalid API key
10002 Database connection error
3001 Invalid stop number
3002 Stop number not found
3003 Unknown get estimates error
3004 Invalid route
3005 No stop estimates found
3006 Invalid time frame
3007 Invalid count

Examples

  • https://api.translink.ca/rttiapi/v1/stops/60980/estimates?apikey=[APIKey]
    - Returns the next 6 buses for each route to service the stop in the next 24 hours

  • https://api.translink.ca/rttiapi/v1/stops/60980/estimates?apikey=[APIKey]&count=3&timeframe=120
    - Returns the next 3 buses for each route to service the stop in the next 2 hours meters

  • https://api.translink.ca/rttiapi/v1/stops/60980/estimates?apikey=[APIKey]&count=3&timeframe=120&routeNo=050
    - Returns the next 3 buses to service the stop in the next 2 hours for route 50

  • https://api.translink.ca/rttiapi/v1/stops/60980/estimates?apikey=[APIKey]&routeNo=050
    - Returns the next 6 buses to service the stop in the next 24 hours for route 50


Buses

Use the buses request to retrieve vehicle information of all or a filtered set of buses.

Parameter

ApiKey (string) Your ApiKey received during registration

Identity

BusNo (int) A vehicle id

Filters

StopNo (int) If present, will search for buses for stop id specified
RouteNo (string) If present, will search for stops specific to route

Response Fields

Buses The element containing the list of buses
Bus The element containing the bus information
VehicleNo The vehicle number of the bus
TripId The id of the trip the bus currently running
RouteNo The route number of the vehicle
Direction The direction of the trip
Pattern The pattern of the trip
Latitude The latitude of the vehicle location
Longitude The longitude of the vehicle location
RecordedTime The recorded time of the last location of the vehicle
RouteMap The element containing the route map information
Href The location of the route map file for the vehicle in KMZ format

Error Codes

10001 Invalid API key
10002 Database connection error
2001 Invalid bus number
2002 Bus number not found
2003 Unknown get bus error
2011 No buses found
2012 Unknown get buses by stop error
2013 Unknown get buses by route error
2014 Invalid stop number
2015 Invalid route number
2016 Stop number not found
2017 Route number not found
2018 Unknown get buses by stop and route error

Examples

  • https://api.translink.ca/rttiapi/v1/buses/7196?apikey=[APIKey]
    - Returns details for bus id 7196 if active, otherwise a 404 will be returned

  • https://api.translink.ca/rttiapi/v1/buses?apikey=[APIKey]
    - Returns details for all active buses

  • https://api.translink.ca/rttiapi/v1/buses?apikey=[APIKey]&stopNo=53987
    - Returns all active buses serving stop 53987

  • https://api.translink.ca/rttiapi/v1/buses?apikey=[APIKey]&stopNo=53987&routeNo=210
    - Returns all active buses serving stop 53987 and route 210

  • https://api.translink.ca/rttiapi/v1/buses?apikey=[APIKey]&routeNo=099
    - Returns all active buses serving route 99

  • https://api.translink.ca/rttiapi/v1/buses?apikey=[APIKey]&routeNo=9999
    - Returns a 404 error, "Invalid route number specified. Please use a valid active route id."


Routes

Routes are a sequenced pattern of service.

Parameter

ApiKey (string) Your ApiKey received during registration

Identity

RouteNo (string) A bus route number

Filters

StopNo (int) If present, will search for routes passing through this stop

Response Fields

Route The element containing the route information
RouteNo The bus route number
Name The name of the route
OperatingCompany The operating company of the route
Patterns The list of patterns for the route
Pattern The element containing the pattern information
PatternNo The pattern number
Destination The destination of the pattern
RouteMap The element containing the route map information
Href The location of the route map file for the specific pattern
Direction The direction of the pattern

Error Codes

10001 Invalid API key
10002 Database connection error
4002 Route number not found
4003 Unknown get route error
4004 Invalid route number
4011 Invalid stop number
4012 Stop number not found
4013 Unknown error
4014 No routes found

Examples

  • https://api.translink.ca/rttiapi/v1/routes/351?apikey=[APIKey]
    - Returns details for route 351

  • https://api.translink.ca/rttiapi/v1/routes?apikey=[APIKey]&stopNo=55385
    - Returns routes serving stop 55385


Status

Gets the bus location and real-time schedule information update status.

Parameter

ApiKey (string) Your ApiKey received during registration

Identity

Service A service name. "Location" for bus location information, "schedule" for real-time schedule information, and "all" for both services.

Response Fields

Statuses The element containing the list of statuses
Status The element containing the status information
Name The name of the service ("Location" or "Schedule")
Value The status of the service ("Online" or "Offline")

Error Codes

10001 Invalid API key
10002 Database connection error
5001 Invalid service name

Examples

  • https://api.translink.ca/rttiapi/v1/status/all?apikey=[APIKey]
    - Returns status of location and schedule updates

  • https://api.translink.ca/rttiapi/v1/status/location?apikey=[APIKey]
    - Returns status of location updates

  • https://api.translink.ca/rttiapi/v1/status/schedule?apikey=[APIKey]
    - Returns status of schedule updates


TransLink

Sorry, your website browser is no longer supported.

Upgrade to one of these browsers to visit translink.ca: