Linking Trip Planner API to Realtime GTFS Timetables

Hello
I apologise in advance if this has been answered before but I am unable to find the right answer.
I am developing an app that will basically show departure times for favourite saved stops. I am using the trip planner APIs to search for stops and retrieve departure times. However only a small number of departure times are being returned so I guess I need to refer to the static realtime GTFS timetables. Reading the documentation I have determined that I need to obtain a trip_id from trips.txt in order to be able to extract my departure times from stop_times.txt. To get the trip_id I can search for the route_id which I obtain from routes.txt. This is where I come unstuck because the route_no in routes.txt does not always match the route_no returned from the trip planner API departure_mon call? Is there something I am missing here? Or does the data returned from the Trip Planner API not match the GTFS data?

Thank you.

Hi Bonobo,
The field you are looking for is named RealtimeTripId (see below). This will link to trip_id in trips.txt from public transport timetables realtime.

How many is a small number? I generally get 40 results in one search.

     "departureTimePlanned":"2017-07-20T02:01:00Z",
     "transportation":{
        "id":"nsw:020T3: :H:sj2",
        "name":"Sydney Trains Networ T3 Bankstown Line",
        "disassembledName":"T3",
        "number":"T3 Bankstown Line",
        "iconId":1,
        "description":"City to Liverpool or Lidcombe via Bankstown",
        "product":{
           "class":1,
           "name":"Sydney Trains Networ",
           "iconId":1
        },
        "operator":{
           "id":"x0001",
           "name":"Sydney Trains"
        },
        "destination":{
           "name":"Liverpool via Bankstown",
           "type":"stop"
        },
        "properties":{
           "tripCode":660,
           "mtSubcode":"0"
        },
        "origin":{
           "name":"Central Station",
           "type":"stop"
        }
     },
     "properties":{
        "WheelchairAccess":"true",
        "RealtimeTripId":"10-H.1386.111.120.M.8.46414549",
        "PlanLowFloorVehicle":"1",
        "PlanWheelChairAccess":"1"
     }
  },
1 Like

Hi Patrick
Thanks for your reply. Yeah I have tried searching for the Realtime Trip ID in trips.txt for SydneyTrains realtime GTFS timetables but I find it is not an exact match. I downloaded the GTFS bundle yesterday and if I run a departure_mon call dated the 20170719 I find the timetable version id’s differ in that the trip planner returns 111 (same as in your example) but the GTFS bundle shows 114.

I find I only get anything from 1-6 stop events for a particular route at a stop. If you are getting more then maybe my API call is incorrect but I can’t see any other options I should be selecting?
Cheers
Bonobo

Hi Bonobo,
I will come back to you. I checked it out, it seems to be just today, trip plans tomorrow and Saturday are fine. I don’t know enough about the timing of the file update.

Could you send me the stops you are using as well?

OK, the trip id issue seems to have resolved itself.

Bonobo DM’d me the stop he is looking at. If you pick a busy stop with lots of services, once you filter by route the result can be quite small. You can fix this by adding the parameter “limit” and increase it above the default 40.

i.e
https://api.transport.nsw.gov.au/v1/tp/departure_mon?TfNSWDM=true&outputFormat=rapidJSON&coordOutputFormat=EPSG%3A4326&mode=direct&type_dm=stop&name_dm=10101443&depArrMacro=dep&itdDate=20170721&itdTime=1200&limit=150

Limit isn’t documented for some reason but I’ll see about getting it added.

1 Like

I had an inquiry on another forum with a similar issue. If you’re looking for stops at a specific platform you need add the parameter nameKey_dm=$USEPOINT$ . If you don’t do that you’ll get the whole station.

Check page 31 of the manual:

1 Like