StravaApiLib 1.0.4

dotnet add package StravaApiLib --version 1.0.4
                    
NuGet\Install-Package StravaApiLib -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StravaApiLib" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StravaApiLib" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="StravaApiLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StravaApiLib --version 1.0.4
                    
#r "nuget: StravaApiLib, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package StravaApiLib@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StravaApiLib&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=StravaApiLib&version=1.0.4
                    
Install as a Cake Tool

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.

  1. 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

  1. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 81 5/4/2026
1.0.3 98 4/28/2026
1.0.2 99 4/24/2026
1.0.1 89 4/24/2026
1.0.0 91 4/24/2026