Developer Documentation
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.
Register as a developer to receive an API keyDeveloper sign-in
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.
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...
1) GetRouteSummaryForStop
Retrieves the routes for a given stop number
URL: https://api.octranspo1.com/v1.3/GetRouteSummaryForStop
Parameters:
- appID
- Required. Generated in the developer portal after registration.
- apiKey
- Required. Generated in the developer portal after registration.
- stopNo
- Required. 4-digit stop number found on bus stops. A full list of stops can be downloaded here: http://data.ottawa.ca/dataset/oc-transpo-schedules
- routeNo
- Required. Required. Bus route number.
- format
- Optional. Format of the returned data. JSON or XML Default: XML
Usage:
curl -d "appID={appID}&apiKey={apiKey}&stopNo=7659" https://api.octranspo1.com/v1.3/GetRouteSummaryForStop
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.
POST /v1.3/GetRouteSummaryForStop HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: length stopNo=string HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetRouteSummaryForStopResponse xmlns="http://octranspo.com"> <GetRouteSummaryForStopResult> <StopNo xmlns="http://tempuri.org/">string</StopNo> <StopDescription xmlns="http://tempuri.org/">string</StopDescription> <Error xmlns="http://tempuri.org/">string</Error> <Routes xmlns="http://tempuri.org/"> <Route> <RouteNo>string</RouteNo> <DirectionID>int</DirectionID> <Direction>string</Direction> <RouteHeading>string</RouteHeading> </Route> <Route> <RouteNo>string</RouteNo> <DirectionID>int</DirectionID> <Direction>string</Direction> <RouteHeading>string</RouteHeading> </Route> </Routes> </GetRouteSummaryForStopResult> </GetRouteSummaryForStopResponse> </soap:Body> </soap:Envelope>
Bus Type Formats
Here is the list of bus types with different letters: 4,6,40,60,DD, E,EA, A, L, B, DEH
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
E, L, A, EA means low-floor Easy Access
B = Bike Rack
DEH = Diesel Electric Hybrid
IN = INVIRO (bus type)
ON = ORION (bus type)
Adjustment Age
AdjustmentAge indicates the last time (in minutes and adjusted in whole and fractional minutes) when the GPS data available for the bus was used to determine the AdjustedScheduleTime. The higher the number the less reliable the AdjustedScheduleTime is.
If the AdjustmentAge is a negative value, it indicates that the AdjustedScheduleTime contains the planned scheduled time.
Possible Error codes for: <Error>string</Error>
Error Note 1 Invalid API key 2 Unable to query data source 10 Invalid stop number 11 Invalid route number 12 Stop does not service route
XML Format Description
<!--Response to the web method GetRouteSummaryForStop--> <RoutesForStopData> <!--Errors if any for the request made.--> <Error>string</Error> <RouteSummaryData> <!--Route number--> <RouteNo>string</RouteNo> <Directions> <!--First direction--> <DirectionData> <!--Direction identifier. e.g. 0 = Eastbound, 1 = WestBound--> <DirectionId>int</DirectionId> <!--The route & direction heading--> <RouteHeading>string</RouteHeading> <!--Direction description e.g. Inbound / Outbound--> <DirDescription>string</DirDescription> </DirectionData> <!--Second direction--> <DirectionData> <!--Direction identifier. e.g. 0 = Eastbound, 1 = WestBound--> <DirectionId>int</DirectionId> <!--The route & direction heading--> <RouteHeading>string</RouteHeading> <!--Direction description e.g. Inbound / Outbound--> <DirDescription>string</DirDescription> </DirectionData> </Directions> </RouteSummaryData> </RoutesForStopData>
Sample data for stop 3037.
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetRouteSummaryForStopResponse xmlns="http://octranspo.com"> <GetRouteSummaryForStopResult> <StopNo xmlns="http://tempuri.org/">3017</StopNo> <StopDescription xmlns="http://tempuri.org/">GREENBORO STATION</StopDescription> <Error xmlns="http://tempuri.org/" /> <Routes xmlns="http://tempuri.org/"> <Route> <RouteNo>2</RouteNo> <DirectionId>0</DirectionId> <Direction>Northbound</Direction> <RouteHeading>Bayview</RouteHeading> </Route> <Route> <RouteNo>2</RouteNo> <DirectionId>1</DirectionId> <Direction>Southbound</Direction> <RouteHeading>Greenboro</RouteHeading> </Route> <Route> <RouteNo>R2</RouteNo> <DirectionId>0</DirectionId> <Direction>Northbound</Direction> <RouteHeading>Bayview</RouteHeading> </Route> <Route> <RouteNo>R2</RouteNo> <DirectionId>1</DirectionId> <Direction>Southbound</Direction> <RouteHeading>Greenboro</RouteHeading> </Route> <Route> <RouteNo>6</RouteNo> <DirectionId>0</DirectionId> <Direction>Southbound</Direction> <RouteHeading>Greenboro</RouteHeading> </Route> <Route> <RouteNo>6</RouteNo> <DirectionId>1</DirectionId> <Direction>Northbound</Direction> <RouteHeading>Rockcliffe</RouteHeading> </Route> <Route> <RouteNo>40</RouteNo> <DirectionId>0</DirectionId> <Direction>Northbound</Direction> <RouteHeading>St-Laurent</RouteHeading> </Route> <Route> <RouteNo>40</RouteNo> <DirectionId>1</DirectionId> <Direction>Southbound</Direction> <RouteHeading>Greenboro</RouteHeading> </Route> <Route> <RouteNo>87</RouteNo> <DirectionId>0</DirectionId> <Direction>Southbound</Direction> <RouteHeading>Greenboro</RouteHeading> </Route> <Route> <RouteNo>87</RouteNo> <DirectionId>1</DirectionId> <Direction>Northbound</Direction> <RouteHeading>Baseline</RouteHeading> </Route> <Route> <RouteNo>92</RouteNo> <DirectionId>0</DirectionId> <Direction>Southbound</Direction> <RouteHeading>Greenboro</RouteHeading> </Route> <Route> <RouteNo>92</RouteNo> <DirectionId>1</DirectionId> <Direction>Northbound</Direction> <RouteHeading>Hurdman</RouteHeading> </Route> </Routes> </GetRouteSummaryForStopResult> </GetRouteSummaryForStopResponse> </soap:Body> </soap:Envelope>
2) GetNextTripsForStop
Retrieves next three trips on the route for a given stop number
URL: https://api.octranspo1.com/v1.3/GetNextTripsForStop
Parameters:
- appID
- Required. Generated in the developer portal after registration.
- apiKey
- Required. Generated in the developer portal after registration.
- stopNo
- Required. 4-digit stop number found on bus stops. A full list of stops can be downloaded here: http://data.ottawa.ca/dataset/oc-transpo-schedules
- routeNo
- Required. Required. Bus route number.
- format
- Optional. Format of the returned data. JSON or XML Default: XML
Usage:
curl -d "appID={appID}&apiKey={apiKey}&routeNo=1&stopNo=7659" https://api.octranspo1.com/v1.3/GetNextTripsForStop
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetRouteSummaryForStopResponse xmlns="http://octranspo.com"> <GetRouteSummaryForStopResult> <StopNo xmlns="http://tempuri.org/">string</StopNo> <StopDescription xmlns="http://tempuri.org/">string</StopDescription> <Error xmlns="http://tempuri.org/">string</Error> <Routes xmlns="http://tempuri.org/"> <Route> <RouteNo>string</RouteNo> <DirectionID>int</DirectionID> <Direction>string</Direction> <RouteHeading>string</RouteHeading> </Route> <Route> <RouteNo>string</RouteNo> <DirectionID>int</DirectionID> <Direction>string</Direction> <RouteHeading>string</RouteHeading> </Route> </Routes> </GetRouteSummaryForStopResult> </GetRouteSummaryForStopResponse> </soap:Body> </soap:Envelope>
Possible Error codes for <Error>:
Error Note 2 Unable to query data source
XML Format Description
<!--Retrieve the next 3 trips for a specific route in a specific direction to pass by the stop. The following is a sample request and response. The placeholders shown need to be replaced with actual values.--> <!--Response--> <StopInfo> <!--4 digit stop number--> <StopNo>string</StopNo> <!--Stop description--> <StopLabel>string</StopLabel> <!--Errors if any while generating data the stop. i.e. Invalid stop number--> <Error>string</Error> <Routes> <Route> <!--Route number--> <routeNo>string</routeNo> <!--Route description--> <RouteLabel>string</RouteLabel> <!--Trip direction i.e. NorthBound/SouthBound--> <Direction>string</Direction> <!--Errors if any while generating data the route. i.e. Route does not pass the stop specified--> <Error>string</Error> <!--Time the request was processed. This will be using the format 'YYYYMMDDHHMISS' where HH = 24 hour format--> <RequestProcessingTime>string</RequestProcessingTime> <Trips> <!--First Trip--> <Trip> <!--Final stop on the trip--> <TripDestination>string</TripDestination> <!--start time for the trip. Format HH:MI, where HH = 24 hour format--> <TripStartTime>string</TripStartTime> <!--adjusted scheduled time in minutes--> <AdjustedScheduleTime>string</AdjustedScheduleTime> <!--The time since the scheduled was adjusted in whole and fractional minutes. --> <AdjustmentAge>string</AdjustmentAge> <!--last trip to pass the stop for the route & direction--> <LastTripOfSchedule>boolean</LastTripOfSchedule> <!--type of bus : low floor, bike rack etc.--> <BusType>string</BusType> <!--speed of the bus in km/hr-- > <GPSSpeed>int</GPSSpeed> <!--Latitude of the last gps reading for the bus--> <Latitude></Latitude> <!--Longitude of the last gps reading for the bus--> <Longitude></Longitude> </Trip> <!--Second Trip--> <Trip> <!--Final stop on the trip--> <TripDestination>string</TripDestination> <!--start time for the trip--> <TripStartTime>string</TripStartTime> <!--adjusted scheduled time in minutes--> <AdjustedScheduleTime>string</AdjustedScheduleTime> <!--The time since the scheduled was adjusted in whole and fractional minutes--> <AdjustmentAge>string</AdjustmentAge> <!--last trip to pass the stop for the route & direction--> <LastTripOfSchedule>boolean</LastTripOfSchedule> <!--type of bus : low floor, bike rack etc.--> <BusType>string</BusType> <!--speed of the bus in km/hr-- > <GPSSpeed>int</GPSSpeed> <!--Latitude of the last gps reading for the bus--> <Latitude></Latitude> <!--Longitude of the last gps reading for the bus--> <Longitude></Longitude> </Trip> <!--Third Trip--> <Trip> <!--Final stop on the trip--> <TripDestination>string</TripDestination> <!--start time for the trip--> <TripStartTime>string</TripStartTime> <!--adjusted scheduled time in minutes--> <AdjustedScheduleTime>string</AdjustedScheduleTime> <!--The time since the scheduled was adjusted in whole and fractional minutes--> <AdjustmentAge>string</AdjustmentAge> <!--last trip to pass the stop for the route & direction--> <LastTripOfSchedule>boolean</LastTripOfSchedule> <!--type of bus : low floor, bike rack etc.--> <BusType>string</BusType> <!--speed of the bus in km/hr-- > < GPSSpeed >int</ GPSSpeed > <!--Latitude of the last gps reading for the bus--> <Latitude></Latitude> <!--Longitude of the last gps reading for the bus--> <Longitude></Longitude> </Trip> </Trips> </Route> </Routes> </StopInfo>
Sample data for route 97 at stop 3037.
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetNextTripsForStopResponse xmlns="http://octranspo.com"> <GetNextTripsForStopResult> <StopNo xmlns="http://tempuri.org/">3017</StopNo> <StopLabel xmlns="http://tempuri.org/">GREENBORO STATION</StopLabel> <Error xmlns="http://tempuri.org/" /> <Route xmlns="http://tempuri.org/"> <RouteDirection> <RouteNo>97</RouteNo> <RouteLabel>Airport / Aéroport</RouteLabel> <Direction>Eastbound</Direction> <Error /> <RequestProcessingTime>20190128143405</RequestProcessingTime> <Trips> <Trip> <TripDestination>Airport / Aéroport</TripDestination> <TripStartTime>13:59</TripStartTime> <AdjustedScheduleTime>2</AdjustedScheduleTime> <AdjustmentAge>0.55</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>4LA - DD</BusType> <Latitude>45.369028</Latitude> <Longitude>-75.667496</Longitude> <GPSSpeed>22.4</GPSSpeed> </Trip> <Trip> <TripDestination>South Keys</TripDestination> <TripStartTime>13:47</TripStartTime> <AdjustedScheduleTime>9</AdjustedScheduleTime> <AdjustmentAge>0.71</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>6EB - 60</BusType> <Latitude>45.406349</Latitude> <Longitude>-75.664368</Longitude> <Speed>29.1</Speed> </Trip> <Trip> <TripDestination>Airport / Aéroport</TripDestination> <TripStartTime>14:14</TripStartTime> <AdjustedScheduleTime>20</AdjustedScheduleTime> <AdjustmentAge>0.40</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>6LB - 60</BusType> <Latitude>45.424393</Latitude> <Longitude>-75.686963</Longitude> <GPSSpeed>28.0</GPSSpeed> </Trip> </Trips> </RouteDirection> <RouteDirection> <RouteNo>97</RouteNo> <RouteLabel>Bells Corners</RouteLabel> <Direction>Westbound</Direction> <Error /> <RequestProcessingTime>20190128143405</RequestProcessingTime> <Trips> <Trip> <TripDestination>Bayshore</TripDestination> <TripStartTime>14:31</TripStartTime> <AdjustedScheduleTime>4</AdjustedScheduleTime> <AdjustmentAge>0.48</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>6EB - 60</BusType> <Latitude>45.332706</Latitude> <Longitude>-75.651175</Longitude> <GPSSpeed>80.8</GPSSpeed> </Trip> <Trip> <TripDestination>Bells Corners</TripDestination> <TripStartTime>14:44</TripStartTime> <AdjustedScheduleTime>12</AdjustedScheduleTime> <AdjustmentAge>0.50</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>6EB - 60</BusType> <Latitude>45.349821</Latitude> <Longitude>-75.652247</Longitude> <Speed>0.5</Speed> </Trip> <Trip> <TripDestination>Bayshore</TripDestination> <TripStartTime>14:50</TripStartTime> <AdjustedScheduleTime>23</AdjustedScheduleTime> <AdjustmentAge>-1</AdjustmentAge> <LastTripOfSchedule>false</LastTripOfSchedule> <BusType>4LA - DD</BusType> <Latitude></Latitude> <Longitude></Longitude> <GPSSpeed></GPSSpeed> </Trip> </Trips> </RouteDirection> </Route> </GetNextTripsForStopResult> </GetNextTripsForStopResponse> </soap:Body> </soap:Envelope>
3) GetNextTripsForStopAllRoutes
Retrieves next three trips for all routes for a given stop number.
URL: https://api.octranspo1.com/v1.3/GetNextTripsForStopAllRoutes
Parameters:
- appID
- Required. Generated in the developer portal after registration.
- apiKey
- Required. Generated in the developer portal after registration.
- stopNo
- Required. 4-digit stop number found on bus stops. A full list of stops can be downloaded here: http://data.ottawa.ca/dataset/oc-transpo-schedules
- format
- Optional. Format of the returned data. JSON or XML Default: XML
Usage
curl -d "appID={appID}&apiKey={apiKey}&stopNo=7659&format=json" https://api.octranspo1.com/v1.3/GetNextTripsForStopAllRoutes
XML Format Description
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetRouteSummaryForStopResponse xmlns="http://octranspo.com"> <GetRouteSummaryForStopResult> <StopNo xmlns="http://tempuri.org/">string</StopNo> <StopDescription xmlns="http://tempuri.org/">string</StopDescription> <Error xmlns="http://tempuri.org/">string</Error> <Routes xmlns="http://tempuri.org/"> <Route> <RouteNo>string</RouteNo> <DirectionID>int</DirectionID> <Direction>string</Direction> <RouteHeading>string</RouteHeading> <Trips> <!--First Trip--> <Trip> <!--Final stop on the trip--> <TripDestination>string</TripDestination> <!--start time for the trip. Format HH:MI, where HH = 24 hour format--> <TripStartTime>string</TripStartTime> <!--adjusted scheduled time in minutes--> <AdjustedScheduleTime>string</AdjustedScheduleTime> <!--The time since the scheduled was adjusted in whole and fractional minutes. --> <AdjustmentAge>string</AdjustmentAge> <!--last trip to pass the stop for the route & direction--> <LastTripOfSchedule>boolean</LastTripOfSchedule> <!--type of bus : low floor, bike rack etc.--> <BusType>string</BusType> <!--speed of the bus in km/hr-- > <GPSSpeed>int</GPSSpeed> <!--Latitude of the last gps reading for the bus--> <Latitude></Latitude> <!--Longitude of the last gps reading for the bus--> <Longitude></Longitude> </Trip> <!--Second Trip--> <Trip> <!--Final stop on the trip--> <TripDestination>string</TripDestination> <!--start time for the trip--> <TripStartTime>string</TripStartTime> <!--adjusted scheduled time in minutes--> <AdjustedScheduleTime>string</AdjustedScheduleTime> <!--The time since the scheduled was adjusted in whole and fractional minutes--> <AdjustmentAge>string</AdjustmentAge> <!--last trip to pass the stop for the route & direction--> <LastTripOfSchedule>boolean</LastTripOfSchedule> <!--type of bus : low floor, bike rack etc.--> <BusType>string</BusType> <!--speed of the bus in km/hr-- > <SPEED>int</SPEED> <!--Latitude of the last gps reading for the bus--> <Latitude></Latitude> <!--Longitude of the last gps reading for the bus--> <Longitude></Longitude> </Trip> </Trips> </Route> <Route> <RouteNo>string</RouteNo> <DirectionID>int</DirectionID> <Direction>string</Direction> <RouteHeading>string</RouteHeading> <Trips> <!--First Trip--> <Trip> <!--Final stop on the trip--> <TripDestination>string</TripDestination> <!--start time for the trip. Format HH:MI, where HH = 24 hour format--> <TripStartTime>string</TripStartTime> <!--adjusted scheduled time in minutes--> <AdjustedScheduleTime>string</AdjustedScheduleTime> <!--The time since the scheduled was adjusted in whole and fractional minutes. --> <AdjustmentAge>string</AdjustmentAge> <!--last trip to pass the stop for the route & direction--> <LastTripOfSchedule>boolean</LastTripOfSchedule> <!--type of bus : low floor, bike rack etc.--> <BusType>string</BusType> <!--speed of the bus in km/hr-- > <GPSSpeed>int</GPSSpeed> <!--Latitude of the last gps reading for the bus--> <Latitude></Latitude> <!--Longitude of the last gps reading for the bus--> <Longitude></Longitude> </Trip> <!--Second Trip--> <Trip> <!--Final stop on the trip--> <TripDestination>string</TripDestination> <!--start time for the trip--> <TripStartTime>string</TripStartTime> <!--adjusted scheduled time in minutes--> <AdjustedScheduleTime>string</AdjustedScheduleTime> <!--The time since the scheduled was adjusted in whole and fractional minutes--> <AdjustmentAge>string</AdjustmentAge> <!--last trip to pass the stop for the route & direction--> <LastTripOfSchedule>boolean</LastTripOfSchedule> <!--type of bus : low floor, bike rack etc.--> <BusType>string</BusType> <!--speed of the bus in km/hr-- > <SPEED>int</SPEED> <!--Latitude of the last gps reading for the bus--> <Latitude></Latitude> <!--Longitude of the last gps reading for the bus--> <Longitude></Longitude> </Trip> </Trips> </Route> </Routes> </GetRouteSummaryForStopResult> </GetRouteSummaryForStopResponse> </soap:Body> </soap:Envelope>
JSON Example Response
{ "GetRouteSummaryForStopResult": { "StopNo": "7659", "StopDescription": "BANK / FIFTH", "Error": "", "Routes": { "Route": [ { "RouteNo": "6", "DirectionID": 1, "Direction": "Northbound", "RouteHeading": "Rockcliffe", "Trips": [ { "TripDestination": "Rockcliffe", "TripStartTime": "13:37", "AdjustedScheduleTime": "2", "AdjustmentAge": "0.27", "LastTripOfSchedule": false, "BusType": "6EB - 60", "Latitude": "45.396047", "Longitude": "-75.684445", "GPSSpeed": "38.9" }, { "TripDestination": "Rockcliffe", "TripStartTime": "13:52", "AdjustedScheduleTime": "14", "AdjustmentAge": "0.32", "LastTripOfSchedule": false, "BusType": "6EB - 60", "Latitude": "45.378260", "Longitude": "-75.667399", "GPSSpeed": "0.5" }, { "TripDestination": "Rockcliffe", "TripStartTime": "14:07", "AdjustedScheduleTime": "24", "AdjustmentAge": "0.65", "LastTripOfSchedule": false, "BusType": "6EB - 60", "Latitude": "45.351760", "Longitude": "-75.654081", "GPSSpeed": "53.4" } ] }, { "RouteNo": "7", "DirectionID": 1, "Direction": "Eastbound", "RouteHeading": "St-Laurent", "Trips": [ { "TripDestination": "St-Laurent", "TripStartTime": "14:03", "AdjustedScheduleTime": "5", "AdjustmentAge": "0.45", "LastTripOfSchedule": false, "BusType": "4E - DEH", "Latitude": "45.391233", "Longitude": "-75.690734", "GPSSpeed": "35.7" }, { "TripDestination": "St-Laurent", "TripStartTime": "14:18", "AdjustedScheduleTime": "17", "AdjustmentAge": "-1", "LastTripOfSchedule": false, "BusType": "4LA - DEH", "Latitude": "", "Longitude": "", "GPSSpeed": "" }, { "TripDestination": "Brittany", "TripStartTime": "14:30", "AdjustedScheduleTime": "22", "AdjustmentAge": "-1", "LastTripOfSchedule": false, "BusType": "4L - DEH", "Latitude": "", "Longitude": "", "GPSSpeed": "" } ] } ] } } }
4) GTFS
Retrieves specific records from all sections of the GTFS file.
URL: https://api.octranspo1.com/v1.3/Gtfs
Parameters:
- appID
- Required. Generated in the developer portal after registration.
- apiKey
- Required. Generated in the developer portal after registration.
- table
- Required. The table to query. (Tables Listed Below)
- id
- Optional. A specific row in a table by the id value.
- column
- Optional. A specific column in a table. The use of column requires the use of the value parameter. (Columns listed below.)
- value
- Optional*. A specific value in a column. *Required if column is specified.
- order_by
- Optional. Specify a column to sort by.
- direction
- Optional. Specify the direction of sorted records. asc or desc. Default asc.
- limit
- Optional. Specify a maximum limit of returned records.
- format
- Optional. Format of the returned data. json OR xml Default: xml
Usage
curl -d "appID={appID}&apiKey={apiKey}&table=stops&column=stop_id&value=AA010&order_by=stop_code&direction=desc&limit=10&format=json" https://api.octranspo1.com/v1.3/Gtfs
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
<?xml version="1.0"?> <Gtfs> <result id="[ID of record]"> <[Column Name]>[Value]</[Column Name]> <[Column Name With Null Value] /> </result> </Gtfs>