API for accessing the strava V2 API - (http://bit.ly/161qmXg)
Very experimental right now, but is in use. Subject to change in future versions.
Add this line to your application's Gemfile:
gem 'strava-api-v2'
And then execute:
$ bundle
Or install it yourself as:
$ gem install strava-api-v2
This module includes both versions of the API (at least the sparse parts I was interested in putting together. The confusing thing is that you'll probably have to mix and match to get things done that you care about.
The connection object is used to interact with Strava's servers.
$ connection_v1 = Strava::V1::Connection.new
$ connection_v2 = Strava::V2::Connection.new
Get a random sampling of all rides
$ rides = connection_v1.rides
Or you can pass in parameters to get a more useful subset of rides.
For instance, to get the top rides from a club $ rides = connection_v1.rides(:club_id => 15)
Or get the rides for a given athlete $ rides = connection_v1.rides(:athlete_id = > 7679)
Other parameters include :athlete_name, :start_date, :end_date, :start_id, and :offset (http://bit.ly/18CrfCa)
Get the stream information about a ride, including heart rates, coordinates, times, distances, altitudes of points sampled on a ride.
$ stream = connection_v1.stream(ride_id)
You can find all the efforts for a segment in the following way
$ segment = connection_v1.segment_with_efforts(segment_id, params)
$ efforts = segment.efforts
The efforts can be search by different parameters, including :club_id, :athlete_id, :athlete_name, :start_date, :end_date, :start_id, :best => true
Search for club by name
$ clubs = connection_v1.rides(:name => "Mission Cycling")
See http://bit.ly/18Ctky9 for more details - this also enables you to retrieve tokens and athlete information.
$ auth = connection_v2.login("email@example.com", "password")
$ token = auth.token
$ athlete = auth.athlete
See http://bit.ly/125MoTh for more details - this allows you to look up the segments for a given ride
$ segments = connection_v2.segments_for_ride(ride_id)
$ first_segment_efforts = segments[0].efforts
See http://bit.ly/125MoTh - looks up all efforts put out in a given ride.
$ segments = connection_v2.segments_and_efforts_for_ride(ride_id)
$ first_effort = segments[0].efforts[0]
- Fork it
- 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