Module: Strava::Api::Endpoints::Athletes

Included in:
Client
Defined in:
lib/strava/api/endpoints/athletes.rb

Overview

API endpoints for Strava athletes.

Athletes represent Strava users. This module provides methods for retrieving athlete profiles, stats, zones, and updating athlete information.

Instance Method Summary collapse

Instance Method Details

#athleteStrava::Models::DetailedAthlete

Get the authenticated athlete's profile.

Returns the currently authenticated athlete with detailed information. Requires profile:read_all scope for full profile access.

Examples:

Get athlete profile

athlete = client.athlete
puts "#{athlete.firstname} #{athlete.lastname}"
puts "Location: #{athlete.city}, #{athlete.state}"

Returns:

See Also:



30
31
32
# File 'lib/strava/api/endpoints/athletes.rb', line 30

def athlete
  Strava::Models::DetailedAthlete.new(get('athlete'))
end

#athlete_stats(id_or_options, options = {}) ⇒ Strava::Models::ActivityStats

Get activity statistics for an athlete.

Returns the activity stats of an athlete including recent totals, year-to-date totals, and all-time totals for different activity types.

Examples:

Get athlete stats

stats = client.athlete_stats(12345)
recent_run = stats.recent_run_totals
puts "Recent runs: #{recent_run.count} totaling #{recent_run.distance_s}"

Parameters:

  • id_or_options (Integer, Hash)

    Athlete ID or options hash with :id key

  • options (Hash) (defaults to: {})

    Additional options

Returns:

See Also:



73
74
75
76
# File 'lib/strava/api/endpoints/athletes.rb', line 73

def athlete_stats(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  Strava::Models::ActivityStats.new(get("athletes/#{id}/stats", options))
end

#athlete_zones(options = {}) ⇒ Strava::Models::Zones

Get the authenticated athlete's heart rate and power zones.

Returns the athlete's configured training zones for heart rate and power. These zones are used for training analysis and activity classification.

Examples:

Get athlete zones

zones = client.athlete_zones
heart_rate = zones.heart_rate
heart_rate.zones.each { |zone| puts "#{zone.min}-#{zone.max} bpm" }

Parameters:

  • options (Hash) (defaults to: {})

    Additional options

Returns:

See Also:



51
52
53
# File 'lib/strava/api/endpoints/athletes.rb', line 51

def athlete_zones(options = {})
  Strava::Models::Zones.new(get('athlete/zones', options))
end

#update_athlete(options = {}) ⇒ Strava::Models::DetailedAthlete

Update the authenticated athlete's profile.

Updates the currently authenticated athlete. Only weight can be updated. Requires profile:write scope.

Examples:

Update athlete weight

athlete = client.update_athlete(weight: 70.5)

Parameters:

  • options (Hash) (defaults to: {})

    Athlete attributes to update

Options Hash (options):

  • :weight (Float)

    Athlete weight in kilograms

Returns:

See Also:



94
95
96
# File 'lib/strava/api/endpoints/athletes.rb', line 94

def update_athlete(options = {})
  Strava::Models::DetailedAthlete.new(put('athlete', options))
end