r/Python Pythonista 1d ago

Showcase A lightweight Python wrapper for the Strava API that makes authentication painless

What My Project Does

Light Strava Client is a minimalist Python wrapper around the Strava API that automates the entire OAuth flow and token management. It provides a clean, typed interface for accessing Strava data while handling all the authentication complexity behind the scenes.
Key features:

  • Automated OAuth flow (just paste the callback URL and you're done)
  • Automatic token refresh handling
  • Type-safe responses using Pydantic
  • Simple to extend with new endpoints
  • No complex dependencies

Target Audience

This is primarily designed for developers who want to quickly prototype or build personal projects with Strava data. While it can be used in production, it's intentionally kept minimal to prioritize hackability and ease of understanding over comprehensive feature coverage.

Comparison

The main alternative is stravalib, which is a mature and feature-complete library. Light Strava Client takes a different approach by offering a minimal, modern (Pydantic, type hints) codebase that prioritizes quick setup and hackability over comprehensive features.

The code is available here: https://github.com/GiovanniGiacometti/Light-Strava-Client

I'd love to hear your thoughts or feature suggestions!

124 Upvotes

16 comments sorted by

13

u/yuppiepuppie 1d ago

Nice! I’ve been building something for my cycling data and was looking into the stava api. I’ll check this out!

Have you had any issues getting an api key, especially with regards to their recent terms and conditions changes that really effect third party apps?

3

u/GioGiac Pythonista 1d ago

Great, I built this utility to help me analyze my running data. Let me know if you find it useful!

I didn't experience particular issues, creating an application is pretty straightforward, but since I'm not interested in building something public I didn't really look into that.

4

u/coldoven 1d ago

License missing

3

u/GioGiac Pythonista 1d ago

Just added, thanks!

5

u/coldoven 1d ago

As good practise, you want to put it into pyproject.toml as well, since then tools like pip-licenses can automatically read it. In some companies, this is mandatory.

1

u/GioGiac Pythonista 8h ago

Thank you for explaining this, I'll add the license to the toml asap :)

3

u/yrubooingmeimryte 1d ago

In what way is your code more "lightweight" than stravalib?

1

u/GioGiac Pythonista 8h ago

I'd say it's a bit more self contained, easy to navigate and quicker to adapt and hack if needed. Stravalib has a more complex codebase in my opinion, but that's because it's a bigger project, which serves other purposes. That's my opinion though, let me know yours :)

2

u/runawayasfastasucan 1d ago

This is really neat!! I think much of the stats on Strava (even that I have access to) is presented in a bad way, and that there are so much more that could be done with the data (comparing similar sessions for instance). Gonne use this in a notebook to see what I can do.

1

u/GioGiac Pythonista 8h ago

I totally agree! Let me know if you find it useful!

2

u/ionburger 1d ago

i have a side project that basically died because i didnt like stravalib, will give it another shot with this

1

u/GioGiac Pythonista 8h ago

Glad to hear that, let me know how it goes!

1

u/OhYourFuckingGod 22h ago

Does it reauth if the refresh token is expired?

3

u/Mkep 19h ago

1

u/OhYourFuckingGod 13h ago

I just glanced at the code but to me it looked like an expired refresh token would fall through the cracks. E.g. would not get initialized, and also not refreshed.

1

u/GioGiac Pythonista 8h ago edited 8h ago

Yes, but you need to explicitly call the verify token method before calling the api, in the way it's done for the only method currently available (the one to retrieve the activities). It has kind of a lazy approach :)