Difference between revisions of "Charlottetown Transit API"

From rukapedia
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 117: Line 117:
 
==Schedule==
 
==Schedule==
  
Returns information on the scheuled service at single stop in a given Charlottetown Transit route.
+
Returns information on the scheduled service at single stop in a given Charlottetown Transit route.
  
 
{| border="1" cellpadding="5" cellspacing="0"
 
{| border="1" cellpadding="5" cellspacing="0"
Line 137: Line 137:
  
 
<pre>
 
<pre>
# curl http://thebus.ca/api/route/1/stop/12
+
# http://thebus.ca/api/route/1/stop/1/schedule?after=17:00&limit=1&direction=O
  
 
<?xml version="1.0"?>
 
<?xml version="1.0"?>
<stops>
+
<schedule>
   <stop>
+
   <service>
       <number>12</number>
+
      <time>17:10:00</time>
       <name>Richmond and Queen</name>
+
      <direction>O</direction>
       <latitude>46.233454</latitude>
+
  </service>
       <longitude>-63.127044</longitude>
+
</schedule>
   </stop>
+
</pre>
</stops>
+
 
 +
<pre>
 +
# http://thebus.ca/api/route/1/stop/1/schedule?limit=2&direction=O
 +
 
 +
<?xml version="1.0"?>
 +
<schedule>
 +
  <service>
 +
       <time>06:45:00</time>
 +
       <direction>O</direction>
 +
  </service>
 +
  <service>
 +
       <time>07:04:00</time>
 +
       <direction>O</direction>
 +
   </service>
 +
</schedule>
 
</pre>
 
</pre>

Latest revision as of 18:33, 2 September 2008

This document describes a RESTful API that provides access to the same stop, route and schedule information that is used to power the Charlottetown Interactive Transit Map.

Routes

Returns information on Charlottetown Transit routes.

URL /api/routes
Method GET
Querystring None
Returns XML

Example

# curl http://thebus.ca/api/routes

<?xml version="1.0"?>
<routes>
   <route>
      <number>1</number>
      <name>University Ave. Express</name>
      <markercolour>yellow</markercolour>
      <routecolour>ff0000</routecolour>
      <lightcolour>ff847f</lightcolour>
      <note/>
   </route>
</routes>

Stops

Returns information on the stops in a given Charlottetown Transit route.

URL /api/route/[routenumber]/stops
Method GET
Querystring None
Returns XML

Example

# curl http://thebus.ca/api/route/1/stops

<?xml version="1.0"?>
<stops>
   <stop>
      <number>1</number>
      <name>Confederation Centre</name>
      <latitude>46.234307</latitude>
      <longitude>-63.128021</longitude>
   </stop>
   ...
   <stop>
      <number>12</number>
      <name>Richmond and Queen</name>
      <latitude>46.233454</latitude>
      <longitude>-63.127044</longitude>
   </stop>
</stops>

Single Stop

Returns information on a single stop in a given Charlottetown Transit route.

URL /api/route/[routenumber]/stop/[stopnumber]
Method GET
Querystring None
Returns XML

Example

# curl http://thebus.ca/api/route/1/stop/12

<?xml version="1.0"?>
<stops>
   <stop>
      <number>12</number>
      <name>Richmond and Queen</name>
      <latitude>46.233454</latitude>
      <longitude>-63.127044</longitude>
   </stop>
</stops>

Schedule

Returns information on the scheduled service at single stop in a given Charlottetown Transit route.

URL /api/route/[routenumber]/stop/[stopnumber]/schedule
Method GET
Querystring after HH:MM (only show service after the given time; use 24hr clock)
direction O or I (only show Outbound or Inbound service)
limit integer (limit results to given number)
Returns XML

Example

# http://thebus.ca/api/route/1/stop/1/schedule?after=17:00&limit=1&direction=O

<?xml version="1.0"?>
<schedule>
   <service>
      <time>17:10:00</time>
      <direction>O</direction>
   </service>
</schedule>
# http://thebus.ca/api/route/1/stop/1/schedule?limit=2&direction=O

<?xml version="1.0"?>
<schedule>
   <service>
      <time>06:45:00</time>
      <direction>O</direction>
   </service>
   <service>
      <time>07:04:00</time>
      <direction>O</direction>
   </service>
</schedule>