runpandas.StravaClient#

class runpandas.StravaClient(*args, token_file=None, refresh_token=None, client_secret=None, client_id=None, **kwargs)#

The StravaClient object is a helper tool for handling the authentication process (i.e. authorization, token update, …) against the Strava.

Parameters
  • token_file (File, The Strava access token path where it will be kept or loaded, optional) –

  • refresh_token (str, The Strava refresh token, optional) –

  • client_secret (str, The strava client secret used for token refresh, optional) –

  • client_id (int, The Strava client id used for token refresh, optional) –

__init__(*args, token_file=None, refresh_token=None, client_secret=None, client_id=None, **kwargs)#

Initialize a new client object.

Parameters
  • access_token (str) – The token that provides access to a specific Strava account. If empty, assume that this account is not yet authenticated.

  • rate_limit_requests (bool) – Whether to apply a rate limiter to the requests. (default True)

  • rate_limiter (callable) – 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_session (requests.Session() object) – (Optional) pass request session object.

Methods

__init__(*args[, token_file, refresh_token, ...])

Initialize a new client object.

authenticate_web()

It handles the authentication web negotiation with Strava.

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()

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_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

get_token_from_file()

Gets the token from a token_file and returns as dict.

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()

It updates the access token if the token is expired.

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).

save_token_to_file(token)

It saves the token to the file

set_token_from_dict(token)

It extracts the token components from a token dict response.

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.