Via rubygems.org:
$ gem install cta-api
This gem allows you to access the Chicago Transit Authority API via Ruby. You can track the real-time locations of all public transportation vehicles, including buses and trains. You can obtain API keys from the CTA website:
- http://www.transitchicago.com/developers/bustracker.aspx
- http://www.transitchicago.com/developers/traintracker.aspx
require 'cta-api'
key = "XXXXXXXXXXXXXXXXXXXXXXXXX"
CTA::BusTracker.key = key
# list all available routes
CTA::BusTracker.routes
# gets the available directions for the specified route (north, south, etc.)
CTA::BusTracker.directions :rt => 50
# list all stops that belong to a particular route
CTA::BusTracker.stops :rt => 50, :dir => :north
# returns an array of vehicles that travel the given routes
CTA::BusTracker.vehicles :rt => 50
# returns an array of vehicles with the given vehicle ids
CTA::BusTracker.vehicles :vid => ["1782", "1419", "1773"]
# get arrival times for a list of stop ids
# note that the rt parameter is optional
CTA::BusTracker.predictions :stpid => 8923, :rt => 50
# get arrival times for a list of vehicle ids
CTA::BusTracker.predictions :vid => ["1782", "1419", "1773"]
CTA::BusTracker.time
require 'cta-api'
key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
CTA::TrainTracker.key = key
# stops
CTA::TrainTracker.stops
# stations
CTA::TrainTracker.stations
CTA::TrainTracker.arrivals :stpid => "30106"