MBTA Realtime

Description goes here.

Usage

Remember to always require 'mbta-realtime' before you use it.

require 'mbta-realtime' # 'mbta_realtime' also works

Initialize it with your API key.

@mbta = MBTARealtime::Client.new(api_key: "your_api_key")

If you keep your API key in an environment variable (or .env file with Dotenv), such as

export MBTA_API_KEY=wu9RGmG7OoT2UZnHuwN9Xw

you can initialize your MBTA Realtime client with

@mbta = MBTARealtime.new(ENV['MBTA_API_KEY'])

All methods return Ruby hashes.

Routes

#routes returns all the routes in the system.

@mbta.routes
# => {"mode"=>[{"route_type"=>"0", "mode_name"=>"Subway", "route"=>[{"route_id"=>"810_", "route_name"=>"Green Line"}, {"route_id"=>"813_", "route_name"=>"Green Line"}
# ... rest truncated for brevity ...

#routes_by_stop(stop_id) returns all the routes for a given stop, indicated by its unique stop id.

@mbta.routes_by_stop(1395)
# => {"stop_id"=>"1395", "stop_name"=>"Dartmouth St @ Appleton St", "mode"=>[{"route_type"=>"3", "mode_name"=>"Bus", "route"=>[{"route_id"=>"10", "route_name"=>"10"}, {"route_id"=>"170", "route_name"=>"170"}]}]}

Immediate Next Steps

Contributing to mbta-realtime

Copyright © 2014 Matt Cloyd. See LICENSE.txt for further details.