bustimes.org icon indicating copy to clipboard operation
bustimes.org copied to clipboard

Getting departures from stop via API?

Open jamesmacwhite opened this issue 1 year ago • 3 comments

Hi @jclgoodwin

Thanks for your work on bustimes.org!

I was wondering if the current API allows for obtaining the departures from a specific stop through the API i.e. JSON, rather than the web interface?

I can see there's this path: https://bustimes.org/stops/9400ZZNOLCM2/departures within the JavaScript resources for the main website, but this is HTML formatted as a part that gets included in the main web interface overall and refreshes a div element.

I can do this: https://bustimes.org/api/stops/9400ZZNOLCM2/, but adding the depatures path throws a 404 Not Found, so I'm not sure if it is intended to be used this way?

Thank you!

jamesmacwhite avatar Feb 03 '24 20:02 jamesmacwhite

There is – undocumented but used by a few things:

https://bustimes.org/stops/9400ZZNOLCM2/times.json https://bustimes.org/stops/9400ZZNOLCM2/times.json?limit=3 https://bustimes.org/stops/9400ZZNOLCM2/times.json?when=2024-02-03T12:30:00Z

jclgoodwin avatar Feb 03 '24 22:02 jclgoodwin

Ah thank you! That makes sense.

In terms of external applications using this API, is this within the terms of service/usage or would you require further discussion around this area?

jamesmacwhite avatar Feb 04 '24 06:02 jamesmacwhite

I have used this API in https://github.com/ukslim/my-bus-stops - letting you know as a courtesy, and to say thank you.

Please do let me know if this is a problem or there's a different endpoint you'd prefer me to use. I don't realistically expect it to become heavily used.

ukslim avatar Apr 10 '24 09:04 ukslim