Actions11
- User Actions
- Measure Actions
- Sleep Actions
- Activity Actions
Overview
This node integrates with the Withings API to retrieve sleep summary data for a user. It is designed to fetch aggregated sleep information, such as total sleep duration and quality metrics, over a specified time range or other filtering criteria.
Common scenarios where this node is beneficial include:
- Monitoring sleep patterns over time for health and wellness applications.
- Aggregating sleep data to correlate with other health metrics like activity or heart rate.
- Automating reports or alerts based on sleep quality summaries.
For example, a user could configure the node to get a weekly summary of their sleep data, filtered by start and end dates, to analyze trends in their sleep habits.
Properties
| Name | Meaning |
|---|---|
| Additional Fields | Optional filters for data retrieval: |
| - Start Date: Start timestamp for data retrieval | |
| - End Date: End timestamp for data retrieval | |
| - Last Update: Retrieve only data updated after this timestamp | |
| - Offset: Skip a number of records (for pagination) | |
| Data Fields | Types of sleep data to retrieve (optional): |
| - HR: Heart rate data | |
| - RR: Respiration rate data | |
| - SNORING: Snoring data |
Output
The node outputs JSON objects containing the sleep summary data retrieved from the Withings API. The structure includes:
success: Boolean indicating if the request was successful.resource: The resource type, here always"sleep".operation: The operation performed, here"getsummary".- Other fields depend on the API response body and typically include aggregated sleep metrics such as total sleep time, sleep phases, and possibly selected data fields if requested.
If the API returns an error, the output JSON will contain:
success: falseerror: Error message stringstatus: HTTP status code or API error codeerrorCode: Specific error identifier if availableresourceandoperationfor context
The node does not output binary data.
Dependencies
- Requires an OAuth2 API credential for authenticating with the Withings API.
- The node makes HTTP GET requests to Withings endpoints under
https://wbsapi.withings.net/v2/sleep. - Proper configuration of the OAuth2 credentials with required scopes is necessary.
- Network connectivity to Withings API endpoints is required.
Troubleshooting
Common Issues
- Authentication errors: Invalid, expired, or revoked tokens can cause failures.
- API rate limits or temporary unavailability: The node implements retries with exponential backoff but may still fail if limits are exceeded.
- Incorrect date formats: Input dates must be valid timestamps; otherwise, the API may reject the request.
- Missing or incorrect OAuth2 credentials: Without proper credentials, the node cannot authenticate.
Error Messages and Resolutions
- Errors mentioning token issues (e.g., "unauthorized", "expired", "invalid") suggest re-authenticating the Withings account in n8n credentials.
- API errors with status codes other than 0 indicate problems returned by Withings API; check the error message for details.
- If the node fails after multiple attempts, verify that the Withings developer account is active and has the correct permissions.
- Temporary network or API issues may require retrying after some time.