Project

cta-api

0.01
No commit activity in last 3 years
No release in over 3 years
An easy way to access the Chicago Transit Authority API via the Ruby programming language
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.0.0
>= 0.10.2
 Project Readme

Install

Via rubygems.org:

$ gem install cta-api

Usage

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:

Bus Tracker

Setup

require 'cta-api'

key = "XXXXXXXXXXXXXXXXXXXXXXXXX"
CTA::BusTracker.key = key

Find Routes and Stops

# 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

Find Vehicles

# 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 Predicted Arrival Times

# 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"]

Get System Time

CTA::BusTracker.time

Train Tracker

Setup

require 'cta-api'

key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
CTA::TrainTracker.key = key

Get a List of Stops and Stations

# stops
CTA::TrainTracker.stops

# stations
CTA::TrainTracker.stations

Get Predicted Arrival Times

CTA::TrainTracker.arrivals :stpid => "30106"