[hackpgh-discuss] Re: Bus stop API

  • From: Derrick Brashear <shadow@xxxxxxxxx>
  • To: hackpgh-discuss@xxxxxxxxxxxxx
  • Date: Tue, 12 Oct 2010 18:01:12 -0400

Now that you stand a chance of getting my email:
1) you can get the full Port Authority GTFS feed directly from them.
2) there is no "real time" component. So, that's schedule data. Nothing else.
3) If you're interested in tools, I can tell you about many of them; I
can probably do a Friday talk about the state of the art; and I can
hook you up with a number of locals who are interested in such things.

On Tue, Oct 12, 2010 at 4:26 PM, Matthew Beckler <matthew@xxxxxxxxxxxx> wrote:
> I know that someone mentioned that we have a bus stop sign hanging out
> in the shop, with the grand idea to have it light up or otherwise
> indicate when a bus is coming soon. I suppose the first step towards
> that is figuring out how to get that data, so this afternoon I took a
> snack break and got something working.
>
> There is a website called RouteShout that parses the General Transit
> Feed Spec (GTFS)[0] feed that transit agencies publish so Google can
> provide transit info on google maps. RouteShout provides an easy and
> useful web API around that data (http://www.routeshout.com/main/api)
> that is pretty slick.
>
> I registered for an API key, and wrote a chunk of python to do what we
> need. There is lots of info available, but all we really need to do is
> to "Get a list of upcoming stops for a specific agency and stop (within
> next 2 hours)". For my key, the PA, and the HackPGH bus stop on
> Jumonville at Watson, this is the url to fetch:
>
> http://api.routeshout.com/rs.stops.getTimes
> ?key=361099f484000362836fca4cc320085d
> &agency=paac
> &stop=E33040
>
> The API call returns a "webpage" that looks something like this,
> slightly trimmed:
> {
>    "response": {
>            "timezone": "America/New_York",
>            "times": [
>                {
>                    "type": "scheduled",
>                    "arrival_time": "03:49 PM",
>                    "departure_time": "03:49 PM",
>                    "route_short_name": "71D",
>                    "route_long_name": "HAMILTON - VIA
> OAKLAND-SHADYSIDE-5TH AV - OR"
>                },
>                {
>                    "type":"scheduled",
>                    "arrival_time":"03:50 PM",
>                    "departure_time":"03:50 PM",
>                    "route_short_name":"71C",
>                    "route_long_name":"POINT BREEZE - VIA
> OAKLAND-SHADYSIDE-CENTRE AV - OR"
>                },
>                ...
>        ]
>        }
>        "status": "ok"
> }
>
> I wrote a little bit of python to fetch and parse this data, giving us
> results like this:
>
> matthew@broderick$ ./get_stop_data.py
> Status: ok
> Timezone: America/New_York
> 04:16 PM
>    71A
>    NEGLEY - VIA OAKLAND-SHADYSIDE-CENTRE AV - OR
> 04:17 PM
>    500
>    HIGHLAND PK - DOWNTOWN-OAKLAND-ZOO - OA
> 04:20 PM
>    71D
>    HAMILTON - VIA OAKLAND-SHADYSIDE-5TH AV - OR
>
> Seems like this is a good first step towards getting some sort of bus
> alert system going. I'll go ahead and add this information and my script
> to the wiki.
>
> Thanks,
> Matthew
>
> [0] http://code.google.com/transit/spec/transit_feed_specification.html
>
>
>



-- 
Derrick

Other related posts: