stravalib.client.Client

class stravalib.client.Client(access_token=None, rate_limit_requests=True, rate_limiter=None, requests_session=None)[source]

Main client class for interacting with the exposed Strava v3 API methods.

This class can be instantiated without an access_token when performing authentication; however, most methods will require a valid access token.

__init__(access_token=None, rate_limit_requests=True, rate_limiter=None, requests_session=None)[source]

Initialize a new client object.

access_tokenstr

The token that provides access to a specific Strava account. If empty, assume that this account is not yet authenticated.

rate_limit_requestsbool

Whether to apply a rate limiter to the requests. (default True)

rate_limitercallable

A stravalib.util.limiter.RateLimiter object to use. If not specified (and rate_limit_requests is True), then stravalib.util.limiter.DefaultRateLimiter will be used.

requests_sessionrequests.Session() object

(Optional) pass request session object.

Methods

__init__([access_token, ...])

Initialize a new client object.

authorization_url(client_id, redirect_uri[, ...])

Get the URL needed to authorize your application to access a Strava user's information.

create_activity(name, activity_type, ...[, ...])

Create a new manual activity.

create_subscription(client_id, ...[, ...])

Creates a webhook event subscription.

deauthorize()

Deauthorize the application.

delete_activity(activity_id)

Deletes the specified activity.

delete_subscription(subscription_id, ...)

Unsubscribe from webhook events for an existing subscription.

exchange_code_for_token(client_id, ...)

Exchange the temporary authorization code (returned with redirect from strava authorization URL) for a short-lived access token and a refresh token (used to obtain the next access token later on).

explore_segments(bounds[, activity_type, ...])

Returns an array of up to 10 segments.

get_activities([before, after, limit])

Get activities for authenticated user sorted by newest first.

get_activity(activity_id[, include_all_efforts])

Gets specified activity.

get_activity_comments(activity_id[, ...])

Gets the comments for an activity.

get_activity_kudos(activity_id[, limit])

Gets the kudos for an activity.

get_activity_laps(activity_id)

Gets the laps from an activity.

get_activity_photos(activity_id[, size, ...])

Gets the photos from an activity.

get_activity_streams(activity_id[, types, ...])

Returns a stream for an activity.

get_activity_zones(activity_id)

Gets zones for activity.

get_athlete([athlete_id])

Gets the specified athlete; if athlete_id is None then retrieves a detail-level representation of currently authenticated athlete; otherwise summary-level representation returned of athlete.

get_athlete_clubs()

List the clubs for the currently authenticated athlete.

get_athlete_followers([athlete_id, limit])

Gets followers for current (or specified) athlete.

get_athlete_friends([athlete_id, limit])

Gets friends for current (or specified) athlete.

get_athlete_koms(athlete_id[, limit])

Gets Q/KOMs/CRs for specified athlete.

get_athlete_starred_segments(athlete_id[, limit])

Returns a summary representation of the segments starred by the

get_athlete_stats([athlete_id])

Returns Statistics for the athlete.

get_both_following(athlete_id[, limit])

Retrieve the athletes who both the authenticated user and the indicated

get_club(club_id)

Return a specific club object.

get_club_activities(club_id[, limit])

Gets the activities associated with specified club.

get_club_members(club_id[, limit])

Gets the member objects for specified club ID.

get_effort_streams(effort_id[, types, ...])

Returns an streams for an effort.

get_friend_activities([limit])

DEPRECATED This endpoint was removed by Strava in Jan 2018.

get_gear(gear_id)

Get details for an item of gear.

get_related_activities(activity_id[, limit])

Deprecated.

get_route(route_id)

Gets specified route.

get_route_streams(route_id)

Returns streams for a route.

get_routes([athlete_id, limit])

Gets the routes list for an authenticated user.

get_running_race(race_id)

Gets a running race for a given identifier.

get_running_races([year])

Gets a running races for a given year.

get_segment(segment_id)

Gets a specific segment by ID.

get_segment_effort(effort_id)

Return a specific segment effort by ID.

get_segment_efforts(segment_id[, ...])

Gets all efforts on a particular segment sorted by start_date_local

get_segment_leaderboard(segment_id[, ...])

Gets the leaderboard for a segment.

get_segment_streams(segment_id[, types, ...])

Returns an streams for a segment.

get_starred_segments([limit])

Returns a summary representation of the segments starred by the

handle_subscription_callback(raw[, verify_token])

Validate callback request and return valid response with challenge.

handle_subscription_update(raw)

Converts a raw subscription update into a model.

join_club(club_id)

Joins the club on behalf of authenticated athlete.

leave_club(club_id)

Leave club on behalf of authenticated user.

list_subscriptions(client_id, client_secret)

List current webhook event subscriptions in place for the current application.

refresh_access_token(client_id, ...)

Exchanges the previous refresh token for a short-lived access token and a new refresh token (used to obtain the next access token later on).

update_activity(activity_id[, name, ...])

Updates the properties of a specific activity.

update_athlete([city, state, country, sex, ...])

Updates the properties of the authorized athlete.

upload_activity(activity_file, data_type[, ...])

Uploads a GPS file (tcx, gpx) to create a new activity for current athlete.

Attributes

access_token

The currently configured authorization token.