Strava Connector
This is a simple Strava client written in Python. I found Strava's Python API to be difficult to use, so I wrote this wrapper that uses requests to expose all GET requests that are available in Strava's API documentation.
You have to manually follow the tutorial listed below to retrieve a client_id and a client_secret. This has to be done only once. Afterwards, strava_connector exposes convenient wrappers.
Installation
pip install strava_connector
or
poetry add strava_connector
How to use
For the following example to work, you need to follow the Authentication workflow below.
Here's an example that shows how to retrieve a user's recent activities.
This is a wrapper around getLoggedInAthleteActivities.
from strava_connector.connector import Connector
connector = Connector(".tokens_client.json",".tokens_strava.json")
res = connector.getLoggedInAthleteActivities(page=1, per_page=3)
Authentication workflow
Run the following steps.
Step 1
You have to first execute the first step (Create your App/API Connection) presented in this amazing tutorial by Benji Knights Johnson.
As a result, you will have received your client_id and your client_secret.
Step 2
We need to run an initial authentication.
Run the following code interactively in a python shell and replace the fake client_id and client_secret with the ones obtained in the previous step.
from strava_connector import initial_auth
client_id = "8xxxxxxxxxx1"
client_secret = "axxxxxxxxxxxxxxxxxxxxxxxxxc"
initial_auth(client_id, client_secret)
This will prompt you to click on a link and the dialogue will look something like this:
Click on the following authentication url.
You will be redirected and have to click 'Authorize'.
This redirects to a domain that does not resolve.
Click here. # On MacOs, you can do option+left mouse on this link.
Paste the full url in here.
http://localhost/exchange_token?state=&code=2xxxxxxxxxxxxx // redacted
{'client_secret': 'axxxxxxxxxxxxxxxxxxxxxxxxxc', 'client_id': '8xxxxxxxxxx1'}
{
'token_type': 'Bearer',
'expires_at': 1714407867,
'expires_in': 20187,
'refresh_token': '7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxb',
'access_token': '6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa',
'athlete': { // redacted }
}
This creates the two required files, .tokens_client.json and .tokens_strava.json.
AI warning
I heavily used Github's Copilot as an advanced autocomplete
for the creation of the get_... methods and for writing the test_get_... methods.
Credits
- Strava authentication tutorial by Benji Knights Johnson
- This package was created with
cookiecutterandthomascamminady/cookiecutter-pypackage, a fork ofaudreyr/cookiecutter-pypackage. - Documentation via pdoc
Metadata
Release files for strava_connector 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strava_connector-0.2.2.tar.gz | 7.3 kB | Without provenance | Details for strava_connector-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strava_connector-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for strava_connector-0.2.2-py3-none-any.whl |
Total release size: 14.4 kB
Release files / strava_connector-0.2.2.tar.gz
| Download URL | strava_connector-0.2.2.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b190b8275bd078a937081d9bc8ff9e87ac3194a7856dda2e7c9f0bc4751d801
|
|
BLAKE2b-256 checksum How to use checksums |
ab95f5413693684b94228a50349b2bb30bbff48a1af513cf05b236105c3fbf91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.11 Darwin/23.4.0
|
Release files / strava_connector-0.2.2-py3-none-any.whl
| Download URL | strava_connector-0.2.2-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f861c4a698aa6cceea7296ca855d576d0ca6552b11a5860bdd56191b122b8a4c
|
|
BLAKE2b-256 checksum How to use checksums |
395395bcc4caba04924e0c1a00b9931e0f6cab79161bc995b14cac9322112b4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.11 Darwin/23.4.0
|
Security for strava_connector 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.