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.

?
  1. Follow this link to register:?http://www.octranspo1.com/developers/register
  2. 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.
  3. For security purposes, you will be asked for your Application ID and API key with each request.

Description of Methods

The OC Transpo API is RESTful and must be queried with HTTP POST request. The API includes the following methods:

  • GetRouteSummaryForStop:?Retrieves the routes for a given stop number.
  • GetNextTripsForStop:?Retrieves next three trips on the route for a given stop number.

GetRouteSummaryForStop

Retrieves the routes for a given stop number

URL: https://api.octranspo1.com/v1.1/GetRouteSummaryForStop

Parameters:

Usage:

curl -d "appID={appID}&apiKey={apiKey}&stopNo=7659" 
 https://api.octranspo1.com/v1.1/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.1/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>int</RouteNo>
						<DirectionID>int</DirectionID>
						<Direction>string</Direction>
						<RouteHeading>string</RouteHeading>
					</Route>
					<Route>
						<RouteNo>int</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>int</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 3017.


<?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/">BASELINE</StopDescription>
			<Error xmlns="http://tempuri.org/" />
			<Routes xmlns="http://tempuri.org/">
				<Route>
					<RouteNo>57</RouteNo>
					<DirectionId>0</DirectionId>
					<Direction>Inbound</Direction>
					<RouteHeading>Downtown / centre-ville</RouteHeading>
				</Route>
				<Route>
					<RouteNo>57</RouteNo>
					<DirectionId>1</DirectionId>
					<Direction>Outbound</Direction>
					<RouteHeading>Baseline</RouteHeading>
				</Route>
				<Route>
					<RouteNo>70</RouteNo>
					<DirectionId>0</DirectionId>
					<Direction>Inbound</Direction>
					<RouteHeading>Downtown / centre-ville</RouteHeading>
				</Route>
				<Route>
					<RouteNo>70</RouteNo>
					<DirectionId>1</DirectionId>
					<Direction>Outbound</Direction>
					<RouteHeading>Barrhaven</RouteHeading>
				</Route>
				<Route>
					<RouteNo>71</RouteNo>
					<DirectionId>0</DirectionId>
					<Direction>Inbound</Direction>
					<RouteHeading>Downtown / Centre-ville</RouteHeading>
				</Route>
				<Route>
					<RouteNo>71</RouteNo>
					<DirectionId>1</DirectionId>
					<Direction>Outbound</Direction>
					<RouteHeading>Barrhaven</RouteHeading>
				</Route>
				<Route>
					<RouteNo>73</RouteNo>
					<DirectionId>0</DirectionId>
					<Direction>Inbound</Direction>
					<RouteHeading>Downtown / centre-ville</RouteHeading>
				</Route>
				<Route>
					<RouteNo>73</RouteNo>
					<DirectionId>1</DirectionId>
					<Direction>Outbound</Direction>
					<RouteHeading>Barrhaven</RouteHeading>
				</Route>
				<Route>
					<RouteNo>76</RouteNo>
					<DirectionId>0</DirectionId>
					<Direction>Inbound</Direction>
					<RouteHeading>Downtown / centre-ville</RouteHeading>
				</Route>
				<Route>
					<RouteNo>76</RouteNo>
					<DirectionId>1</DirectionId>
					<Direction>Outbound</Direction>
					<RouteHeading>Barrhaven</RouteHeading>
				</Route>
				<Route>
					<RouteNo>77</RouteNo>
					<DirectionId>0</DirectionId>
					<Direction>Inbound</Direction>
					<RouteHeading>Downtown / centre-ville</RouteHeading>
				</Route>
			</Routes>
			</GetRouteSummaryForStopResult>
		</GetRouteSummaryForStopResponse>
	</soap:Body>
</soap:Envelope>

GetNextTripsForStop

Retrieves next three trips on the route for a given stop number

URL: https://api.octranspo1.com/v1.1/GetNextTripsForStop

Parameters:

  • appID: Required.??Generated in the developer portal after registration.
  • apiKey: Required. Generated in the developer portal after registration.
  • routeNo: Required. Bus route number.
  • stopNo: Requited. 4-digit stop number found on bus stops. A full list of stops can be downloaded here: http://ottawa.ca/online_services/opendata/info/transit_schedule_en.html

Usage:

