Neil Ang

Developer

A stunning likeness of Neil Ang
Hello world

Melbourne public transport ruby gem

Posted on

Edit: This gem was built originally released PTV API. This gem has not been updated to use the newer/better API.

Lately I've been working a project that involves querying for public transport timetable data from PTV. A few months ago they announced the release of an API giving access to their data. The API allows you to lookup timetable data for trains, trams and buses, but also perform basic searches to find nearby stops and myki ticket outlets.

The API is not in great shape, but still useful if you need access to this information. So I put together a ruby gem called 'ptv_timetable' to make accessing the API easier.

You can download the gem from RubyGems or get the raw source from GitHub.

Example.

irb> require 'ptv_timetable'
irb> api = PtvTimetable::API.new('devid', 'secret_key')
irb> api.search('Camberwell')
[
  {
    "result" => {
      "suburb" => "Camberwell",
      "transport_type" => "tram",
      "stop_id" => 3012,
      "location_name" => "265 Camberwell Rd #41 ",
      "lat" => -37.83211,
      "lon" => 145.057755,
      "distance" => 0.0
    },
    "type"=>"stop"
  },
  {
    "result" => {
      "suburb" => "Camberwell",
      "transport_type" => "tram",
      "stop_id" => 3061,
      "location_name" => "Acheron Ave/Camberwell Rd #46 ",
      "lat" => -37.83981,
      "lon" => 145.0663,
      "distance" => 0.0
    },
    "type" => "stop"
  },
  ...
]

See the project read me for full list of commands.