StravaApiLib 1.0.4
dotnet add package StravaApiLib --version 1.0.4
NuGet\Install-Package StravaApiLib -Version 1.0.4
<PackageReference Include="StravaApiLib" Version="1.0.4" />
<PackageVersion Include="StravaApiLib" Version="1.0.4" />
<PackageReference Include="StravaApiLib" />
paket add StravaApiLib --version 1.0.4
#r "nuget: StravaApiLib, 1.0.4"
#:package StravaApiLib@1.0.4
#addin nuget:?package=StravaApiLib&version=1.0.4
#tool nuget:?package=StravaApiLib&version=1.0.4
StravaApiLib
A lightweight .NET wrapper for the Strava API v3.
This library simplifies working with the Strava API by handling:
- OAuth token refresh automatically
- Secure API authentication
- Typed DTO models
- Clean and minimal API surface
🚀 Features
- Automatic access token refresh (uses refresh token internally)
- Strongly typed DTOs
- Simple async API methods
- Minimal setup required after OAuth
📦 Supported Endpoints
- Athlete profile
- Athlete statistics
- Activities (paginated)
- Activity details
- Gear details
More endpoints may be added in future updates.
🔐 Authentication Overview
Strava uses OAuth2 authentication.
There are two ways to use this library:
Option 1: Using a Refresh Token
Once you have a refresh token, you can use the API directly:
var api = new StravaApi(clientId, clientSecret, refreshToken, 30);
Option 2: Full OAuth Flow (First-time setup only)
Use this if you do NOT yet have a refresh token.
- Generate authorization URL
var url = StravaApi.GetAuthorizationUrl(clientId, redirectUri);
Open this URL in a browser and let the user log in.
After approval, Strava will redirect to: https://your-redirect-uri?code=AUTH_CODE
- Exchange code for tokens
var (accessToken, refreshToken) = await StravaApi.ExchangeCodeAsync(clientId, clientSecret, codeFromRedirect);
👉 Save the refreshToken — this is what you use long-term. The accessToken is short-lived and used internally by Strava for API requests. It is returned for completeness, but it is not required for using this library, since the library automatically manages token refresh internally.
🏁 Example Usage
var api = new StravaApi(clientId, clientSecret, refreshToken, 30);
// Athlete
var athlete = await api.GetAthleteAsync();
// Activities
var activities = await api.GetActivitiesAsync(page: 1, perPage: 30);
// Activity details
var activity = await api.GetActivityDetailsAsync(activityId);
// Stats
var stats = await api.GetAthleteStatsAsync(athlete.Id);
// Gear
var gear = await api.GetGearAsync(athlete.Shoes.First().Id);
Installation
Install via NuGet:
dotnet add package StravaApiLib
⚠️ Notes
Access tokens are handled automatically internally Refresh tokens must be securely stored by the consumer Authorization codes are single-use and expire quickly Redirect URI must match your Strava app settings exactly
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Http (>= 10.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.