curl -d "appID={appID}&apiKey={apiKey}&routeNo=1&stopNo=7659" 
 https://api.octranspo1.com/v1.1/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>int</RouteNo>
						<DirectionID>int</DirectionID>
						<Direction>string</Direction>
						<RouteHeading>string</RouteHeading>
					</Route>
					<Route>
						<RouteNo>int</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>int</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-->
			<Route>int</Route>
			<!--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-- >
					<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>
<!--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>

<?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/">BASELINE</StopLabel>
	<Error xmlns="http://tempuri.org/" />
	<Route xmlns="http://tempuri.org/">
		<RouteDirection>
			<RouteNo>95</RouteNo>
			<RouteLabel>Orl?ans</RouteLabel>
			<Direction>Eastbound</Direction>
			<Error />
			<RequestProcessingTime>20120213151218</RequestProcessingTime>
			<Trips>
				<Trip>
					<TripDestination>Trim</TripDestination>
					<TripStartTime>14:59</TripStartTime>
					<AdjustedScheduleTime>2</AdjustedScheduleTime>
					<AdjustmentAge>0.53</AdjustmentAge>
					<LastTripOfSchedule>false</LastTripOfSchedule>
					<BusType>6E - 60</BusType>
					<GPSSpeed>46.68</GPSSpeed>
					<Latitude>45.372693</Latitude>
					<Longitude>-75.734738</Longitude>
				</Trip>
				<Trip>
					<TripDestination>Place d'Orl?ans</TripDestination>
					<TripStartTime>15:22</TripStartTime>
					<AdjustedScheduleTime>10</AdjustedScheduleTime>
					<AdjustmentAge>-1</AdjustmentAge>
					<LastTripOfSchedule>false</LastTripOfSchedule>
					<BusType>6E - 60</BusType>
					<Speed>46.68</Speed>
					<Latitude>45.372693</Latitude>
					<Longitude>-75.734738</Longitude>
				</Trip>
				<Trip>
					<TripDestination>Trim</TripDestination>
					<TripStartTime>15:09</TripStartTime>
					<AdjustedScheduleTime>16</AdjustedScheduleTime>
					<AdjustmentAge>0.73</AdjustmentAge>
					<LastTripOfSchedule>false</LastTripOfSchedule>
					<BusType>6E - 60</BusType>
					<GPSSpeed>46.68</GPSSpeed>
					<Latitude>45.372693</Latitude>
					<Longitude>-75.734738</Longitude>
				</Trip>
			</Trips>
		</RouteDirection>
		<RouteDirection>
			<RouteNo>95</RouteNo>
			<RouteLabel>Barrhaven Centre</RouteLabel>
			<Direction>Westbound</Direction>
			<Error />
			<RequestProcessingTime>20120213151218</RequestProcessingTime>
			<Trips>
				<Trip>
					<TripDestination>Barrhaven Centre</TripDestination>
					<TripStartTime>14:25</TripStartTime>
					<AdjustedScheduleTime>7</AdjustedScheduleTime>
					<AdjustmentAge>0.67</AdjustmentAge>
					<LastTripOfSchedule>false</LastTripOfSchedule>
					<BusType>6E - 60</BusType>
					<GPSSpeed>46.68</GPSSpeed>
					<Latitude>45.372693</Latitude>
					<Longitude>-75.734738</Longitude>
				</Trip>
				<Trip>
					<TripDestination>Barrhaven Centre</TripDestination>
					<TripStartTime>14:55</TripStartTime>
					<AdjustedScheduleTime>9</AdjustedScheduleTime>
					<AdjustmentAge>0.55</AdjustmentAge>
					<LastTripOfSchedule>false</LastTripOfSchedule>
					<BusType>6E - 60</BusType>
					<Speed>46.68</Speed>
					<Latitude>45.372693</Latitude>
					<Longitude>-75.734738</Longitude>
				</Trip>
				<Trip>
					<TripDestination>Barrhaven Centre</TripDestination>
					<TripStartTime>14:35</TripStartTime>
					<AdjustedScheduleTime>18</AdjustedScheduleTime>
					<AdjustmentAge>0.82</AdjustmentAge>
					<LastTripOfSchedule>false</LastTripOfSchedule>
					<BusType>6E - 60</BusType>
					<GPSSpeed>46.68</GPSSpeed>
					<Latitude>45.372693</Latitude>
					<Longitude>-75.734738</Longitude>
				</Trip>
			</Trips>
		</RouteDirection>
	</Route>
</GetNextTripsForStopResult>
</GetNextTripsForStopResponse>
</soap:Body>
</soap:Envelope>

E-mail this page

PRESTO