Integration / WEAR API LAB

Wearable API integration: a practical starting guide

Choose the right access route, define a usable data contract, and build a sync process that survives delayed, missing, and repeated records.

Neon typography card reading Wearable API Integration, with connected device and data symbols and WearAPI.com branding.

A wearable API integration begins with a product question: what should the application help someone understand or do? A live workout display, a weekly activity report, and a sleep journal need different data paths. Treating them as the same integration can produce an impressive connection screen followed by unreliable features.

This guide develops a small, testable integration: import completed workouts and display their duration, activity type, and available heart rate summary. The architecture is an example you can adapt to your application. For a wider map of terminology and access methods, start with the wearable API overview.

Write the data requirement first

Describe the feature in terms that can become acceptance criteria. For the workout example, the requirement might be: after a connected source finishes syncing, show each completed workout once, preserve its start time, and explain when heart rate information is unavailable. This is much more useful than asking for access to every supported metric.

For each field, record its required resolution, acceptable delay, and fallback. A weekly chart can tolerate a later refresh more easily than a live training screen. A workout can remain useful without a heart rate summary, while a heart rate chart cannot. Distinguish an essential input from a decorative addition before requesting permission.

Also define the supported audience. An application for one watch family has different constraints from a product spanning watches, rings, and chest straps. A narrow first release makes compatibility claims easier to verify.

Choose an access route

There are three useful architectural starting points. Direct device access reads from a sensor or device SDK close to where measurement happens. This can suit interactive experiences, but the integration must account for connection state, app lifecycle, and whatever data the device actually exposes. A successful Bluetooth pairing does not establish access to every metric visible in the manufacturer's app.

A local health store exchanges records with permission on a person's phone. This route can consolidate data supplied by participating apps, but the store contains what those apps write. It should not be treated as a guaranteed live feed from every paired wearable. The Health Connect and HealthKit comparison examines this path in more detail.

A vendor cloud API reads information held by a provider after its own synchronization pipeline. It can suit server-side reporting when access is available, but freshness depends on the full journey from device to vendor account. Check developer eligibility, supported regions, data types, and access conditions before designing around a provider.

One product may use several routes. Keep them explicit: a live strap measurement and yesterday's imported workout are separate sources, even when both contain heart rate.

Connect access to a visible purpose

Ask for permissions when the associated feature becomes useful. Explain the requested records, the destination of copied data, and the consequence of declining. Someone who only wants a workout list should not need to approve unrelated sleep access.

For a cloud integration using OAuth, separate the user's authorization from the application's own account session. The OAuth 2.0 authorization framework defines scoped access tokens and optional refresh tokens; a provider's supported flow and security guidance determine the implementation details. Do not assume every provider issues a refresh token or grants all requested scopes.

Represent connection state explicitly: waiting for authorization, connected, reconnect required, or disconnected. Keep a failed data request separate from consent withdrawal. A temporary provider error should not send the person through onboarding again. Conversely, repeated retries cannot repair revoked access. Plan deletion and retention behavior alongside the connection flow; the consent and security guide covers that boundary.

Define a small normalization contract

Normalize the fields your feature uses, while preserving enough source context to explain them. For a completed workout, start with a source identifier, provider record identifier, activity type, start and end instants, original time zone information where supplied, and explicitly named units. Keep the source's original activity label when mapping it to your own categories.

A compact conceptual record might look like this:

{
  "source": "example-watch-import",
  "source_record_id": "workout-204",
  "kind": "workout",
  "started_at": "2024-03-18T07:00:00Z",
  "ended_at": "2024-03-18T07:32:00Z",
  "activity": "walking",
  "average_heart_rate_bpm": null,
  "heart_rate_status": "not_provided"
}

These are illustrative fields, not a WearAPI.com endpoint. The missing average is intentional. Storing zero would turn unavailable information into a measurement. Preserve distinctions among unsupported, not supplied, not authorized where knowable, and temporarily delayed. Only expose a reason that the source actually lets your application determine.

Keep import time separate from measurement time. A workout recorded on Monday and received on Wednesday belongs to Monday's activity history, while Wednesday describes freshness.

Add validation at the normalization boundary. If an end instant precedes its start, flag the record for investigation rather than displaying a negative workout duration. If a field uses an unfamiliar unit, retain the source description and withhold the normalized value until the conversion is defined. Route a malformed record into a recoverable error path without discarding unrelated valid records from the same batch. Keep a version number for the mapping logic so a later correction can identify which imported records need reprocessing. This makes a small adapter change traceable when it alters an existing chart.

Make synchronization repeatable

Build the importer so processing the same provider record again updates the same local item. A practical identity key combines the connection, source, and provider record identifier. Provider identifiers can have a limited namespace, so using a bare identifier across all accounts invites collisions.

Process one page or batch at a time. Validate its structure, transform supported records, persist the changes, and then advance the checkpoint. Saving a checkpoint before saving the data can skip records permanently after a crash. If storage supports transactions, use one for changes that must succeed together.

For transient failures, use bounded retries with increasing delays and respect any provider retry guidance. Limit concurrent work per connection. A scheduled sync and a manual refresh should not independently refresh the same token or race to move the same checkpoint. Invalid requests need investigation rather than an endless retry loop.

Plan for corrections as well as additions. Workouts may arrive late, change, or disappear at the source. Use the provider's supported change mechanism where available. Otherwise, document a bounded reconciliation strategy and its limitations. Test that reprocessing an overlapping window does not duplicate a workout.

Test the inconvenient cases

A useful test set is a collection of realistic records and connection states, not just one successful response. Include two workouts with the same display name, a session crossing midnight, an empty page with another page available, and a record that gains a heart rate summary during a later import.

  • Import the same batch twice and confirm the visible workout count stays unchanged.
  • Interrupt processing between storage and checkpoint advancement, then resume it.
  • Revoke one optional permission and verify that unrelated features remain usable.
  • Import a workout through two routes and check the source-selection policy.
  • Move the display time zone and confirm that absolute duration remains consistent.
  • Feed an unknown activity code and preserve the source label instead of guessing.

Duplicate observations from different routes require a separate decision from repeated delivery of the same record. Do not silently merge workouts using timestamps alone. Two people can share device accounts, clocks can drift, and a person can record an activity on two devices. Preserve provenance and make your matching policy reviewable.

Evaluate the whole integration cost

When choosing a provider, compare access conditions, useful data coverage, available test fixtures, correction behavior, and support expectations alongside pricing. A lower subscription cost can still mean more engineering work if the data arrives unpredictably or identifiers change between exports.

Measure operational success with signals such as last successful import, age of newest source data, failed batches, and reconnect requests. Avoid logging raw health values or tokens to obtain those metrics. The integration cost planning page offers a framework for separating provider charges from engineering and ongoing maintenance.

Start with one trustworthy feature

A strong first integration earns confidence through a small promise: the right records, with clear provenance, at a useful cadence. Establish that behavior with one source and one feature before widening coverage. Use the implementation checklists to turn the contract, permission flow, and recovery cases into a repeatable review for the next device family.