Provides all the functionality of the stravalib package and extends it using web scraping.
Download activity files as GPX, TCX, or the original format they were uploaded in.
from stravaweblib import WebClient, DataFormat
# Log in (requires API token and email/password for the site)
client = WebClient(access_token=OAUTH_TOKEN, email=EMAIL, password=PASSWORD)
# Get the first activity id (uses the normal stravalib API)
activities = client.get_activities()
activity_id = activities[0].id
# Get the filename and data stream for the activity data
data = client.get_activity_data(activity_id, fmt=DataFormat.ORIGINAL)
# Save the activity data to disk using the server-provided filename
with open(data.filename, 'wb') as f:
for chunk in data.content:
if not chunk:
break
f.write(chunk)
Delete activities from the site. Note that this was previously possible via the API, but the endpoint has been deprecated as of 2017-03-01.
from stravaweblib import WebClient
# Log in (requires API token and email/password for the site)
client = WebClient(access_token=OAUTH_TOKEN, email=EMAIL, password=PASSWORD)
# Get the first activity id (uses the normal stravalib API)
activities = client.get_activities()
activity_id = activities[0].id
# Delete the activity
client.delete_activity(activity_id)
Retrieve all components added to bikes. Can optionally only show components active at a certain date.
from stravaweblib import WebClient
from datetime import datetime
# Log in (requires API token and email/password for the site)
client = WebClient(access_token=OAUTH_TOKEN, email=EMAIL, password=PASSWORD)
# Get a list of bikes the current user owns
athlete = client.get_athlete()
bikes = athlete.bikes
# Get the id of the first bike
bike_id = bikes[0].id
# Get all components of the first bike (past and present)
client.get_bike_components(bike_id)
# Get the current components on the first bike
client.get_bike_components(bike_id, date=datetime.now())
Licensed under the Mozilla Public License, version 2.0