You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The iOS 12 update contained a very cool feature: Siri Shortcuts. This replaces the Workflows app. I was using Workflows to send my wife an SMS with my estimated time of arrival at home when I left work. With the new Shortcuts app I could have this all happen automatically, and it also supports reading from Web APIs.
The first part, however, is to figure out how to get data from the Gautrain website.
mitmproxy
mitmproxy or Man In The Middle Proxy is a piece of software you can run on your computer which will stand between a device and the internet and allow you to inspect what is going on. I might cover installation in another post, but basically I just followed instructions to get it going and then fired up the Gautrain app to see what it was doing.
The important part here is "name": "Gautrain" and that id which is used later.
Also interesting is that they are clearly using whereismytransport.com, which is the first time I've heard of this service.
The app then asks ask for a list of stops:
This is the first request which has parameters. You can see that they are using the coordinates for Hatfield station and Sandton station as the start and end points.
So that list of agencies to omit is obviously from the original request. I'm hoping I don't need that. For my purposes I just need to know when the next train will arrive and how long it will take to get to the destination.
The response from this request is quite huge, but the first bit shows the important parts:
I'm only really interested in when the next train will arrive at Sandton and I don't want to type all that stuff into a mobile app, I want a minimal version.
Further investigation yields the simplified request:
This is something I can put into the automation app eally easily. More info on that to follow.
For posterity, this is that call being checked via curl:
curl -d '{"geometry":{"coordinates":[[28.23794,-25.74762],[28.05693,-26.10858]],"type":"MultiPoint"},"profile":"ClosestToTime","maxItineraries":5,"timeType":"DepartAfter","only":{"agencies":["edObkk6o-0WN3tNZBLqKPg"]}}' -H "Content-Type: application/json" -X POST https://api.gautrain.co.za/transport-api/api/0/journey/create
The iOS 12 update contained a very cool feature: Siri Shortcuts. This replaces the Workflows app. I was using Workflows to send my wife an SMS with my estimated time of arrival at home when I left work. With the new Shortcuts app I could have this all happen automatically, and it also supports reading from Web APIs.
The first part, however, is to figure out how to get data from the Gautrain website.
mitmproxy
mitmproxy or Man In The Middle Proxy is a piece of software you can run on your computer which will stand between a device and the internet and allow you to inspect what is going on. I might cover installation in another post, but basically I just followed instructions to get it going and then fired up the Gautrain app to see what it was doing.
Sequence of events with Gautrain App
First endpoint to check service is live
Returns
true
orfalse
.The app then hits
And gets a whole list of agencies, including this one:
The important part here is
"name": "Gautrain"
and thatid
which is used later.Also interesting is that they are clearly using whereismytransport.com, which is the first time I've heard of this service.
The app then asks ask for a list of stops:
The response is a list of stops like this one:
I've kept the important ones for me - I'm going from Hatfield to Sandton and back, so I need those coordinates.
Right, so the next thing they hit is
This is the first request which has parameters. You can see that they are using the coordinates for Hatfield station and Sandton station as the start and end points.
So that list of agencies to omit is obviously from the original request. I'm hoping I don't need that. For my purposes I just need to know when the next train will arrive and how long it will take to get to the destination.
The response from this request is quite huge, but the first bit shows the important parts:
So when is the next train?
I'm only really interested in when the next train will arrive at Sandton and I don't want to type all that stuff into a mobile app, I want a minimal version.
Further investigation yields the simplified request:
This is something I can put into the automation app eally easily. More info on that to follow.
For posterity, this is that call being checked via curl:
Guess it's also time to create an account at whereismytransport.com!
https://negfeedback.blogspot.com/2020/05/indispensable-command-line-tools.html
The text was updated successfully, but these errors were encountered: