piemadd / amtrak

NPM library to get Amtrak tracking data.
GNU Affero General Public License v3.0
49 stars 4 forks source link

Consider normalizing object to be the same shape regardless of endpoint #6

Open scvnc opened 2 years ago

scvnc commented 2 years ago

first off: nice job, thank you for making this data way more accessible! I understand part of this issue is likely from just how amtrak is making the data available.

Viewing train from /trains/{number} endpoint

notice estArr, estDep included.

2022-04-22_05-06

Viewing train from /stations/{code} endpoint

notice estArr, estDep not included

2022-04-22_05-05

It would be nice if in the /stations/{code} endpoint, the shape was the same.

My use case

Simply get my train and see when it's Amtrak-reported estimated arrival is. Not sure how to query that robustly yet. The /trains endpoint has the nice info but I'd likely have filter by station/date in some (totally possible) way.

deeper use case: omg I love amtrak but the chicago bound train is scheduled to slide through at 3:20am and is usually 1 to 5 hours late. Gotta pipe this data into a cron script that tells Twilio to spam my phone an hour before the train is about to arrive so that I can get the maximum amount of sleep. Open for collab on that :)

piemadd commented 2 years ago

I totally understand your use case here and also have no idea why I don't have the estimated arrival/departure on the stations endpoint. You've actually caught me at the right time as I am currently working on rewriting the API currently (should be done by Sunday) and I'll make sure that the train and station objects are standardized through all endpoints.

scvnc commented 1 year ago

@piemadd any updates? Want to meet up in Chi town? I want to help bolster and test this lib

piemadd commented 1 year ago

Sorry for taking a while, just finished the new API, which is live at https://api-v3.amtraker.com/v3. I'm currently working on porting Amtrak.js over to operate with this api. It has some breaking changes from the previous api, one of which is to move away from including train information in station requests, and instead including a list of train ids ([train number]-[day of the month the train originated]), like this: image

you can try it out here: https://api-v3.amtraker.com/v3/trains https://api-v3.amtraker.com/v3/trains/6 https://api-v3.amtraker.com/v3/stations/NYP https://api-v3.amtraker.com/v3/stations