Trip Planner API now available!


#1

TfNSW is excited to have released the Trip Planner APIs that can help our customers plan their trips with ease, check out the new dataset at https://opendata.transport.nsw.gov.au/dataset/trip-planner-apis

The five APIs that have been released are:
1. Stop Finder API – Allows customers to search for stops, stations, wharves, points of interest and known addresses based on search criteria. Use with: Trip Planner and Departure API.
2. Trip Planner API – Allows customers to plan a trip between two locations and includes walking, driving, real-time service and Opal fare information.
3. Departure API – Provides customers with departure information from a stop, station or wharf in real-time.
4. Service Alert API – Provides customers with service status and incident information across the Transport network.
5. Coordinate Request API – Allows customers to search for nearby stops, stations, wharves and points of interest based on their geographical location.

We are also proud to announce the launch of three new real-time apps which have emerged from our Personal Trip Planning API Challenge:

  • Navibaby – A mobile app that provides trip planning for parents and carers for pram and stroller friendly routes. Navibaby is available for download from Google Play for Andriod and will be coming soon to Apple iOS. Visit: https://play.google.com/store/apps/details?id=com.navibaby.android

  • AnyTrip – A mobile responsive web application that lets customers share trip information with others via SMS, Facebook Messenger, WhatsApp or Twitter. Visit: www.anytrip.com.au

  • Splice Trip NSW – Facebook Messenger chat bot that allows customers to quickly access train times across NSW and share it with others. Visit: www.facebook.com/splicetripnsw

If you have any questions or anything to discuss please post below.


#3

A long awaited reply in this thread!

I have just found the time to have a try at this (very non-technical), and got it working nicely. I have home assistant (smart home software - https://home-assistant.io) running and have managed to get the time to the next few train services for my (very close) train station by using:

stopEvents.0.departureTimeEstimated
stopEvents.1.departureTimeEstimated
stopEvents.2.departureTimeEstimated etc.

This works nicely, but the problem I’m finding is that the ‘zero’ stop event most of the time becomes ‘sticky’ and stays there even after the train has left. It generally gets up to negative 4-5 minutes before being replaced by what was the ‘1’ stop event. Is this a common thing that other people just program out (if < 0, use stopevent.1)? That’s a little bit beyond me at the moment.

Or is it just something with this station? Station is 10101200 (Denistone - all platforms).

Thanks!


#4

Hi Greenhouse,

I assume you’re using the departure_mon API endpoint? Are you able to post up what query parameters you are using?

Cheers,
Ken


#5

Ken,

Firstly, a big thanks to you as you first got me interested in this and only by digging through your site (PID/departure monitor) did I actually come to understand how this all works.

You are correct in that I’m using the departure_mon. Every 60 seconds it runs the following:

curl -X GET --header 'Accept: application/json' --header 'Authorization: apikey [redacted]' 'https://api.transport.nsw.gov.au/v1/tp/departure_mon?outputFormat=rapidJSON&coordOutputFormat=EPSG%3A4326&mode=direct&type_dm=stop&name_dm=10101200&departureMonitorMacro=true&TfNSWDM=true&version=10.2.1.42'

In your implementation do you remove negatives through code or just rely on the zero stop event updating externally?

Thanks,
Adam


#6

Hi Adam,

That’s great to hear :slight_smile:

I don’t use the departure_mon API on AnyTrip, however, I am familar with the API.

I’m not sure what’s possible on home-assistant.io, but I suspect there is some sort of caching in the system somewhere (either on home assistant or somewhere on the API side). If it’s possible, you could try populating the itdTime attribute in HHMM format – e.g. itdTime=1520 for 3:20pm.

If not, perhaps you could try adding an attribute with a random or incrementing number at the end – e.g. cache={RANDOM_NUM}?


#7

Thanks for your reply.

Unfortunately I can’t (that I know of) put any variables in the GET command so I might have to wear it for now.

I thought that I might be running into a limit somewhere in the API as I’m doing this 10 times every 60 seconds, but those 10 times are all at once (therefore >5 per second), but I’m not getting any messages back saying I’ve exceeded anything (which I got when I was testing other things).