Skip to main content

stravaweblib

Provides all the functionality of the stravalib package and extends it using web scraping.

Authentication

In order to log into the website, the WebClient class either needs an email and password, or the JWT of an existing session. Strava stores this JWT in the strava_remember_token cookie.

After the client has logged in, a JWT for the current session can be accessed via the WebClient's jwt property. Storing this JWT (and the access_token from stravalib) allows for resuming the session without having to log in again. This can avoid rate limits and lockouts.

Example:

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)

# Store the current session's information
jwt = client.jwt
access_token = client.access_token

# Create a new client that continues to use the previous web session
client = WebClient(access_token=access_token, jwt=jwt)

Extra functionality

Export activities

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

Delete activities from the site. Note that this was previously possible via the API, but the endpoint has been removed as of 2017-01-17.

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)

Get bike components

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, on_date=datetime.now())

License

Licensed under the Mozilla Public License, version 2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stravaweblib-0.0.6.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stravaweblib-0.0.6-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file stravaweblib-0.0.6.tar.gz.

File metadata

  • Download URL: stravaweblib-0.0.6.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.9

File hashes

Hashes for stravaweblib-0.0.6.tar.gz
Algorithm Hash digest
SHA256 0c3fd75d63a37ef5a8f9c26adacfdfad5a9830ce84264eb8e1a1b3c189505508
MD5 5bfd2de2bceb9d7f89cee68771568a3e
BLAKE2b-256 8e685bf09cb0ea807865aa2364f9a8b988bde9b69fe479cf0498f0e2c2d12fce

See more details on using hashes here.

File details

Details for the file stravaweblib-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: stravaweblib-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.9

File hashes

Hashes for stravaweblib-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 02946364a3063961636d1dbbb307124d685d691c6cffbbfc5da3f60617945465
MD5 c7b8d7464cf5091cf7d581514b1a9801
BLAKE2b-256 4dfd1ef283762390a6a5670f9771ccd75b1da94a3e81e2b371a125d7a2814474

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page