SpBus
A small Ruby client for SPTrans API which allows you to retrieve data about São Paulo city buses, lines, stops and real-time (GPS) information.
Installation
Add this line to your Gemfile:
gem 'spbus'
And then execute:
$ bundle
Or install it yourself as:
$ gem install spbus
Usage
First of all, get your API token at SPTrans developers page. Then you can play with the client:
client = SpBus::Client.new("your api token goes here")
Authentication
Before do any request, client must be authenticated. So, let's authenticate:
client.authenticate #=> true
Search
client.search("largo sao francisco") #=> [#<SpBus::Line ...>, #<SpBus::Line ...>, ...]
Line stops
client.stops(line.id) #=> [#<SpBus::Stop ...>, #<SpBus::Stop ...>, ...]
Real-time (GPS)
client.buses(line.id) #=> [#<SpBus::Bus ...>, #<SpBus::Bus ...>, ...]
Contributing
- Fork it (http://github.com/lenon/spbus/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
To-do
- Improve documentation.
- Support more endpoints (like estimated time of arrival and bus lanes).