Transperth

Posted on 2014-03-07 00:00:00 +0800

This project is sorta in limbo, thanks to the new transperth website being significantly more difficult to scrape.

Those people who live, or have lived in Perth are likely familiar with the government organisation that provides the public transportation facilities, Transperth.

Put simply, I wished to create a more or less simply to use API library in Python to pull data out of their system. I originally thought that this would primarily involve scraping their website, as I had trouble figuring out the location of the API the mobile app used.

I think I have now figured it out, in part;

Train times API

Example; http://livetimes.transperth.wa.gov.au/LiveTimes.asmx/GetSercoTimesForStation?stationname=Perth%20Underground%20Stn Python interface; https://github.com/Mause/pytransperth/blob/master/transperth/livetimes.py

I found a JSON string in

1
com.jeppesen.transperth.vm.TrainTimesVm
that gave a list of the lines and station names that the API would accept. The example above shows the corresponding URL for the
1
Perth Underground Stn
.

Journey Planner API

Root URL; https://api.transperth.info/DesktopModules/JJPApiService/api/jjpapi

Silver Rails Journey Planner API:

The SaaS service provides endpoints for reference data (stops, routes, timetable, etc.), a journey planner, a localities index, a nearby stops service, a timetable lookup, and a trip lookup, presumably for trips already determined via the API.

Having rooted my phone, and installing Root Browser to access the android Transperth App’s assets, I was able to retrieve the

1
ApiKey
for the Silver Rails API, as well as many other settings.

Because I would probably get the shit sued out of me, I don’t feel comfortable sharing the key here.

Anyway, using the ApiKey, I was able to download all the reference data that the app uses which is a rather large amount, and it seems to be downloaded everytime the app is started, at least partially. I shall investigate this further.

The reference data contains info about;

  • ServiceProviderReferenceData - TransPerth, TransBunbury, etc.
  • TransitStopReferenceData - All the train, bus, and presumably ferry stops
  • RouteTimetableGroupReferenceData - Timetables for the routes, routes themselves
  • LandmarkReferenceData - Landmark info -
    1
    
    Curtin University of Technology
    
    for example
  • TransportModeReferenceData - Lists the transport modes; School Bus, Rail, Bus, and Ferry
  • RouteReferenceData - Metadata for routes

Using

1
apktool
, I managed to extract an XML file from the
1
.apk
that contains a large number of strings not present in the code I extracted. This is where I retrieved the list of datasets for the Silver Rail Technology API from;

  • PerthDataset
  • BrisbaneDataset
  • BostonDataset

You can insert these into some of the above URLs, along with a an

1
ApiKey
query parameter, to make use of the endpoint.

I also found some documentation; http://journeyplanner.silverrailtech.com/JourneyPlanner/Help/html/R_Project_Journey_Planner_Interface_Specification.htm

Misc

7:02PM 8/3/2014

Browsing through the action list on the transperth website, I noticed that it generated a synthetic TAG ON event to account for my incorrect TAG ON at the wrong scanner.