Realtime API Examples

Miscellaneous Examples

Here is a list of commands that you might use to build an application. This should give you a good idea of how the interface has been designed.

Command Description

http://api.metro.net/agencies/lametro/routes/

Get all routes for LAMETRO (JSON)

http://api.metro.net/agencies/lametro/routes/704/

Get all the stops for route 704 (JSON)

http://api.metro.net/agencies/lametro/routes/704/xml/
Get all the stops for route 704 (XML)

http://api.metro.net/agencies/ lametro/routes/704/stops/callback=doList
Get all the stops for route 704 (JSON-P with callback “doList”)

http://api.metro.net/agencies/ lametro/stops/6033/predictions/
Get the current arrival predictions for stop 6033 (JSON)

http://api.metro.net/agencies/ lametro/stops/6033/messages/
Get messages for stop 6033 (JSON)

http://api.metro.net/agencies/lametro/routes/704/info/xml/
Get stop and sequence information for route 704 (XML)

http://api.metro.net/agencies/ lametro/routes/704/sequence/
Get all the stops for route 704 in sequence (good for drawing route maps)

http://api.metro.net/agencies/lametro/routes/704/runs/xml/
Get the runs for route 704 (XML)

http://api.metro.net/agencies/lametro/routes/704/vehicles/
Get all the Metro vehicles now running on route 704

3 thoughts on “Realtime API Examples

  1. Hi,
    I have a couple of questions/comments.

    1. I am trying to organize stop predictions for specific route+direction combinations. http://api.metro.net/agencies/lametro/stops/16304/predictions/ is returning an item with e.g. {“run_id”: “4_157_1″, “route_id”: “4″}. However, when I subsequently call http://api.metro.net/agencies/lametro/routes/4/runs/ to learn more about run 4_157_1, I only receive {“items”: [{"route_id": "4_159_1", "display_name": "West to Santa Monica", "id": "4_159_1", "display_in_ui": true, "direction_name": "West"}, {"route_id": "4_165_0", "display_name": "East to Downtown LA - Broadway-Venice", "id": "4_165_0", "display_in_ui": true, "direction_name": "East"}]}. Why doesn’t run 4_157_1 appear in this list?

    2. http://api.metro.net/agencies/lametro/routes/4/runs/ returns as an item, e.g. {“route_id”: “4_159_1″, “id”: “4_159_1″, ..}. Shouldn’t “route_id” be “4″, not “4_159_1″?

    3. Are run_id’s meant to map to trips in the GTFS data feed? They don’t seem to have matching IDs.

    4. The XML version appears to be returning 500 Server Errors. E.g. http://api.metro.net/agencies/lametro/routes/704/runs/xml/ . This has been occurring for at least two weeks now.

    Thanks for your assistance!

    • Hi Jasonshah,

      These are good questions. I can confirm the problem you are seeing on questions 1 & 2. I’ll need to check with the Nextrip developers to give you a good answer.

      3. You should be able to find those run_ids in the GTFS. Are you looking at the most recent data?

      4. There is little demand for the XML feed and it has languished since I upgraded the server. Do you require it for your application?

      I will also look into giving more meaningful errors too. 50x errors aren’t very helpful!

      Thanks,
      -Doug

Leave a Reply