> ## Documentation Index
> Fetch the complete documentation index at: https://openwearables.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Polar API Integration

> Connect Polar devices via AccessLink API with OAuth 2.0. Syncs workouts, sleep, daily activity, continuous HR, Nightly Recharge, and cardio load. Requires Client ID and Secret from Polar AccessLink Admin.

> [!NOTE]
>
> **Need help with your Polar integration?** Pop into our [Discord](https://discord.gg/qrcfFnNE6H) if you have questions or want to discover how Open Wearables can solve your problems.

## Overview

Polar provides access to exercise, daily activity, sleep, and heart rate data from Polar devices through the [AccessLink API](https://www.polar.com/accesslink-api). The integration uses OAuth 2.0 for authentication and pull-based syncing to fetch data.

### Supported data types

| Data Type | Support |
| - | - |
| Workouts / Exercises | Yes (with optional HR samples, zones, route) |
| Sleep (with stages) | Yes — Polar doesn't report efficiency, so it's derived as Polar Flow's actual sleep share: the night minus its interruptions, over the night |
| Daily activity (steps, calories) | Yes, plus timestamped step samples within the day |
| Continuous heart rate | Yes |
| Nightly Recharge / Recovery | Yes — recovery score, plus overnight HRV (RMSSD) and breathing rate as one day value per night (`resolution=1day`) |
| Cardio Load | Yes |
| Sleepwise Alertness | Yes (requires Polar Sleepwise subscription) |
| Sleepwise Circadian Bedtime | Yes (requires Polar Sleepwise subscription) |
| Body Temperature | Yes (requires Polar Elixir device) |
| Sleep Skin Temperature | Yes (requires Polar Elixir device) |
| SpO2 | Yes (requires Polar Elixir device) |
| Wrist ECG | Yes (requires Polar Elixir device) |

### Data delivery

| Method | Description |
| - | - |
| **Polling (pull) — Exercises** | Open Wearables fetches exercises via the AccessLink v3 API (`/v3/exercises`). Returns all exercises available in Polar Flow for the connected user. |
| **Polling (pull) — 24/7 data** | Sleep, daily activity, continuous HR, Nightly Recharge, cardio load, and Elixir/Sleepwise metrics are fetched via range endpoints covering the last 90 days. |
| **Webhooks (push)** | Polar sends a lightweight notification on each event (exercise, sleep, activity, etc.). Open Wearables acknowledges immediately and enqueues a targeted sync for the affected data type. |

> [!NOTE]
>
> Webhook delivery requires a registered webhook subscription and `POLAR_WEBHOOK_SIGNATURE_SECRET` set in your environment. See the configuration step below.

## What you need by the end

* **App credentials**: Client ID + Client Secret from the Polar AccessLink admin panel
* **Redirect URI** registered in your Polar application

## Prerequisites

* A [Polar Flow](https://flow.polar.com) account

## Application walkthrough

**1. Create a Polar Flow account**

If you don't have one yet, create a free account at [flow.polar.com](https://flow.polar.com).

This is the same account used by Polar device owners - no separate developer account is needed.

**2. Register your application at Polar AccessLink**

Go to the [Polar AccessLink Admin](https://admin.polaraccesslink.com) and sign in with your Polar Flow credentials.

Click **Create client** to start the registration process. You'll go through four tabs:

**1. Contractual Information**

* Fill in your organization details (name, address, country)
* Toggle "I intend to integrate on behalf of a client or third-party organization" if applicable
* Accept the AccessLink Limited License Agreement

**2. Application Information**

* **Application Name**: Your app name (e.g. "Open Wearables")
* **Business contact (email)**: Your contact email
* **Description**: Brief description of your application
* **Application Web site**: Your app's website (optional)
* **Authorization redirect URL**: Your OAuth callback URL. Open Wearables derives this from your `API_BASE_URL` as `{API_BASE_URL}/api/v1/oauth/polar/callback`, so register that exact URL here, e.g. `http://localhost:8000/api/v1/oauth/polar/callback` for local development.
* **Available data types**: Enable all three - **Exercise data**, **Daily activity data**, **Physical information data**

**3. Check Information**

Review the summary of your organization and application details, then click **Confirm**.

**4. Credentials**

After confirmation, you'll see your:

* **Client ID**
* **Client Secret**

> [!WARNING]
>
> The Client ID and Client Secret are **shown only once**. Copy and store them immediately. If you lose them, you'll need to create new credentials from the Admin tool.

**3. Configure credentials in Open Wearables**

Add the following to your `.env` file:

```bash theme={null}
# Public base URL of your API. The OAuth redirect URI is derived from this as
# {API_BASE_URL}/api/v1/oauth/polar/callback.
API_BASE_URL=http://localhost:8000

#--- Polar ---#
POLAR_CLIENT_ID=your-polar-client-id
POLAR_CLIENT_SECRET=your-polar-client-secret
# Optional — required only if using webhooks (set automatically on first registration)
POLAR_WEBHOOK_SIGNATURE_SECRET=
```

**Configuration details:**

| Variable | Description |
| - | - |
| `API_BASE_URL` | Public base URL of your API. The OAuth redirect URI is derived from it as `{API_BASE_URL}/api/v1/oauth/polar/callback`, which must match the Authorization redirect URL registered in your Polar application |
| `POLAR_CLIENT_ID` | Client ID from the Polar AccessLink Admin panel |
| `POLAR_CLIENT_SECRET` | Client Secret from the Polar AccessLink Admin panel |
| `POLAR_WEBHOOK_SIGNATURE_SECRET` | HMAC-SHA256 signing secret returned by Polar on webhook creation. Returned once — save it immediately. Used to verify incoming webhook payloads. |

> [!NOTE]
>
> The OAuth scope is hardcoded to `accesslink.read_all` which grants full read access to the AccessLink API. No additional scope configuration is needed.

**4. Connect a user via OAuth**

With credentials configured and your Open Wearables instance running, initiate the OAuth flow to connect a user's Polar account.

**1. Get the authorization URL:**

```bash theme={null}
curl -X GET "http://localhost:8000/api/v1/oauth/polar/authorize?user_id={user_id}&redirect_uri=http://localhost:3000/users/{user_id}" \
  -H "X-Open-Wearables-API-Key: YOUR_API_KEY"
```

**Response:**

```json theme={null}
{
  "authorization_url": "https://flow.polar.com/oauth2/authorization?client_id=...&redirect_uri=...&response_type=code&scope=accesslink.read_all&state=...",
  "state": "abc123..."
}
```

**2. Redirect the user** to the `authorization_url`. They will log in to Polar Flow and authorize your app.

**3. Polar redirects back** to the callback URI derived from `API_BASE_URL` (`{API_BASE_URL}/api/v1/oauth/polar/callback`). Open Wearables automatically exchanges the authorization code for access tokens and registers the user with the Polar API.

**4. Verify the connection** was created:

```bash theme={null}
curl -X GET "http://localhost:8000/api/v1/users/{user_id}/connections" \
  -H "X-Open-Wearables-API-Key: YOUR_API_KEY"
```

You should see a connection with `"provider": "polar"` and `"status": "active"`.

> [!NOTE]
>
> The `redirect_uri` parameter in the authorize call is where the **user** is sent after the flow completes (e.g., back to your app). This is separate from the **server-side** OAuth callback (`{API_BASE_URL}/api/v1/oauth/polar/callback`) that Polar sends the authorization code to.

**5. Sync data**

An initial sync is triggered automatically after a successful OAuth connection. To manually sync or fetch data:

```bash theme={null}
# Sync all data types
curl -X POST "http://localhost:8000/api/v1/providers/polar/users/{user_id}/sync?data_type=all" \
  -H "X-Open-Wearables-API-Key: YOUR_API_KEY"
```

> [!NOTE]
>
> Exercises are fetched from `/v3/exercises` which returns all exercises available in Polar Flow for the connected user (no date filter). 24/7 data (sleep, activity, HR, etc.) is fetched over a 90-day lookback window using range endpoints.

**6. Verify the integration**

Once data has synced, fetch it via the Open Wearables API:

```bash theme={null}
# Fetch workouts
curl -X GET "http://localhost:8000/api/v1/users/{user_id}/events/workouts?start_date=2026-01-01T00:00:00Z&end_date=2026-02-01T00:00:00Z" \
  -H "X-Open-Wearables-API-Key: YOUR_API_KEY"

# Fetch sleep records
curl -X GET "http://localhost:8000/api/v1/users/{user_id}/events/sleep?start_date=2026-01-01T00:00:00Z&end_date=2026-02-01T00:00:00Z" \
  -H "X-Open-Wearables-API-Key: YOUR_API_KEY"

# Fetch daily activity
curl -X GET "http://localhost:8000/api/v1/users/{user_id}/events/daily-activity?start_date=2026-01-01T00:00:00Z&end_date=2026-02-01T00:00:00Z" \
  -H "X-Open-Wearables-API-Key: YOUR_API_KEY"
```

You can also fetch raw Polar exercise data with optional samples, zones, and route data:

```bash theme={null}
# Fetch Polar exercises with HR samples and route
curl -X GET "http://localhost:8000/api/v1/vendor-workouts/polar/users/{user_id}/workouts?samples=true&zones=true&route=true" \
  -H "X-Open-Wearables-API-Key: YOUR_API_KEY"
```

If data is returned, your Polar integration is working end-to-end.

## Rate Limits

Polar AccessLink API uses dynamic rate limits that scale with your registered user count:

| Limit | Formula |
| - | - |
| Per 15 minutes | 500 + (registered users x 20) |
| Per 24 hours | 5,000 + (registered users x 100) |

Rate limit headers are included in every response: `RateLimit-Usage`, `RateLimit-Limit`, `RateLimit-Reset`.

## Next Steps

> [card] [API Reference](https://openwearables.io/docs/api-reference/introduction.md)
>
> Explore the Open Wearables API endpoints.

> [card] [Architecture](https://openwearables.io/docs/architecture/system-overview.md)
>
> Understand the overall system architecture.

## Support

> [!NOTE]
>
> **Need Help?**
>
> * Join our [Discord](https://discord.gg/qrcfFnNE6H) and ask a question.
> * Check [GitHub Discussions](https://github.com/the-momentum/open-wearables/discussions).
> * Check the [Polar AccessLink API Documentation](https://www.polar.com/accesslink-api).
> * Contact Polar developer support: [b2bhelpdesk@polar.com](mailto:b2bhelpdesk@polar.com)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.