list of stops associated with a bus route number

55 views
Skip to first unread message

Yun Zeng

unread,
Oct 29, 2020, 3:12:07 AM10/29/20
to TransLink Developers
Hello TransLink developer,

I am doing a small web app for school project and I am also learning to use API. 

I try to get a list of stops filtered by a route number but it doesn't work? For example, i want to know all the stop ID associated with route 320 I would send the follow api request with my registered api id. 

https://api.translink.ca/rttiapi/v1/stops?apikey=[myAPIKey]&routeNo=320

this returns status 500.

but if i do something like this:


the returned data doesn't include stop ID but instead pattern information which i cant use to pinpoint on a map.

Any idea how i can get a list of stopNo for a particular bus route so I can get their latitude and longitude info to plot on a map?

Thanks,

Yun Zeng

Dennis Tsang

unread,
Dec 3, 2020, 5:52:21 PM12/3/20
to TransLink Developers
You can find this information in the static GTFS available here: https://developer.translink.ca/ServicesGtfs/GtfsData
The file format specification can be found here: https://developers.google.com/transit/gtfs/reference

It'll probably be easier to import this into a database of sorts to make querying easier, because you'll need to join the following files/tables:
1. First, with the public-facing route number as route_short_name, look up the route_id from routes.txt
2. Using the route_id, look up all the associated trip_ids in trips.txt
3. For each trip_id, look up all the associated stop_id in stop_times.txt
4. Finally for each stop_id, you can look up the stop details (lat, lon, stop code, zone, etc.) from the stops.txt.

Regards,
Dennis

Yun Zeng

unread,
Dec 12, 2020, 2:12:42 AM12/12/20
to TransLink Developers
Dennis,

That's exactly what I needed!

Thank you!

Yun
Reply all
Reply to author
Forward
0 new messages