Legacy OC Transpo API 2.0
GTFS Changes
Due to changes to our GTFS schedule file, this API method will soon be deprecated.
Getting Started
To access the OC Transpo Live Next Bus Arrival Data Feed, you will need an API key. Register and receive an API key instantly using the API registration form.
Once you have provided your name and contact information, we will send you an email with a link to activate your account. Follow the instructions to activate the account, sign in and generate a new Application ID by clicking on the applications section of the Dashboard.
For security purposes, you will be asked for your Application ID and API key with each request. Please ensure you are making your requests using HTTPS.
GTFS Download
The GTFS data provides the same schedule data that supports OC Transpo’s online travel planner. Please note that by accessing the datasets, you agree to the City of Ottawa’s Terms of Use. The OC Transpo GTFS Schedule file follows the GTFS standard maintained by MobilityData.
Methods
- GetRouteSummaryForStop: Retrieves the routes for a given stop number.
- GetNextTripsForStop: Retrieves next three trips on the route for a given stop number.
- GetNextTripsForStopAllRoutes: Retrieves next three trips for all routes for a given stop number.
- GTFS: Retrieves specific records from all sections of the GTFS file.
Error Codes
Error Code | Error | Methods |
---|---|---|
1 |
Invalid API key |
All |
2 |
Unable to query data source |
|
10 |
Invalid stop number |
GetRouteSummaryForStop GetNextTripsForStop GetNextTripsForStopAllRoutes |
11 |
Invalid route number |
|
12 |
Stop does not service route at this time |
GetNextTripsForStop GetNextTripsForStopAllRoutes |
13 | No routes available at stop at any time |
Vehicle Types
All OC Transpo buses and the O-Train are fully accessible.
Code | Description |
---|---|
4 or 40 | 40-foot buses |
6 or 60 | 60-foot buses |
4 and 6 | trips can be done by 60 or 40-foot buses |
DD | Double-Decker buses |
B | Bike Rack |
DEH | Diesel Electric Hybrid |
IN | INVIRO (bus type) |
ON | ORION (bus type) |
Method Descriptions
1) GetRouteSummaryForStop
Retrieves the routes for a given stop number.
Base URL
https://api.octranspo1.com/v2.0/GetRouteSummaryForStop
Request
https://api.octranspo1.com/v2.0/GetRouteSummaryForStop?appID={appID}&apiKey={apiKey}&stopNo={stopNo}&format={format}
Parameters
-
Parameter Required Description appID Yes Generated in the developer portal after registration. apiKey Yes Generated in the developer portal after registration. stopNo Yes 4-digit stop number found on bus stops. A full list of stops can be found here. format No Format of the returned data. JSON or XML. Default: JSON. Response
Field Descriptions
Field Name Value Type Description StopNo string 4-digit bus stop number. StopDescription string Stop description. Error string Error codes. Refer to the Error Codes section for details. Route - RouteNo string Alpha-numeric route number. Route - DirectionID integer Route direction identifier. Route - Direction string Route direction description. Route - RouteHeading string Route heading. Response Format
XML
Loading...
JSON
{ GetRouteSummaryForStopResult: { StopNo: "string", Error: "string", StopDescription: "string", Routes: { Route: [ { RouteNo: "string", RouteHeading: "string", Direction: "string", DirectionID: integer }, { RouteNo: "string", RouteHeading: "string", Direction: "string", DirectionID: integer } ] } } }
Response Example
XML
JSON
2) GetNextTripsForStop
Retrieves next three trips on the route for a given stop number.
Base URL
https://api.octranspo1.com/v2.0/GetNextTripsForStop
Request
https://api.octranspo1.com/v2.0/GetNextTripsForStop?appID={appID}&apiKey={apiKey}&stopNo={stopNo}&routeNo={routeNo}&format={format}
Parameters
-
Parameter Required Description appID Yes Generated in the developer portal after registration. apiKey Yes Generated in the developer portal after registration. stopNo Yes 4-digit stop number found on bus stops. A full list of stops can be found here. routeNo Yes Bus route number. format No Format of the returned data. JSON or XML. Default: JSON. Response
Field Descriptions
Field Name Value Type Description StopNo string 4-digit bus stop number. StopLabel string Stop description. Error string Error codes. Refer to the Error Codes section for details. RouteDirection - RouteNo string Alpha-numeric route number. RouteDirection - RouteLabel string Route heading. RouteDirection - Direction string Route direction description. RouteDirection - Error string Error codes. Refer to the Error Codes section for details. RouteDirection - RequestProcessingTime string API request time. Trip - Longitude string Longitude. Trip - Latitude string Latitude. Trip - GPSSpeed string This value has been removed from the API and will return a blank string. Trip - TripDestination string Trip heading. Trip - TripStartTime string Trip scheduled start time. Trip - AdjustedScheduleTime string Time until trip is estimated to arrive at stop. Trip - AdjustmentAge string The time since the scheduled was adjusted in whole and fractional minutes. The higher the number the less reliable the AdjustedScheduleTime is. If this value is negative, it indicates that the AdjustedScheduleTime contains the planned scheduled time. Trip - LastTripOfSchedule boolean Last trip of the day. Trip - BusType string Vehicle type. Refer to the Bus Type section for details. Response Format
XML
JSON
Response Example
XML
JSON
3) GetNextTripsForStopAllRoutes
Retrieves next three trips for all routes for a given stop number.
Base URL
https://api.octranspo1.com/v2.0/GetNextTripsForStopAllRoutes
Request
https://api.octranspo1.com/v2.0/GetNextTripsForStopAllRoutes?appID={appID}&apiKey={apiKey}&stopNo={stopNo}&format={format}
Parameters
-
Parameter Required Description appID Yes Generated in the developer portal after registration. apiKey Yes Generated in the developer portal after registration. stopNo Yes 4-digit stop number found on bus stops. A full list of stops can be found here. format No Format of the returned data. JSON or XML. Default: JSON. Response
Field Descriptions
Field Name Value Type Description StopNo string 4-digit bus stop number. StopDescription string Stop description. Error string Error codes. Refer to the Error Codes section for details. Route - RouteNo string Alpha-numeric route number. Route - RouteHeading string Route heading. Route - DirectionID integer Route direction identifier. Route - Direction string Route direction description. Trip - Longitude string Longitude. Trip - Latitude string Latitude. Trip - GPSSpeed string This value has been removed from the API and will return a blank string. Trip - TripDestination string Trip heading. Trip - TripStartTime string Trip scheduled start time. Trip - AdjustedScheduleTime string Time until trip is estimated to arrive at stop. Trip - AdjustmentAge string The time since the scheduled was adjusted in whole and fractional minutes. The higher the number the less reliable the AdjustedScheduleTime is. If this value is negative, it indicates that the AdjustedScheduleTime contains the planned scheduled time. Trip - LastTripOfSchedule boolean Last trip of the day. Trip - BusType string Vehicle type. Refer to the Bus Type section for details. Response Format
XML
JSON
Response Example
XML
JSON
4) GTFS
Retrieves specific records from all sections of the GTFS file.
Base URL
https://api.octranspo1.com/v2.0/Gtfs
Request
https://api.octranspo1.com/v2.0/Gtfs?appID={appID}&apiKey={apiKey}&table={table}&id={id}&column={column}&value={value}&order_by={order_by}&direction={direction}&limit={limit}&format={format}
Parameters
-
Parameter Required Description appID Yes Generated in the developer portal after registration. apiKey Yes Generated in the developer portal after registration. table Yes The table to query (Tables Listed Below). id No A specific row in a table by the id value. column No A specific column in a table. The use of column requires the use of the value parameter (Columns listed below). value No* A specific value in a column. *Required if column is specified. order_by No Specify a column to sort by. direction No Specify the direction of sorted records. asc or desc. Default asc. limit No Specify a maximum limit of returned records.
format.
format No Format of the returned data. JSON or XML. Default: JSON. GTFS Query: Tables and Columns
Table | Columns | JSON |
---|---|---|
agency |
|
{ "Query": { "table": "agency", "direction": "ASC", "column": "id", "value": "1", "format": "json" }, "Gtfs": [ { "id": "1", "agency_name": "OC Transpo-a", "agency_url": "http:\/\/www.octranspo.com", "agency_timezone": "America\/Montreal", "agency_lang": "en" } ] } |
calendar |
|
{ "Query": { "table": "calendar", "direction": "ASC", "column": "id", "value": "1", "format": "json" }, "Gtfs": [ { "id": "1", "service_id": "JUN26-JUNDA13-Weekday-01", "monday": "1", "tuesday": "1", "wednesday": "1", "thursday": "1", "friday": "1", "saturday": "0", "sunday": "0", "start_date": "20130626", "end_date": "20130627" } ] } |
calendar_dates |
|
{ "Query": { "table": "calendar_dates", "direction": "ASC", "column": "id", "value": "1", "format": "json" }, "Gtfs": [ { "id": "1", "service_id": "JUN13-JUNDA13-Weekday-99", "date": "20130701", "exception_type": "2" } ] } |
routes |
|
{ "Query": { "table": "routes", "direction": "ASC", "column": "id", "value": "1", "format": "json" }, "Gtfs": [ { "id": "1", "route_id": "1-146", "route_short_name": "1", "route_long_name": "", "route_desc": "", "route_type": "3" } ] } |
stops |
|
{ "Query": { "table": "stops", "direction": "ASC", "column": "stop_id", "value": "AA010", "format": "json" }, "Gtfs": [ { "id": "1", "stop_id": "AA010", "stop_code": "8767", "stop_name": "SUSSEX \/ CHUTE RIDEAU FALLS", "stop_desc": "", "stop_lat": "45.4399", "stop_lon": "-75.6958", "stop_street": "", "stop_city": "", "stop_region": "", "stop_postcode": "", "stop_country": "", "zone_id": "" } ] } |
NOTE: stops table requires stop_id, stop_code or id values specified. | ||
stop_times |
|
{ "Query": { "table": "stop_times", "direction": "ASC", "column": "stop_id", "value": "AA010", "format": "json" }, "Gtfs": [ { "id": "133436", "trip_id": "27212870-CADA13-CADA13-Sunday-71", "arrival_time": "08:29:00", "departure_time": "08:29:00", "stop_id": "AA010", "stop_sequence": "20", "pickup_type": "0", "drop_off_type": "0" } ] } |
NOTE: stop_times table requires trip_id, stop_id or id values specified. | ||
trips |
|
{ "Query": { "table": "trips", "direction": "ASC", "column": "route_id", "value": "135-147", "format": "json" }, "Gtfs": [ { "id": "1", "route_id": "135-147", "service_id": "CADA13-CADA13-Sunday-71", "trip_id": "27210104-CADA13-CADA13-Sunday-71", "trip_headsign": "Esprit", "block_id": "3406628" } ] } |
NOTE: trips table requires route_id or id values specified. |
XML Format Description
Loading...