### Device Setup WebView URLs
Source: https://developer.withings.com/sdk/v2/tree/sdk-webviews/device-setup-webview
Examples of URLs to open the Device Setup WebView for specific device models. The `device_model` parameter determines which device flow is initiated. Includes examples for both standard and HIPAA cloud environments.
```URL
https://inappviews.withings.com/sdk/setup?csrf_token=j34de463gecje...689jhg6&device_model=6
```
```URL
https://inappviews.us.withingsmed.com/sdk/setup?csrf_token=j34de463gecje...689jhg6&device_model=6
```
--------------------------------
### Withings Device Setup Overview
Source: https://developer.withings.com/sdk/v2/tree/overview/device-setup
Provides a technical overview of the initial setup flow for Withings devices. It highlights the use of Bluetooth LE for device interaction and explains the two installation modes: Wi-Fi and Bluetooth LE sync.
```APIDOC
Device Model Compatibility:
Device Model | Device Category | Wi-Fi Sync Mode | Bluetooth LE Sync Mode
---|---|---|---
Body | Smart scale | Yes | Yes
Body+ | Smart scale | Yes | Yes
BPM Connect | Smart blood pressure monitor | Yes | Yes
Thermo | Smart thermometer | Yes | Yes
Sleep | Smart sleep tracking mat | Yes | No
Move | Activity tracker | No | Yes
Pulse HR | Activity tracker | No | Yes
```
--------------------------------
### Program Member ID Integration Example Scenario
Source: https://developer.withings.com/developer-guide/v3/integration-guide/program-member-id/program-member-id-implementation-example
Illustrates a complete user scenario for the Program Member ID integration, starting with device activation and setting an initial baseline weight.
```APIDOC
Scenario: User Activation and Baseline Weight
1. Device Activation:
- User activates their Withings device.
2. Baseline Weight Input:
- User provides an initial baseline weight of 80kg.
This scenario demonstrates the initial steps in integrating with the Withings platform for member ID management.
```
--------------------------------
### Next Step Navigation
Source: https://developer.withings.com/developer-guide/v3/integration-guide/withings-rpm/withings-rpm-overview
A link to the next step in the integration process, which is obtaining credentials for the Withings RPM platform.
```html
Next Get your credentials
```
--------------------------------
### Navigation Links
Source: https://developer.withings.com/developer-guide/v3/integration-guide/withings-rpm/withings-rpm-overview
Contains navigation links for the Withings Developer Portal, including links to the RPM overview, credential acquisition, and user data fetching.
```html
```
--------------------------------
### Withings API - Sample Response (Get User)
Source: https://developer.withings.com/api-reference
Example JSON response for the User v2 - Get API call, detailing user preferences and settings.
```JSON
{
"status": 0,
"body": {
"user": {
"preflang": "fr_FR",
"height": {
"value_measure": 180,
"unit_measure": -2,
"type_measure": 4
},
"sms_reminder": true,
"sms_onboarding": true,
"assistance_onboarding": true,
"category": -6,
"device_types": "[1231,5675]",
"device_models": "[765,15]",
"external_ids": [
{
"type": "string",
"identifier": "string"
}
],
"sms_notification": true,
"icd_codes": "[66,455]"
},
"program": {
"id": 50,
"cohortid": 18035,
"name": "Glucose Care Team",
"timezone": "Europe/Paris"
}
}
}
```
--------------------------------
### WithingsFragment Instance Creation
Source: https://developer.withings.com/sdk/v2/tree/sdk-reference/android/withingsfragment
Provides examples for creating new instances of the WithingsFragment with different configurations, including specifying installation URLs and access tokens.
```kotlin
WithingsFragment.newInstance(myInstallUrl)
WithingsFragment.newInstance(myDevicesUrl, accessToken)
```
--------------------------------
### Withings SDK v2 iOS Installation and Usage
Source: https://developer.withings.com/sdk/v2/tree/sdk-reference/ios
Guides on how to install and use the Withings SDK for iOS, covering sample code, minimum requirements, Swift package installation, manual installation, general usage, integration, and background synchronization.
```APIDOC
Installation & Usage (iOS):
Sample Code: Examples demonstrating SDK functionality.
Minimum Requirements: Specifies the minimum OS and hardware requirements.
Installation:
Swift Package Installation: Instructions for adding the SDK via Swift Package Manager.
Manual Installation: Steps for manual integration.
Usage: General guidelines for using the SDK.
Integration: How to integrate the SDK into your project.
Background Sync: Information on enabling background data synchronization.
```
--------------------------------
### More Links
Source: https://developer.withings.com/developer-guide/v3/integration-guide/withings-rpm/withings-rpm-overview
Additional links for contacting Withings, checking API status, and accessing health solutions and legal information.
```html
```
--------------------------------
### Device Links
Source: https://developer.withings.com/developer-guide/v3/integration-guide/withings-rpm/withings-rpm-overview
Links to various Withings professional devices, providing information for partners interested in integrating with specific hardware.
```html
```
--------------------------------
### Withings Android SDK Sample App
Source: https://developer.withings.com/sdk/v2/tree/sources/android
Access the sample application for the Withings Android SDK to see practical implementation examples and get started quickly.
```github
https://github.com/withings-sdk/withings-sdk-sample-android
```
--------------------------------
### API Reference Links
Source: https://developer.withings.com/developer-guide/v3/integration-guide/withings-rpm/withings-rpm-overview
Provides links to the Withings API Reference documentation, essential for understanding and interacting with the Withings Health Data API.
```html
API Reference
```
--------------------------------
### Withings SDK Integration Steps
Source: https://developer.withings.com/sdk/v2/tree/getting-started/step-by-step
This section details the core steps required to integrate the Withings SDK into a mobile application. It includes installing the SDK, setting up server-side web services for authorization and data handling, and utilizing the Withings API.
```APIDOC
SDK Installation:
- iOS: Refer to [iOS SDK Installation Guide](https://developer.withings.com/sdk/v2/tree/sources/ios)
- Android: Refer to [Android SDK Installation Guide](https://developer.withings.com/sdk/v2/tree/sources/android)
Server Setup:
- Implement required [web-services](https://developer.withings.com/sdk/v2/tree/sdk-webviews/required-web-services).
- Implement [URL redirection](https://developer.withings.com/sdk/v2/tree/sdk-webviews/required-web-services#server-side-webview-url-construction) web service for:
- [Installation webview](https://developer.withings.com/sdk/v2/tree/sdk-webviews/device-setup-webview)
- [Device Settings WebView](https://developer.withings.com/sdk/v2/tree/sdk-webviews/device-settings-webview)
- Implement [Token reception](https://developer.withings.com/sdk/v2/tree/sdk-webviews/required-web-services#token-reception) web service.
API Usage:
- Use the [Withings API](https://developer.withings.com/api-reference) to retrieve end-user data.
```
--------------------------------
### Withings Mobile SDK Integration Guide
Source: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-sdk/integrate-sdk-into-your-app/integrate-sdk-into-your-app-overview
Directs users to the comprehensive guide for integrating the Withings Mobile SDK into their applications. This guide contains detailed instructions and requirements for a successful integration.
```APIDOC
Go to mobile integration guide:
https://developer.withings.com/sdk/#/
```
--------------------------------
### Cellular Integration Guides
Source: https://developer.withings.com/developer-guide/v3/integration-guide/cellular-integration-guides
Guides for integrating Withings devices, covering both Bulkshipment and Dropshipment scenarios. These guides help in distributing Withings devices to members.
```APIDOC
Cellular Integration Guides:
Bulkshipment Integration Guide:
Description: For distributing Withings devices yourself.
Start Integration URL: https://developer.withings.com/developer-guide/v3/integration-guide/bulkship-cellular/bulkship-cellular-overview/
Dropshipment Integration Guide:
Description: For scenarios where Withings ships devices directly to your members.
Start Integration URL: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-cellular/dropship-cellular-overview
```
--------------------------------
### CURL Request Example for Sleep v2 - Get
Source: https://developer.withings.com/api-reference
Example of how to make a POST request to the Withings Sleep v2 - Get endpoint using cURL. This snippet shows the command-line equivalent of the PHP example, including setting the URL, headers, and POST data.
```CURL
curl -X POST https://wbsapi.withings.net/v2/sleep \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d "action=get&startdate=startdate&enddate=enddate&data_fields=data_fields&meastypes=meastypes"
```
--------------------------------
### PHP Request Example for Sleep v2 - Get
Source: https://developer.withings.com/api-reference
Example of how to make a POST request to the Withings Sleep v2 - Get endpoint using PHP cURL. This snippet demonstrates setting the URL, headers, and POST fields, including the authorization token and query parameters.
```PHP
'get',
'startdate' => 'startdate',
'enddate' => 'enddate',
'data_fields' => 'data_fields',
'meastypes' => 'meastypes'
]));
$rsp = curl_exec($ch);
curl_close($ch);
var_dump($rsp);
?>
```
--------------------------------
### Withings API Integration Prerequisites
Source: https://developer.withings.com/sdk/v2/tree/getting-started/before-you-begin
This section details the essential steps and requirements for integrating with the Withings API. It includes reading overview and minimum requirements documentation, setting up web services, understanding platform-specific requirements for iOS and Android, registering as an API partner, and requesting SDK service authorization.
```APIDOC
APIDOC:
Title: Withings API Integration Steps
Description: Steps to integrate with the Withings API.
Steps:
- Read Overview documentation: https://developer.withings.com/sdk/v2/tree/overview/device-setup
- Read Minimum Requirements documentation: https://developer.withings.com/sdk/v2/tree/minimum-requirements
- Set up a server for required web-services: https://developer.withings.com/sdk/v2/tree/sdk-webviews/required-web-services
- Review iOS minimum requirements: https://developer.withings.com/sdk/v2/tree/minimum-requirements#ios
- Review Android minimum requirements: https://developer.withings.com/sdk/v2/tree/minimum-requirements#android
- Register as a Withings API partner: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-sdk/developer-account/create-your-accesses
- Request SDK service authorization: https://developer.withings.com/sdk/v2/tree/getting-started/authorization
```
--------------------------------
### Dropshipment Integration Guide
Source: https://developer.withings.com/developer-guide/v3/integration-guide/sdk-integration-guides
Choose this option if Withings is going to ship the devices to your members. Provides an overview and steps for dropshipment integration.
```markdown
[Start Integration](https://developer.withings.com/developer-guide/v3/integration-guide/dropship-sdk/dropship-sdk-overview)
```
--------------------------------
### CURL Request Example for Get Workouts
Source: https://developer.withings.com/api-reference
A cURL command-line example for fetching workout data from the Withings API, specifying the action, date range, and authorization.
```CURL
curl -X POST https://wbsapi.withings.net/v2/measure \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d "action=getworkouts&startdateymd=2020-07-01&enddateymd=2020-07-02"
```
--------------------------------
### PHP Request Example for Get Workouts
Source: https://developer.withings.com/api-reference
A PHP cURL example demonstrating how to request workout data from the Withings API, including setting the authorization header and POST fields.
```PHP
'getworkouts',
'startdateymd' => '2020-07-01',
'enddateymd' => '2020-07-02'
]));
$rsp = curl_exec($ch);
curl_close($ch);
var_dump($rsp);
?>
```
--------------------------------
### Withings WebViews Overview
Source: https://developer.withings.com/sdk/v2/tree/sdk-webviews/introduction
Provides an overview of the two main WebViews offered by Withings for mobile application integration: the Device Setup WebView and the Device Settings WebView. It explains their primary functions in the user onboarding and device management process.
```html
Introduction
Withings provides two WebViews to be embedded by the parter mobile application:
The Device Setup webview , which guides end users through the installation process and performs Withings-related technical operations under the hood.
The Device settings webview , which allows end users to access devices settings after the installation such as described [here](https://developer.withings.com/sdk/v2/tree/overview/device-settings)
The SDK Webview section provides details on how to implement these WebViews and the related web services.
```
--------------------------------
### Withings SDK Navigation
Source: https://developer.withings.com/sdk/v2/tree/overview/device-setup
Provides links to various sections of the Withings Mobile SDK documentation, including overview, requirements, and specific features like device setup and user data access.
```APIDOC
SDK Overview:
- Device Setup: https://developer.withings.com/sdk/v2/tree/overview/device-setup
- Device Sync: https://developer.withings.com/sdk/v2/tree/overview/device-sync
- Device Settings: https://developer.withings.com/sdk/v2/tree/overview/device-settings
- End User Consent: https://developer.withings.com/sdk/v2/tree/overview/end-user-consent
- User Data Access: https://developer.withings.com/sdk/v2/tree/overview/user-data-access
Minimum Requirements:
- https://developer.withings.com/sdk/v2/tree/minimum-requirements/
Other Features:
- Webviews: https://developer.withings.com/sdk/v2/tree/overview/device-setup/
- Native Packages: https://developer.withings.com/sdk/v2/tree/overview/device-setup/
- Integration Reference: https://developer.withings.com/sdk/v2/tree/overview/device-setup/
- Change Policy: https://developer.withings.com/sdk/v2/tree/overview/device-setup/
Support & Legal:
- FAQ: https://developer.withings.com/sdk/v2/tree/faq/
- Copyright: https://developer.withings.com/sdk/v2/tree/copyright/
- Legal Notice: https://developer.withings.com/sdk/v2/tree/legal-notice/
```
--------------------------------
### WithingsSyncService Usage
Source: https://developer.withings.com/sdk/v2/tree/sdk-reference/android/withingssyncservice
Demonstrates how to get an instance of the WithingsSyncService and start or stop the synchronization process.
```kotlin
WithingsSyncService.get(context).start()
WithingsSyncService.get(context).stop()
```
--------------------------------
### Community Links
Source: https://developer.withings.com/developer-guide/v3/integration-guide/withings-rpm/withings-rpm-overview
Links to Withings' social media and community platforms, used for engagement and support.
```html
```
--------------------------------
### Bulkshipment Integration Guide
Source: https://developer.withings.com/developer-guide/v3/integration-guide/sdk-integration-guides
Choose this option if you're going to distribute the Withings device yourself. Provides an overview and steps for bulk shipment integration.
```markdown
[Start Integration](https://developer.withings.com/developer-guide/v3/integration-guide/bulkship-sdk/bulkship-sdk-overview/)
```
--------------------------------
### Get Raw Data - PHP/CURL Example
Source: https://developer.withings.com/api-reference
This snippet demonstrates how to fetch raw data from the Withings API using PHP and cURL. It includes setting the API endpoint, authorization headers, and POST data for the 'get' action with parameters like hash_deviceid, rawdata_type, startdate, enddate, and offset.
```PHP
'get',
'hash_deviceid' => 'string',
'rawdata_type' => 'int',
'startdate' => 'startdate',
'enddate' => 'enddate',
'offset' => 'offset'
]));
$rsp = curl_exec($ch);
curl_close($ch);
var_dump($rsp);
?>
```
```CURL
curl -X POST \
https://wbsapi.withings.net/v2/rawdata \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'action=get&hash_deviceid=string&rawdata_type=int&startdate=startdate&enddate=enddate&offset=offset'
```
--------------------------------
### Withings Public API Integration Overview
Source: https://developer.withings.com/developer-guide/v3/withings-solutions/app-to-app-solution
Provides a high-level overview of the Withings Public API integration process. It details the steps from user account setup and device configuration to data access via OAuth and API retrieval.
```APIDOC
Withings Public API Integration Flow:
1. User Creates Account and Sets Up Device via Withings App
- User sets up their account and configures their device using the Withings app.
2. User Grants Data Access via OAuth Web Flow
- User authorizes the partner application to access their health data through a secure OAuth process.
3. Device Transmits Data via WiFi or BLE
- Health data is securely sent from the device to Withings' servers using WiFi or Bluetooth Low Energy.
4. Data is Stored in HDS/HIPAA-compliant Cloud
- Health data is stored in a secure cloud environment that adheres to HDS and HIPAA compliance standards.
5. Partner Accesses Data via API
- Partner applications use the user's access token to retrieve health data through the Withings API.
- Real-time notifications and webhooks are available for updated health insights.
```
--------------------------------
### Withings Device Setup WebView Parameters
Source: https://developer.withings.com/sdk/v2/tree/sdk-webviews/device-setup-webview
Details the parameters that can be passed when redirecting to the Withings Device Setup WebView. This includes essential security tokens and optional device model identifiers.
```APIDOC
Parameter Name: csrf_token
Type: string
Required: yes
Comments: The CSRF token is provided when retrieving a new `access_token` using the refresh service.
Parameter Name: device_model
Type: integer
Required: no
Comments: Withings device model to be installed. If not provided, the end user will be prompted to choose the model manually from the available models. Possible values are listed below.
```
--------------------------------
### Withings API Endpoints
Source: https://developer.withings.com/developer-guide/v3/integration-guide/bulkship-cellular/developer-account/create-your-accesses
This section outlines the different cloud environments available for Withings APIs, detailing their certifications, prerequisites, and corresponding endpoints. The APIs are consistent across all cloud environments.
```APIDOC
Cloud Environment Selection:
Cloud Name / Certification | Prerequisites | Endpoint
---|---|---
**EU Medical Cloud / Public Cloud** | GDPR compliant, ISO 27001:2017, and HDS certified. No prerequisites; free access is available. [More about limitations](https://developer.withings.com/v3/withings-solutions/withings-api-plans). | `https://wbsapi.withings.net`
**US Medical Cloud** | HIPAA and GDPR compliant, ISO 27001:2017 certified. Available **only for partners with a signed contract**. | `https://wbsapi.us.withingsmed.net`
```
--------------------------------
### Login Prompt
Source: https://developer.withings.com/developer-guide/v3/integration-guide/withings-rpm/withings-rpm-overview
A UI element indicating that login is required to file a request, likely related to accessing partner-specific features or support.
```html
Login required
Please log in to your Developer Dashboard in order to file a request.
```
--------------------------------
### Withings Survey Get Request (PHP)
Source: https://developer.withings.com/api-reference
Example of how to make a GET request to the Withings Survey API using PHP and cURL. This snippet demonstrates setting up the cURL request, including the URL, POST data with necessary parameters like action, signature, client_id, nonce, surveyid, and lang, and executing the request.
```PHP
'get',
'signature' => 'signature',
'client_id' => 'client_id',
'nonce' => 'string',
'surveyid' => 'string',
'lang' => 'string'
]));
$rsp = curl_exec($ch);
curl_close($ch);
var_dump($rsp);
?>
```
--------------------------------
### Initialize WithingsFragment
Source: https://developer.withings.com/sdk/v2/tree/sdk-reference/android
Demonstrates how to create a new instance of WithingsFragment, either for initial installation or to load devices with an access token.
```kotlin
WithingsFragment.newInstance(myInstallUrl)
WithingsFragment.newInstance(myDevicesUrl, accessToken)
```
--------------------------------
### Withings API Endpoints
Source: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-sdk/developer-account/create-your-accesses
This section outlines the different cloud environments available for Withings API access, detailing their respective certifications, prerequisites, and endpoints. It helps developers choose the correct environment based on their project's requirements.
```APIDOC
Cloud Environment Selection:
Cloud Name / Certification | Prerequisites | Endpoint
---|---|---
**EU Medical Cloud / Public Cloud** | GDPR compliant, ISO 27001:2017, and HDS certified. No prerequisites; free access is available. [More about limitations](https://developer.withings.com/v3/withings-solutions/withings-api-plans). | `https://wbsapi.withings.net`
**US Medical Cloud** | HIPAA and GDPR compliant, ISO 27001:2017 certified. Available **only for partners with a signed contract**. | `https://wbsapi.us.withingsmed.net`
```
--------------------------------
### Get Withings Nudge
Source: https://developer.withings.com/api-reference
Example of how to retrieve details of a specific nudge using the Withings API. Requires signature, client ID, nonce, and the nudge ID.
```php
'get',
'signature' => 'signature',
'client_id' => 'client_id',
'nonce' => 'string',
'nudgeid' => 'id64'
]));
$rsp = curl_exec($ch);
curl_close($ch);
var_dump($rsp);
?>
```
```curl
curl -X POST https://wbsapi.withings.net/v2/nudge \
-d "action=get&signature=signature&client_id=client_id&nonce=string&nudgeid=12345"
```
--------------------------------
### Creating a Withings Application
Source: https://developer.withings.com/developer-guide/v3/integration-guide/bulkship-sdk/developer-account/create-your-accesses
Instructions on how to create a new application within the Withings Partner Hub to obtain the necessary `client_id` and `client_secret` for accessing Withings services. It recommends using a shared professional email address for organizational clarity.
```APIDOC
Creating an application will provide you with the necessary `client_id` and `client_secret` to access Withings services.
[Create your application](https://developer.withings.com/dashboard/)
You can go back to the Developer Dashboard at any time if you want to update or delete your application.
```
--------------------------------
### CURL Request for Withings Get Intraday Activity
Source: https://developer.withings.com/api-reference
Example CURL command to fetch intraday activity data from the Withings API. This demonstrates how to set the authorization header and POST data.
```CURL
curl -X POST https://wbsapi.withings.net/v2/measure \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d "action=getintradayactivity&startdate=startdate&enddate=enddate&data_fields=data_fields"
```
--------------------------------
### JavaScript Example: Obtaining a Nonce for Withings API
Source: https://developer.withings.com/developer-guide/v3/integration-guide/onsite-mode/get-access/sign-your-requests
Demonstrates how to obtain a nonce from the Withings API using JavaScript. It prepares parameters, generates the signature, and makes a POST request.
```javascript
const crypto = require('crypto');
const clientId = 'YOUR_CLIENT_ID';
const clientSecret = 'YOUR_CLIENT_SECRET';
const getNonceUrl = 'https://wbsapi.withings.net/signaturev2/getnonce';
async function getNonce() {
const timestamp = Math.floor(Date.now() / 1000);
const action = 'getnonce';
const message = `${action},${clientId},${timestamp}`;
const signature = crypto.createHmac('sha256', clientSecret).update(message).digest('hex');
const params = new URLSearchParams();
params.append('action', action);
params.append('client_id', clientId);
params.append('timestamp', timestamp.toString());
params.append('signature', signature);
try {
const response = await fetch(getNonceUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: params
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('Nonce obtained:', data.nonce);
return data.nonce;
} catch (error) {
console.error('Error obtaining nonce:', error);
return null;
}
}
getNonce();
```
--------------------------------
### Withings Integration Guides Navigation
Source: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-only/maintain-your-integration/understand-our-timeline-for-notice
Links to various guides for integrating with Withings services, including dropshipment, developer account creation, request signing, and keeping integrations up-to-date.
```APIDOC
Integration Guides:
- Dropshipment Overview: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-only/dropship-only-overview
- Create Developer Account: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-only/developer-account/create-your-accesses
- Sign Requests: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-only/get-access/sign-your-requests
- Keep Integration Up-to-Date: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-only/maintain-your-integration/understand-our-timeline-for-notice
- FAQ: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-only/faq/
- Glossary: https://developer.withings.com/developer-guide/v3/integration-guide/dropship-only/glossary/glossary-page
```
--------------------------------
### PHP Request for Withings Get Intraday Activity
Source: https://developer.withings.com/api-reference
Example PHP code to call the Withings API for intraday activity data. It sets up a cURL request with the necessary headers and POST fields.
```PHP
'getintradayactivity',
'startdate' => 'startdate',
'enddate' => 'enddate',
'data_fields' => 'data_fields'
]));
$rsp = curl_exec($ch);
curl_close($ch);
var_dump($rsp);
?>
```
--------------------------------
### Withings API - Sample Response (Addtorpm)
Source: https://developer.withings.com/api-reference
Example JSON response for the User v2 - Addtorpm API call, showing user and device details.
```JSON
{
"status": 0,
"body": {
"user": {
"code": "490ed603fe9bd2ce10027bdba0c932069cd27085",
"external_id": "3b7a6db0-ec7e-479b-9675-2a3d8d6a7e51"
},
"devices": [
{
"mac_address": "00:24:e4:69:b2:30",
"type": "Scale",
"model": "Body Cardio",
"model_id": 6,
"battery": "medium",
"deviceid": "892359876fd8805ac45bab078c4828692f0276b1",
"timezone": "Europe/Paris",
"last_session_date": 1594159644
}
]
}
}
```
--------------------------------
### Withings Device Setup WebView Base URLs
Source: https://developer.withings.com/sdk/v2/tree/sdk-webviews/device-setup-webview
Provides the base URLs for accessing the Withings Device Setup WebView. One URL is for the standard cloud environment, and the other is for the HIPAA-compliant cloud environment.
```APIDOC
Standard Cloud Base URL:
https://inappviews.withings.com/sdk/setup
HIPAA Cloud Base URL:
https://inappviews.us.withingsmed.com/sdk/setup
```
--------------------------------
### Get User Devices API
Source: https://developer.withings.com/developer-guide/v3/tutorials/troubleshooting-devices
Retrieves a list of a user's devices using the user-v2.getdevice webservice. This is useful for checking device connection times via `first_session_date` and `last_session_date` fields.
```APIDOC
APIDOC:
user-v2.getdevice:
description: Retrieves a list of a user's devices.
parameters:
- name: userid
type: string
description: The ID of the user.
- name: lastsessiondate
type: boolean
description: Whether to include the last session date.
- name: firstsessiondate
type: boolean
description: Whether to include the first session date.
responses:
200 OK:
description: A list of user devices.
content:
application/json:
schema:
type: object
properties:
devices:
type: array
items:
type: object
properties:
deviceid:
type: string
macaddr:
type: string
model:
type: string
modelid:
type: integer
first_session_date:
type: integer
description: Unix timestamp of the first session.
last_session_date:
type: integer
description: Unix timestamp of the last session.
example:
{
"status": 200,
"body": {
"devices": [
{
"deviceid": "12345",
"macaddr": "AA:BB:CC:DD:EE:FF",
"model": "Withings Body",
"modelid": 1,
"first_session_date": 1678886400,
"last_session_date": 1678972800
}
]
}
}
```
--------------------------------
### JavaScript Example: Signing a Withings API Request
Source: https://developer.withings.com/developer-guide/v3/integration-guide/onsite-mode/get-access/sign-your-requests
Illustrates how to sign an actual Withings API request in JavaScript. It takes the nonce, prepares parameters, sorts them, generates the signature, and includes it in the request.
```javascript
const crypto = require('crypto');
const clientId = 'YOUR_CLIENT_ID';
const clientSecret = 'YOUR_CLIENT_SECRET';
const apiBaseUrl = 'https://wbsapi.withings.net/';
async function callWithingsApi(action, params, nonce) {
const requestParams = {
action: action,
client_id: clientId,
nonce: nonce,
...params
};
// Sort parameters by key
const sortedKeys = Object.keys(requestParams).sort();
const message = sortedKeys.map(key => requestParams[key]).join(',');
const signature = crypto.createHmac('sha256', clientSecret).update(message).digest('hex');
const finalParams = new URLSearchParams();
for (const key in requestParams) {
finalParams.append(key, requestParams[key]);
}
finalParams.append('signature', signature);
const url = `${apiBaseUrl}${action.replace('get', '')}`;
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: finalParams
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('API Response:', data);
return data;
} catch (error) {
console.error('Error calling Withings API:', error);
return null;
}
}
// Example usage:
// const nonce = await getNonce(); // Assuming getNonce() is defined as above
// if (nonce) {
// const weightData = await callWithingsApi('getweight', { lastupdate: 1678886400 }, nonce);
// }
```
--------------------------------
### Using WithingsFragment for Installation or Settings
Source: https://developer.withings.com/sdk/v2/tree/sources/changelogs/android/5
Demonstrates how to instantiate the WithingsFragment to handle user redirection for installation or settings. It shows two common use cases: one for general installation and another that includes an access token for specific user settings.
```java
WithingsFragment.newInstance(myInstallUrl)
WithingsFragment.newInstance(myDevicesUrl, accessToken)
```