Withings.NET 4.0.1

dotnet add package Withings.NET --version 4.0.1
                    
NuGet\Install-Package Withings.NET -Version 4.0.1
                    
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="Withings.NET" Version="4.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Withings.NET" Version="4.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Withings.NET" />
                    
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 Withings.NET --version 4.0.1
                    
#r "nuget: Withings.NET, 4.0.1"
                    
#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 Withings.NET@4.0.1
                    
#: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=Withings.NET&version=4.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Withings.NET&version=4.0.1
                    
Install as a Cake Tool

Withings.NET

.NET client for the Withings Health Data API (OAuth 2.0).

NuGet

Requirements

  • .NET 8.0, 9.0, or 10.0

Installation

dotnet add package Withings.NET

Quick Start

1. Configure Credentials

var credentials = new WithingsCredentials();
credentials.SetClientProperties("your_client_id", "your_client_secret");
credentials.SetCallbackUrl("http://localhost:8585/callback");

2. OAuth 2.0 Authorization

var authenticator = new Authenticator(credentials);

// Generate the authorization URL and redirect the user
var url = authenticator.GetAuthCodeUrl("user.info,user.metrics,user.activity", state);

// After the user authorizes, exchange the code for tokens
var token = await authenticator.GetAccessToken(authorizationCode);

// Refresh tokens when they expire
var newToken = await authenticator.RefreshAccessToken(token.RefreshToken);

3. Fetch Health Data

var client = new WithingsClient(credentials);

// Activity measures
var activity = await client.GetActivityMeasures(startDate, endDate, userId, accessToken);

// Body measures
var body = await client.GetBodyMeasures(userId, startDate, endDate, accessToken);

// Sleep summary
var sleep = await client.GetSleepSummary("2024-01-01", "2024-01-31", accessToken);

// Sleep measures
var sleepData = await client.GetSleepMeasures(userId, startDate, endDate, accessToken);

// Workouts
var workouts = await client.GetWorkouts("2024-01-01", "2024-01-31", accessToken);

// Intraday activity
var intraday = await client.GetIntraDayActivity(userId, startDate, endDate, accessToken);

// Heart
var heartList = await client.GetHeartList(startDate, endDate, accessToken);
var recording = await client.GetHeartRecording(signalId, accessToken);

// User
var devices = await client.GetDevices(accessToken);
var goals = await client.GetGoals(accessToken);

// Webhook subscriptions
await client.Subscribe(callbackUrl, appli, accessToken);
var subscriptions = await client.ListSubscriptions(appli, accessToken);
await client.RevokeSubscription(callbackUrl, appli, accessToken);

Development

Running Unit Tests

dotnet test --filter "TestCategory!=E2E"

Running E2E Tests

E2E tests run against the live Withings API. You need to bootstrap OAuth tokens first.

  1. Create a .env file in the project root:
WITHINGS_CLIENT_ID=your_client_id
WITHINGS_CLIENT_SECRET=your_client_secret
WITHINGS_CALLBACK_URL=http://localhost:8585/callback
WITHINGS_REFRESH_TOKEN=
WITHINGS_USER_ID=
  1. Run the bootstrap script to obtain tokens:
./scripts/bootstrap-token.sh
  1. Run E2E tests:
dotnet test --filter "TestCategory=E2E" -f net10.0

The E2E test suite automatically saves new refresh tokens back to .env after each run (Withings refresh tokens are single-use).

API Reference

Class Description
Authenticator OAuth 2.0 authorization and token management
WithingsClient API client for health data endpoints
OAuthToken Token response with access token, refresh token, and user ID
WithingsApiException Exception thrown for non-zero API status codes

License

See LICENSE for details.

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 is compatible.  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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
4.0.1 117 4/5/2026
4.0.0 3,100 6/9/2017
3.2.2 3,233 5/10/2017
3.2.1 3,161 4/19/2017
3.1.1 3,129 4/12/2017
3.0.2 3,423 4/9/2017
3.0.1 3,087 4/6/2017
3.0.0 3,143 4/5/2017
2.1.1 3,357 4/5/2017