<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom"><channel>
<title>WearAPI.com — Wear API Lab and Guides</title>
<link>https://wearapi.com/</link>
<description>Wearable API guides, technical examples, and complete Wear API Lab articles.</description>
<language>en</language>
<atom:link href="https://wearapi.com/rss.xml" rel="self" type="application/rss+xml"/>
<lastBuildDate>Wed, 30 Sep 2026 21:01:16 +0000</lastBuildDate>
<item>
<title>WearAPI.com | Wear API, Wearable API &amp; Smart Watch Guides</title>
<link>https://wearapi.com/</link>
<guid isPermaLink="true">https://wearapi.com/</guid>
<description>Explore wear API and wearable API guides for smart watches, smart rings, AI clothing, and heart rate monitors. Practical docs and Wear API Lab articles.</description>
</item>
<item>
<title>Wear API Guide: Choose Your Wearable Integration Path | WearAPI.com</title>
<link>https://wearapi.com/wear-api/</link>
<guid isPermaLink="true">https://wearapi.com/wear-api/</guid>
<description>Understand what a wear API can mean, compare device, phone, and cloud access, and plan a wearable integration around the data your app needs.</description>
</item>
<item>
<title>Wearable API Integration and Data Architecture | WearAPI.com</title>
<link>https://wearapi.com/wearable-api/</link>
<guid isPermaLink="true">https://wearapi.com/wearable-api/</guid>
<description>Plan wearable API integrations with clear schemas, source provenance, consent, sync recovery, and practical choices between platform and vendor access.</description>
</item>
<item>
<title>AI Clothing Wear API: Smart Garment Integration Guide | WearAPI.com</title>
<link>https://wearapi.com/ai-clothing-wear-api/</link>
<guid isPermaLink="true">https://wearapi.com/ai-clothing-wear-api/</guid>
<description>Explore AI clothing wear APIs, smart textile sensors, garment calibration, signal quality, and the difference between connected clothing and virtual try-on.</description>
</item>
<item>
<title>Wearable AI Device Development and Edge Inference | WearAPI.com</title>
<link>https://wearapi.com/wearable-ai-device/</link>
<guid isPermaLink="true">https://wearapi.com/wearable-ai-device/</guid>
<description>Plan wearable AI device pipelines, from signal windows and model validation to memory, power, confidence, and on-device inference tradeoffs.</description>
</item>
<item>
<title>Smart Watch Wear API: Sensors, Workouts and Sync | WearAPI.com</title>
<link>https://wearapi.com/smart-watch-wear-api/</link>
<guid isPermaLink="true">https://wearapi.com/smart-watch-wear-api/</guid>
<description>Understand smart watch API routes, Wear OS Health Services, phone health stores, workout sessions, device capabilities, permissions, and battery tradeoffs.</description>
</item>
<item>
<title>Smart Ring Wear API: Sleep, Activity and Data Access | WearAPI.com</title>
<link>https://wearapi.com/smart-ring-wear-api/</link>
<guid isPermaLink="true">https://wearapi.com/smart-ring-wear-api/</guid>
<description>Explore smart ring API integration, sleep sessions, daily summaries, source timestamps, permissions, sync timing, and responsible interpretation.</description>
</item>
<item>
<title>Heart Rate Monitor Wear API and Bluetooth Integration | WearAPI.com</title>
<link>https://wearapi.com/heart-rate-monitor-wear-api/</link>
<guid isPermaLink="true">https://wearapi.com/heart-rate-monitor-wear-api/</guid>
<description>Learn heart rate monitor API concepts, Bluetooth Heart Rate Service measurements, RR intervals, signal context, connection gaps, and data interpretation.</description>
</item>
<item>
<title>Wearable API Docs: Integration Patterns and Examples | WearAPI.com</title>
<link>https://wearapi.com/docs/</link>
<guid isPermaLink="true">https://wearapi.com/docs/</guid>
<description>Explore wearable API integration patterns, a bundled JSON example, sample JavaScript, data contracts, sync states, and practical validation scenarios.</description>
</item>
<item>
<title>Wearable API Pricing and Integration Cost Planning | WearAPI.com</title>
<link>https://wearapi.com/pricing/</link>
<guid isPermaLink="true">https://wearapi.com/pricing/</guid>
<description>WearAPI.com guides are free. Understand provider-specific access, request workloads, testing, and maintenance costs before planning a wearable integration.</description>
</item>
<item>
<title>About WearAPI.com | Independent Wearable API Guidance</title>
<link>https://wearapi.com/about/</link>
<guid isPermaLink="true">https://wearapi.com/about/</guid>
<description>Learn about WearAPI.com, its wearable developer guides, source-based editorial approach, practical examples, and how to suggest a correction.</description>
</item>
<item>
<title>Contact WearAPI.com | Questions, Topics and Corrections</title>
<link>https://wearapi.com/contact/</link>
<guid isPermaLink="true">https://wearapi.com/contact/</guid>
<description>Contact WearAPI.com at info@wearapi.com for wearable API questions, technical corrections, source updates, and ideas for Wear API Lab.</description>
</item>
<item>
<title>Privacy | WearAPI.com</title>
<link>https://wearapi.com/privacy/</link>
<guid isPermaLink="true">https://wearapi.com/privacy/</guid>
<description>Read how WearAPI.com handles its static website features, local examples, email correspondence, and links to external documentation.</description>
</item>
<item>
<title>Terms and Website Use | WearAPI.com</title>
<link>https://wearapi.com/terms/</link>
<guid isPermaLink="true">https://wearapi.com/terms/</guid>
<description>Understand the educational scope of WearAPI.com, illustrative examples, third-party references, and how to report a technical correction.</description>
</item>
<item>
<title>Wear API Lab | Wearable API Tutorials and Engineering Guides</title>
<link>https://wearapi.com/blog/</link>
<guid isPermaLink="true">https://wearapi.com/blog/</guid>
<description>Read Wear API Lab: practical wearable API articles on smart watches, smart rings, AI clothing, heart rate monitors, consent, data quality, and costs.</description>
</item>
<item>
<title>Integration Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/category/integration/</link>
<guid isPermaLink="true">https://wearapi.com/blog/category/integration/</guid>
<description>Wearable integration guides covering API selection, platform access, permission design, and clear data contracts.</description>
</item>
<item>
<title>Devices Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/category/devices/</link>
<guid isPermaLink="true">https://wearapi.com/blog/category/devices/</guid>
<description>Developer guides to smart watches, smart rings, heart rate monitors, and sensor-equipped smart clothing.</description>
</item>
<item>
<title>Engineering Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/category/engineering/</link>
<guid isPermaLink="true">https://wearapi.com/blog/category/engineering/</guid>
<description>Practical wearable engineering guidance for data quality, on-device AI, workload estimates, and integration maintenance.</description>
</item>
<item>
<title>API design Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/api-design/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/api-design/</guid>
<description>Wearable API design articles about access paths, stable schemas, data semantics, and recoverable integrations.</description>
</item>
<item>
<title>Data quality Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/data-quality/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/data-quality/</guid>
<description>Learn to handle missing wearable measurements, timestamps, source context, duplicates, and model input quality.</description>
</item>
<item>
<title>Consent Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/consent/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/consent/</guid>
<description>Wearable consent and permission guides for platform health stores, account connections, and user control.</description>
</item>
<item>
<title>Smart watches Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/smart-watches/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/smart-watches/</guid>
<description>Smart watch API development articles about Health Services, workout sessions, capabilities, and data delivery.</description>
</item>
<item>
<title>Smart rings Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/smart-rings/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/smart-rings/</guid>
<description>Smart ring API guides for sleep data, daily summaries, vendor account access, and meaningful trends.</description>
</item>
<item>
<title>Heart rate Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/heart-rate/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/heart-rate/</guid>
<description>Heart rate monitor integration guidance covering Bluetooth payloads, beats per minute, intervals, and connection gaps.</description>
</item>
<item>
<title>Smart clothing Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/smart-clothing/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/smart-clothing/</guid>
<description>Connected clothing engineering guides about textile sensors, electronics, calibration, signal contracts, and garment use.</description>
</item>
<item>
<title>Edge AI Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/edge-ai/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/edge-ai/</guid>
<description>Wearable edge AI articles about sensor pipelines, on-device inference, model evaluation, and useful confidence states.</description>
</item>
<item>
<title>Cost planning Guides | Wear API Lab | WearAPI.com</title>
<link>https://wearapi.com/blog/tag/cost-planning/</link>
<guid isPermaLink="true">https://wearapi.com/blog/tag/cost-planning/</guid>
<description>Wearable API integration cost planning for request workloads, device testing, maintenance, and provider evaluation.</description>
</item>
<item>
<title>What wearable API integration costs: a planning framework</title>
<link>https://wearapi.com/blog/wearable-api-cost-planning/</link>
<guid isPermaLink="true">https://wearapi.com/blog/wearable-api-cost-planning/</guid>
<description>Build a realistic integration budget from workload assumptions and engineering scope, including the costs hidden behind a successful API request.</description>
<pubDate>Tue, 18 Aug 2026 00:00:00 +0000</pubDate>
<category>Engineering</category>
<content:encoded><![CDATA[
<p>The cost of a wearable API integration is the cost of delivering a dependable feature over time. Provider access, application engineering, infrastructure, device testing, and ongoing maintenance all contribute. A free endpoint can still require substantial work, while a paid integration may be worthwhile if it removes work your team would otherwise own.</p>
<p>Start with a workload and a support boundary, then request commercial terms that match them. The <a href="https://wearapi.com/pricing/">WearAPI.com cost planning page</a> explains the planning categories. This article develops a hypothetical consumer activity app budget without presenting live provider prices or a WearAPI.com service tariff.</p>

<h2 id="define-the-supported-feature">Define the supported feature</h2>
<p>Describe the first release in operational terms. Which device ecosystems will it support? Which records are required? How soon after a source update should they appear? How much history will be imported? What happens when permissions change or a user has two devices recording the same activity?</p>
<p>Keep that scope consistent across estimates. “Support a smartwatch” could mean receiving completed workout summaries from a cloud account, writing a native watch application, or processing live sensor data. Those options have different implementation and testing boundaries. The <a href="https://wearapi.com/wear-api/">Wear API architecture overview</a> helps distinguish the access paths before comparing their cost.</p>
<p>For this worked example, assume a consumer activity diary with three summary collections, scheduled refreshes, and no clinical decision function. Every quantity below is an illustrative planning assumption to replace with measurements from your own integration.</p>

<h2 id="budget-the-work">Budget the work people must perform</h2>
<p>Separate initial delivery from recurring operations. Initial work includes access assessment, provider onboarding, authorization, data mapping, background jobs, user-visible status, and realistic failure handling. Add documentation and support preparation because a successful first import does not explain how someone reconnects later.</p>
<p>Assign estimates to tasks with clear outcomes. “Implement history import with resumable progress and duplicate handling” is easier to assess than “API integration.” Record the assumptions behind each task, such as available test accounts or a confirmed export format. Mark unresolved dependencies as risks instead of silently embedding optimism in the estimate.</p>
<p>For recurring work, include dependency updates, API changes, device and operating system testing, incident response, and support. Convert estimated effort to money using your actual team rates and accounting approach. Keep external fees separate so a change in vendor pricing does not obscure a change in engineering scope.</p>

<h2 id="calculate-steady-workload">Calculate steady-state request volume</h2>
<p>Suppose the app has 1,000 connected users, checks three collections per user, and refreshes each collection twice daily. If each check requires one request, the baseline is 1,000 × 3 × 2 = 6,000 requests per day. This assumes no pagination, token calls, or extra detail fetches.</p>
<p>Add those omitted operations explicitly after testing the provider. If you temporarily reserve an illustrative ten percent allowance for additional requests, the planning total becomes 6,600 requests per day. That allowance is a sensitivity assumption, not an observed retry rate or a recommendation for every application.</p>
<p>Distinguish connected users from active users and request count from returned records. A daily check might return nothing, one summary, or multiple pages. Record those distributions in a pilot. Then produce expected and stressed workloads based on actual behavior instead of relying on a single average.</p>

<h2 id="model-history-imports">Model history imports separately</h2>
<p>Initial history can dominate the request schedule. Imagine that all 1,000 users request 90 days of history for three collections, and the hypothetical endpoint requires one request per user, collection, and day. The initial import would require 1,000 × 3 × 90 = 270,000 requests before retries or pagination.</p>
<p>This example deliberately uses a simple endpoint assumption. A real provider may support date ranges, restrict accessible history, return multiple pages, or expose different collections through different endpoints. Confirm those rules before applying the arithmetic. Do not assume that data visible in a companion app is available through its API.</p>
<p>Plan how backfills share capacity with everyday refreshes. A queue should preserve progress, allow cancellation, and avoid restarting an entire history import after one failure. Show users an understandable status while history arrives. Measure completion time under realistic concurrency so the promised onboarding experience fits the available capacity.</p>

<h2 id="account-for-quotas">Account for quotas and recovery behavior</h2>
<p>Published access limits are part of the cost model even when they carry no direct per-request fee. For example, <a href="https://www.polar.com/accesslink-api/">Polar's AccessLink v3 documentation</a> describes both short and long rate-limit windows, usage headers, and a 429 response when limits are exceeded. Those specific rules illustrate why daily totals alone cannot establish that a workload will fit.</p>
<p>Inspect the documentation for the exact API version you will use. Record how its limits are scoped, what response headers communicate, and whether unsuccessful requests consume capacity. A burst of onboarding traffic can hit a short window even when the daily average looks comfortable.</p>
<p>Include retries as scheduled work with limits, delay, and cancellation. Repeatedly submitting a request that cannot succeed wastes capacity and creates support noise. Decide which failures are retryable, which require a user action, and which should stop the import pending investigation.</p>

<h2 id="estimate-storage-and-processing">Estimate storage and processing with units</h2>
<p>Use returned records to estimate storage. In a separate hypothetical scenario, 1,000 users generate three retained summaries daily, with each normalized record averaging 2,000 bytes. That is 3,000 records and 6,000,000 bytes per day, or 6 megabytes using decimal units. Thirty days would hold 180 megabytes of these records alone.</p>
<p>Add indexes, source payloads if retained, backups, replicas, exports, and diagnostic data separately. A compact summary app and a raw waveform archive have very different storage profiles. State the retention period for each data class and estimate the effect of deletion and reprocessing workflows.</p>
<p>For processing, measure representative jobs: decoding, validation, normalization, deduplication, and aggregation. Use observed execution time and memory to estimate infrastructure under your hosting model. Keep minimum service capacity and workload-dependent costs distinct, especially when a small pilot cannot yet amortize fixed operating expenses.</p>

<h2 id="include-device-testing">Include device testing and support</h2>
<p>Build a support matrix for the combinations you intend to promise: provider, device family, phone platform where relevant, operating system, and important account conditions. Testing every possible combination may be impractical, so choose coverage deliberately and publish a scope that matches it.</p>
<p>Budget for devices, replacement accessories, test accounts where needed, and the time to produce realistic recordings. Include delayed syncing, travel across time zones, app restarts, revoked access, and reconnecting after an extended absence. These scenarios exercise product behavior that an API fixture cannot fully reproduce.</p>
<p>Estimate support effort from pilot observations rather than invented industry averages. Track which problems users can resolve through clear instructions and which require an engineer. This is an integration budget for the stated consumer feature; it does not establish validation requirements or suitability for a different medical use.</p>

<h2 id="compare-complete-options">Compare complete options with common assumptions</h2>
<p>When comparing direct integrations with an aggregation provider, use the same users, data types, history, refresh expectations, and support scope. Ask what the commercial quote includes: access, environments, assistance, minimum commitment, usage measures, overages, and exit arrangements. Confirm terms with the provider instead of treating an old price listing as a budget.</p>
<p>Then compare the remaining work. An adapter can simplify transport while leaving your team responsible for duplicate workouts, user explanations, deletion, and feature-specific quality checks. Conversely, an existing internal integration may reduce the marginal cost of another feature. Document these differences rather than comparing subscription totals alone.</p>
<p>Keep a low, expected, and high estimate with the assumptions that move each one. For example, wider history, more device support, or slower onboarding may alter different parts of the budget. A useful estimate lets a product owner change scope and see which work disappears.</p>

<h2 id="set-commercial-launch-gates">Use evidence to set launch gates</h2>
<p>Before committing to a broad rollout, confirm access terms, exercise the complete connection lifecycle, measure steady refresh and backfill behavior, and price the chosen support matrix. Assign an owner to recurring maintenance and a review date for the workload assumptions.</p>
<p>The strongest wearable API budget connects each cost to a supported user outcome. Use the <a href="https://wearapi.com/blog/wearable-api-integration-guide/">integration planning guide</a> to keep the implementation scope concrete, then revise the estimate as pilot evidence replaces assumptions. That process produces a budget your team can operate, explain, and adjust.</p>
]]></content:encoded>
</item>
<item>
<title>On-device AI for wearables: a practical edge pipeline</title>
<link>https://wearapi.com/blog/on-device-ai-wearables/</link>
<guid isPermaLink="true">https://wearapi.com/blog/on-device-ai-wearables/</guid>
<description>Build a wearable inference pipeline that connects sensor quality, model evaluation, power use, and versioned results.</description>
<pubDate>Tue, 05 May 2026 00:00:00 +0000</pubDate>
<category>Engineering</category>
<content:encoded><![CDATA[
<p>On-device AI for a wearable is a pipeline, not just a model file. The result depends on which measurements reach the model, how they are grouped, what the hardware can execute, and how the application handles uncertainty. A model that runs once on a development board has cleared an early technical milestone. It has not yet established dependable behavior during everyday wear.</p>
<p>This guide uses a hypothetical activity classifier to connect those decisions. Start with the <a href="https://wearapi.com/wearable-ai-device/">wearable AI device overview</a> if you are choosing where inference should run. Here, the objective is a small, inspectable system with measurable operating limits.</p>

<h2 id="define-the-task">Define the task before selecting a model</h2>
<p>Write a plain-language decision: “During a user-started recording, classify each eligible interval as walking, running, stationary, or unknown.” Specify the intended users, device placement, supported activities, and acceptable response delay. Avoid starting with a broad promise such as understanding the user's health or detecting every possible behavior.</p>
<p>Then define the consequence of an error. An activity label used to organize a workout diary can tolerate different behavior from a notification that interrupts someone. Decide whether a wrong label, a delayed label, or an unknown result causes more friction. That judgment determines which evaluation results matter.</p>
<p>Establish a simple baseline, such as a rules-based movement threshold, using the same evaluation data as the model. The comparison should reveal whether machine learning improves the actual feature enough to justify its memory, testing, update, and support requirements.</p>

<h2 id="construct-sampling-windows">Construct sampling windows deliberately</h2>
<p>Define the model's input clock separately from the API delivery schedule. A batch arriving once per second might contain samples acquired at a much higher frequency. Use acquisition timestamps and documented sampling behavior rather than assuming that network arrival intervals describe the underlying signal.</p>
<p>As a hypothetical configuration, consider three accelerometer channels sampled at 50 samples per second with a two-second window. Each window contains 100 time steps and 300 scalar channel values. At four bytes per value, the input values alone require 1,200 bytes before metadata or model working memory. These numbers illustrate arithmetic, not a recommended sampling rate.</p>
<p>Choose whether windows overlap and explain the latency implications. If you advance that two-second window every half second, adjacent examples share much of their content. Track missing samples and define when a window becomes ineligible. Filling a long gap with repeated values can manufacture a stationary pattern that the wearer never produced.</p>

<h2 id="align-preprocessing">Keep preprocessing identical across environments</h2>
<p>Make channel order, units, coordinate convention, normalization, and filtering part of the model contract. A model trained on one axis order should not receive another because a device adapter returns fields in a different order. Likewise, document whether acceleration includes gravity and how device orientation is represented.</p>
<p>Use representative recorded windows as test fixtures. Process the same window through the training pipeline and the device implementation, then compare the resulting tensors within a justified tolerance. Test missing values, clipping, and values near the sensor's documented range limits. This catches errors that a successful model load cannot reveal.</p>
<p>Choose between direct time-series input and engineered features based on the task and hardware. Means, variation, or frequency features can be useful candidates, but each creates assumptions about the signal. Keep the transformation understandable enough that you can diagnose a misclassified recording without retraining blindly.</p>

<h2 id="check-runtime-fit">Check the runtime and hardware together</h2>
<p>Google's <a href="https://developers.google.com/edge/litert/microcontrollers/overview">LiteRT for Microcontrollers overview</a> describes inference on constrained devices, a limited set of supported operations, and manual memory management. Its workflow trains and converts a model before deployment; on-device training is not supported by that runtime. These constraints make operator compatibility and memory planning early design questions.</p>
<p>Measure the complete firmware image and peak working memory on the target hardware. Include sensor buffers, Bluetooth activity, application state, and the inference runtime. A small model download does not establish that the application fits in RAM or that its worst-case execution time meets the sampling schedule.</p>
<p>If conversion fails, inspect unsupported operations before changing the whole architecture. If execution succeeds, compare converted-model outputs with the development version on recorded examples. Quantization or another optimization should earn its place through measured behavior, not file size alone.</p>

<h2 id="evaluate-unseen-people">Evaluate on people and sessions held out</h2>
<p>Plan the dataset split before generating overlapping windows. Group recordings by participant when evaluating performance on unfamiliar people, and consider additional separation by session, device, or environment according to the product claim. Randomly mixing near-identical windows across training and evaluation can give an unhelpfully easy test.</p>
<p>Keep label provenance: who labelled the recording, what reference procedure they used, and which intervals were ambiguous. Review transitions between activities instead of retaining only clean examples. The eventual product will encounter someone slowing down, moving a hand while seated, or wearing the device differently.</p>
<p>Report the errors relevant to each class and the number of examples behind them. An overall score can conceal failure on an uncommon activity. Also inspect results across the participant and hardware conditions that you intended to support. Document unsupported conditions explicitly in the feature specification.</p>

<h2 id="allow-abstention">Allow the system to abstain</h2>
<p>A classifier output is evidence for an application decision, not automatically a reliable confidence percentage. Determine whether its scores are useful for selecting uncertain cases on held-out data. Choose any acceptance threshold using that evidence and the cost of errors in your feature.</p>
<p>Combine model uncertainty with acquisition quality. A confident label from a window containing a sensor dropout should not pass merely because the model returns a large score. Treat input eligibility and output acceptance as separate gates, with distinct reasons for an unknown result.</p>
<p>Define how the interface presents that outcome. “Not enough usable motion data” can prompt a different action from “Activity outside the supported set.” Avoid turning either case into a fabricated zero. The <a href="https://wearapi.com/blog/wearable-data-quality/">wearable data quality guide</a> provides related patterns for preserving missingness and provenance.</p>
<h3>Test the behavior across time</h3>
<p>Evaluate the sequence of displayed labels, not only individual windows. A model that alternates between walking and running on every update can create a distracting diary even when most window labels are acceptable. Consider a persistence rule or another documented temporal policy, then test how much delay it introduces when the activity actually changes.</p>
<p>Keep the raw inference result separate from that application policy during evaluation. This makes it possible to identify whether an unwanted transition comes from the model or the smoothing logic. Include the beginning and end of a recording, short activities, and unknown intervals in the test set. Do not let a smoothing rule carry a confident activity label across a long period without usable input.</p>

<h2 id="measure-the-power-budget">Measure the whole power budget</h2>
<p>Record energy use for sensing, buffering, preprocessing, inference, display updates, and radio transfer under realistic operating conditions. Reducing inference frequency may help one design but barely affect another if its main cost lies elsewhere. Make the measurement answer which component actually controls the budget.</p>
<p>Test continuous activity, idle wear, disconnection, and recovery. A retry loop can produce a worse battery experience than the normal inference path. Establish what happens as power falls: lower sampling, pause optional processing, finish a recording, or ask the user to recharge. Any fallback must preserve the meaning of the outputs.</p>
<p>Consider local processing and transmission together. Sending a compact activity event can reduce transfer volume compared with uploading every sample, but it also removes information that might support later debugging. Decide which diagnostic samples, if any, are necessary and permitted before choosing a retention policy.</p>

<h2 id="version-and-release">Version the complete inference contract</h2>
<p>Attach a model version and preprocessing version to derived results. Maintain a compatibility record for device capabilities, firmware, sensor configuration, and supported labels. This lets the application distinguish a product change from an apparent change in the user's activity history.</p>
<p>For updates, validate compatibility before activation and retain a known working recovery path. Test interrupted installation, restart, and a device with insufficient space. Keep previous evaluation results so a new release can be assessed against the same important failure cases.</p>
<p>Choose launch gates for task usefulness, input handling, execution time, memory, energy, and user-visible uncertainty. The <a href="https://wearapi.com/docs/">WearAPI.com integration notes</a> can help organize the surrounding data contract. Ship the smallest supported capability whose behavior you can explain, then expand it with evidence from additional devices and real recording conditions.</p>
]]></content:encoded>
</item>
<item>
<title>Wearable data quality: handle gaps, time zones, and duplicates</title>
<link>https://wearapi.com/blog/wearable-data-quality/</link>
<guid isPermaLink="true">https://wearapi.com/blog/wearable-data-quality/</guid>
<description>A practical model for timestamps, provenance, missing observations, duplicate delivery, and revised records that keeps wearable charts explainable.</description>
<pubDate>Thu, 22 Jan 2026 00:00:00 +0000</pubDate>
<category>Engineering</category>
<content:encoded><![CDATA[<p>A wearable chart can be wrong even when every request returns successfully. A sleep period lands on the wrong day, a repeated delivery doubles a workout, or an absent reading becomes zero. These failures usually begin when the application erases context while normalizing records. Improving wearable data quality means preserving enough information to explain a value before calculating with it.</p>
<p>Start by defining the questions the feature must answer. A live workout display needs continuity and freshness. A weekly activity report needs a stable day boundary and a clear source-selection policy. A sleep trend needs careful handling of revised periods. The <a href="https://wearapi.com/wearable-api/">wearable API overview</a> can help identify the acquisition route, but each route still needs an explicit data contract.</p>
<h2 id="store-observation-context-before-normalizing">Store observation context before normalizing</h2>
<p>Use a small, consistent envelope around each source payload. Include the source system, connected account reference, record type, source identifier, observation interval or instant, ingestion time, original units, and any available quality information. Preserve the unmodified source payload only when retention is appropriate and the application has a clear reason to keep it. Context is useful; unnecessary sensitive copies create another responsibility.</p>
<p>Keep observation time separate from arrival time. A record received this morning may describe yesterday's workout. A newly delivered version may modify a period from last week. If everything is grouped by when your server received it, reports become charts of synchronization behavior rather than the underlying activity.</p>
<p>Define the origin of each timestamp. A timestamp supplied by a device, a platform record interval, and a phone's receipt timestamp have different meanings. Represent that distinction in the schema. The ingestion code should not populate a field named measured_at with whatever clock value happens to be available.</p>
<h2 id="make-local-days-an-explicit-policy">Make local days an explicit policy</h2>
<p>Store instants in a form suitable for UTC ordering while preserving available local offsets and source-assigned dates. An offset tells you how a particular local time relates to UTC. It does not, by itself, identify the full regional time-zone rules. If a source provides a named time zone, retain it separately; if it does not, avoid inventing one from the user's current location.</p>
<p>Consider two recorded times during a repeated autumn clock hour: 01:30 at offset minus seven hours and 01:30 at offset minus eight hours. The wall-clock text matches, but the instants are an hour apart. Deduplicating on a local timestamp alone would delete valid data. During a spring transition, subtracting local clock labels can produce an elapsed duration that is also wrong.</p>
<p>Choose how reports assign records to days. Possibilities include the source's day label, the original recording location's day, or a user-selected reporting zone. None should emerge accidentally from a database session setting. For an interval crossing midnight, specify whether the feature divides a quantity across days, assigns the entire session to a starting day, or retains the vendor's grouping.</p>
<p>Make the policy visible where it affects interpretation. An activity report may say times shown in your reporting time zone, while a travel diary may preserve original local times. Changing that preference should alter presentation predictably without rewriting the underlying observations.</p>
<h2 id="preserve-missingness-and-units">Preserve missingness and units</h2>
<p>A missing observation and an observed zero carry different information. Zero steps can be a reported quantity for a known interval. No step record can mean that nothing has arrived, permission is unavailable, the device was not worn, or the source does not report that interval. Do not choose one explanation unless the integration has evidence for it.</p>
<p>Represent availability separately from value. A practical model might contain a nullable value plus a status such as available, pending, permission_required, or unavailable_reason_unknown. Keep these statuses specific to what your pipeline actually knows. An empty list after a successful request is a transport result; it does not automatically establish why observations are absent.</p>
<p>Normalize units at a documented boundary. Keep the original unit and the conversion used when traceability matters. A duration in seconds and a display duration in minutes must not share an ambiguous field named duration. Use readable field names or typed quantity objects, and round for display after calculations rather than repeatedly rounding during ingestion.</p>
<p>For aggregates, define a denominator that matches the question. Averaging available nightly durations answers a different question from treating missing nights as zero and dividing by every calendar day. Show the number of included nights or usable observation coverage when it materially changes how a reader should interpret the result.</p>
<h2 id="separate-retries-from-overlapping-sources">Separate retries from overlapping sources</h2>
<p>The <a href="https://developer.android.com/reference/androidx/health/connect/client/records/metadata/Metadata">Android Health Connect metadata reference</a> illustrates useful identity concepts. Records have a platform-assigned identifier and data origin; metadata can also carry client-provided identifiers, versions, device information, and a recording method. For the same client record identifier in the relevant client and data-type context, the highest client record version takes precedence. These fields support traceability, but they do not make two independent devices' records equivalent.</p>
<p>For ingestion, construct an identity from the connection or source namespace, record type, and stable source identifier. Reprocessing that identity should update its stored representation safely. Include the namespace: unrelated sources can use the same short identifier. Avoid using a measurement value as identity, because the same heart rate can occur many times legitimately.</p>
<p>Then handle overlapping sources as a separate product decision. A watch and a phone can both describe activity during one interval. These are not necessarily duplicate deliveries. Choose a source preference, use a platform aggregate whose behavior meets your requirements, or show sources separately. Preserve the original records so a later change to the selection rule can be explained.</p>
<p>The <a href="https://wearapi.com/blog/health-connect-vs-healthkit/">Health Connect and HealthKit comparison</a> develops the platform access decision. Whichever route you choose, document whether the values displayed are source records, platform aggregates, or your own calculations.</p>
<h2 id="design-for-revisions-and-deletions">Design for revisions and deletions</h2>
<p>Do not assume a completed historical interval will never change. Build ingestion to accept revised records and source deletions when the integration exposes them. Keep the source's version or modification marker where available. When a later arrival contains an older version, a simple last-arrival-wins rule can restore stale data over a newer record.</p>
<p>Define a revision window for routine reconciliation. This is an application policy based on source behavior, feature needs, and operational cost, not a universal number of days. Recheck a bounded recent interval, and provide a controlled path for deeper repair when an outage or corrected source record requires it. The <a href="https://wearapi.com/blog/wearable-api-cost-planning/">cost planning guide</a> explains why reconciliation belongs in the capacity model.</p>
<p>Recalculate only the views affected by a change when possible. If a sleep period shifts across a day boundary, both old and new day aggregates may need rebuilding. If a record is deleted, remove its contribution and retain only the minimal operational evidence needed by the retention policy. Derived tables should not preserve an observation indefinitely after its source record has been removed.</p>
<h2 id="test-the-questions-that-break-charts">Test the questions that break charts</h2>
<ol><li>Create two records with identical local clock text but different offsets. Expect two ordered instants.</li><li>Import the same identifier twice with identical content. Expect one stored record and one contribution to totals.</li><li>Import a newer version, followed by an older version. Expect the newer state to remain authoritative where version semantics support it.</li><li>Supply a valid zero, a missing field, and an empty response. Expect distinguishable availability states.</li><li>Move an interval across midnight in a revision. Expect both affected daily views to reconcile.</li><li>Provide overlapping phone and watch records. Expect the documented source policy, rather than automatic summation.</li><li>Interrupt a paginated import and resume it. Expect the same final dataset as a complete uninterrupted run.</li></ol>
<p>Make expected outputs concrete. Assert the displayed date, quantity, unit, coverage label, and source, as well as database counts. Tests that only confirm an HTTP request succeeded leave the interpretation layer unexamined. Use synthetic records for these cases so they can be shared and repeated without exposing a person's history.</p>
<h2 id="make-quality-observable">Make quality observable</h2>
<p>Monitor the pipeline with measures that describe its work: oldest unfinished import, stale connections, rejected payload shapes, repeated deliveries, and records awaiting reconciliation. Separate a provider outage from a parser regression and an authorization problem. Each needs a different response, and grouping them under no data makes recovery slower.</p>
<p>For a first release, aim for explainable records and deterministic calculations. Preserve time context, units, source identity, and missingness; then make revisions safe. The <a href="https://wearapi.com/blog/wearable-api-integration-guide/">wearable integration guide</a> connects these decisions to the full delivery process. A chart earns trust when its values can be traced through the system and its gaps remain visible.</p>]]></content:encoded>
</item>
<item>
<title>AI clothing APIs: build around the sensor, not the slogan</title>
<link>https://wearapi.com/blog/ai-clothing-sensor-integration/</link>
<guid isPermaLink="true">https://wearapi.com/blog/ai-clothing-sensor-integration/</guid>
<description>Turn a smart garment concept into a clear sensor contract, with practical checks for calibration, fit, connectivity, and model provenance.</description>
<pubDate>Thu, 16 Oct 2025 00:00:00 +0000</pubDate>
<category>Devices</category>
<content:encoded><![CDATA[
<p>An AI clothing API project starts with a surprisingly practical question: what actually crosses the interface? A garment might report electrical measurements, sensor samples, estimated movement, or a completed activity summary. Those are different products with different testing requirements. A compelling demonstration does not tell you which values your application can retrieve, when they arrive, or whether another garment will produce comparable results.</p>
<p>Begin by describing the physical measurement and the decision it supports. The <a href="https://wearapi.com/ai-clothing-wear-api/">AI clothing Wear API overview</a> introduces this integration category. This guide develops a working approach for a hypothetical movement feedback garment, from its sensor electronics to the application record.</p>

<h2 id="identify-the-signal">Identify the signal and the intended use</h2>
<p>Separate a smart garment from a virtual try-on system during requirements gathering. Virtual try-on software works with images or representations of clothing and people. A sensor garment acquires measurements from hardware attached to, woven into, or otherwise integrated with fabric. An image model cannot establish that a physical sleeve contains a usable movement sensor.</p>
<p>For the example garment, define the feature as recognizing a small set of deliberate arm movements during an explicitly started session. Ask the supplier what it exposes: raw strain readings, calibrated angles, movement labels, or only a proprietary score. If your application needs timestamps and confidence information, a final score alone may be insufficient.</p>
<p>Treat “AI clothing wear API” as a topic description rather than a universal interface specification. Request the actual device protocol, field definitions, supported hardware revisions, and sample recordings. Put unavailable information into a requirements gap list instead of guessing a common format.</p>

<h2 id="map-the-hardware-path">Map the full hardware path</h2>
<p>Draw the acquisition path before writing a cloud adapter: sensing element, electrical readout, controller, transport, receiving application, and optional inference service. Identify which component provides power, timestamps samples, detects disconnection, and stores data when the phone is absent. A garment can contain passive sensing material while a detachable module handles the active electronics.</p>
<p>A useful research example is the <a href="https://www.nature.com/articles/s41528-020-0068-y">E-TeCS electronic textile suit study</a>, which describes distributed sensor modules integrated into knitted textiles and evaluates aspects including fit, mechanical durability, and washing. It demonstrates why textile integration involves physical construction as well as software. Its findings apply to the studied system; they do not establish the performance of another garment.</p>
<p>For your own device, ask where the accessible interface begins. An internal sensor bus is not automatically a supported application API. Access may require vendor firmware, a Bluetooth protocol, or a companion application with a documented export path.</p>

<h2 id="make-calibration-explicit">Make calibration an explicit state</h2>
<p>Define calibration as an observable workflow with a result. For example, an engineering prototype might ask a participant to hold a reference pose, record a baseline, and repeat a controlled movement. Specify what makes the baseline acceptable, when it expires, and what happens if the procedure is interrupted. The thresholds need evidence from your hardware tests.</p>
<p>Store the calibration identifier alongside each derived value. Include the garment revision, sensor module revision, firmware version, and relevant configuration. If the garment moves during a session, an earlier baseline may no longer describe the same physical setup. Your interface should support a “calibration required” state without inventing a plausible movement reading.</p>
<p>Keep raw acquisition units separate from interpreted quantities. A change in resistance is not an angle merely because the UI needs degrees. Document the transformation and its validated operating conditions before assigning a physical unit to the derived output.</p>

<h2 id="test-fit-and-care">Test fit and care as integration variables</h2>
<p>Build a test matrix around realistic use: correct fit, loose fit, garment rotation, seated movement, stretching, and removal. Record the conditions with each session. A dataset collected from one carefully fitted sample will not reveal how the product behaves when someone puts it on quickly before an activity.</p>
<p>Translate the supplier's care instructions into verification steps. Establish whether electronics must be removed before washing, which components can be cleaned, and how a user identifies damage. Do not extrapolate a research washability result into an unlimited machine-washing claim for a commercial garment.</p>
<p>Repeat the same reference procedure after the permitted care cycles in your evaluation plan. Compare signal availability, baseline stability, connector behavior, and user setup effort. The objective is to determine whether your application can recognize degraded conditions and guide the user through an appropriate recovery.</p>

<h2 id="design-the-data-contract">Design a contract that preserves meaning</h2>
<p>Create separate records for samples, device status, and interpreted events. This avoids hiding a low battery warning inside a movement label or interpreting a connection timeout as a motion event. Use a session identifier that belongs to your application and a source identifier that distinguishes the garment module.</p>
<ul>
<li>For a sample, retain acquisition time, channel, value, unit, sequence number, and quality status.</li>
<li>For a derived event, retain its time interval, label, model version, calibration reference, and any documented confidence output.</li>
<li>For device status, represent connectivity, battery information when available, firmware, and required user actions.</li>
</ul>
<p>These are suggested application fields, not a WearAPI.com endpoint or a claim that every garment supplies them. If the source omits a field, preserve that limitation. The <a href="https://wearapi.com/docs/">integration documentation</a> explains how to separate provider data from your own normalized contract.</p>
<p>For a hypothetical three-channel sleeve, name channels by documented placement and sensor identity, not just their arrival order. If a replacement module changes the order, the adapter can still associate each stream with the correct location. Reject an unknown mapping instead of quietly assigning the first stream to the elbow.</p>
<p>Also distinguish device time from phone receipt time. Record the clock relationship established for the session, including any estimated uncertainty. If the controller restarts and its counter returns to zero, create a new clock segment. That prevents a chart from presenting post-restart samples as though they occurred before earlier readings. These details become especially useful when comparing garment events with an independently recorded workout or reference video.</p>

<h2 id="handle-bluetooth-sessions">Handle Bluetooth sessions deliberately</h2>
<p>If the garment uses Bluetooth Low Energy, obtain the actual service and characteristic definitions from its documentation. Determine whether readings arrive as notifications, requested values, or stored batches. Verify byte order, scaling, packet boundaries, and the behavior after reconnection against captured test data.</p>
<p>For the movement example, give each recording an explicit start and finish. Track gaps in the incoming sequence and distinguish a resumed session from a new one. When a user reconnects, do not silently join two unrelated stretches of data simply because the device name is unchanged.</p>
<p>Provide a visible state for waiting, recording, reconnecting, and incomplete sessions. A green connection indicator only establishes that a link exists; it should not also imply that the sensor is calibrated and producing usable measurements. Read the <a href="https://wearapi.com/blog/bluetooth-heart-rate-monitor-guide/">Bluetooth sensor integration guide</a> for related transport decisions.</p>

<h2 id="document-ai-provenance">Document the origin of AI outputs</h2>
<p>Decide whether the model runs in the garment module, the phone, or an application backend. For every result, preserve enough provenance to explain which model and preprocessing configuration produced it. A firmware upgrade that changes filtering can matter even when the output field names remain identical.</p>
<p>Keep training examples grouped by participant and recording session when evaluating generalization. Record garment size, placement, and acquisition configuration where relevant and appropriately permitted. Otherwise, a model may appear successful because its evaluation samples resemble the same sessions used during development.</p>
<p>Choose an explicit unknown result for movements outside the supported set. A prototype trained to distinguish three gestures should not force every possible action into one of those labels. The <a href="https://wearapi.com/blog/on-device-ai-wearables/">on-device AI pipeline guide</a> develops the evaluation and deployment decisions behind that behavior.</p>

<h2 id="set-acceptance-gates">Set acceptance gates before expanding</h2>
<p>Start with one garment revision, one session type, and a documented set of movement labels. Confirm that an unfamiliar participant can complete setup, that interrupted sessions remain understandable, and that the application records calibration and model provenance correctly. Review failed examples alongside successful demonstrations. Keep representative failures as regression recordings so the next software release must handle the same difficult conditions.</p>
<p>Expand support only after you can explain the consequences of another size, module, or firmware revision. Smart clothing becomes a manageable integration when the physical sensor, transport, interpretation, and user instructions form one testable contract. That contract is the durable foundation for adding AI features without overstating what the garment measures.</p>
]]></content:encoded>
</item>
<item>
<title>Health Connect vs HealthKit: choosing your integration path</title>
<link>https://wearapi.com/blog/health-connect-vs-healthkit/</link>
<guid isPermaLink="true">https://wearapi.com/blog/health-connect-vs-healthkit/</guid>
<description>Plan a shared product experience while keeping Android and Apple permissions, history, and synchronization behavior explicit.</description>
<pubDate>Tue, 08 Jul 2025 00:00:00 +0000</pubDate>
<category>Integration</category>
<content:encoded><![CDATA[<p>Health Connect and HealthKit can both help a mobile application exchange health and fitness records with the person's permission. Choosing between them is primarily a platform and product architecture decision. An Android application and an Apple application need different native integrations, even when both display the same activity timeline.</p>
<p>The useful comparison is therefore: what belongs in a shared product contract, and what must stay specific to each operating system? This guide uses a weekly activity view as a running example. It concentrates on predictable data access and understandable interface behavior, rather than assuming that similar record names guarantee identical results.</p>

<h2 id="start-with-the-device-ecosystem">Start with the device ecosystem</h2>
<p>Health Connect provides a permission-controlled health data store on supported Android devices. Its availability and installation path depend on the device's software. HealthKit is Apple's framework for working with its health data store on supported Apple platforms. Neither name describes a universal cloud endpoint that a website can query directly.</p>
<p>For a native mobile product, put the relevant platform integration beside the app lifecycle and operating-system permission handling. If the product also needs a web dashboard, design a separate, consented transfer from the mobile app to your own application service. That transfer introduces its own retention, account linking, and synchronization decisions.</p>
<p>A watch does not automatically place every measurement into the phone's health store. The recording application and its sharing behavior matter. Before promising support for a wearable, verify a complete path from the device's recorded activity to the records your application can actually read. The <a href="https://wearapi.com/wearable-api/">wearable API guide</a> explains how local stores fit alongside direct sensors and vendor clouds.</p>

<h2 id="separate-shared-features-from-native-adapters">Separate shared features from native adapters</h2>
<p>A shared feature specification might require activity duration for each day, an indication of source, and a visible freshness message. Keep that specification independent of native class names. Then let an Android adapter and an Apple adapter translate the request into their respective queries and supported record types.</p>
<p>Avoid forcing every platform into a single permission Boolean. Your shared layer can report that an integration is available, that a request completed, and that data was returned. More specific claims require evidence from the underlying platform. Likewise, retain native identifiers and source metadata alongside normalized values so support tools can trace an unexpected result.</p>
<p>A useful adapter result includes records, the time range attempted, a continuation or change checkpoint where relevant, and a status describing the operation. The result should not imply that an empty list proves the person was inactive. Designing this distinction early prevents misleading language from spreading into charts, reminders, and analytics.</p>

<h2 id="request-purposeful-permissions">Request purposeful permissions</h2>
<p>Read access and write access serve different purposes. An activity viewer may need to read workouts without writing anything. A training recorder might write its own workout while separately requesting permission to read an optional metric. Ask for the smallest useful set when the person starts the related feature.</p>
<p>Apple makes an especially important distinction: an app cannot determine whether the user granted permission to read HealthKit data. The <a href="https://developer.apple.com/documentation/healthkit/hkhealthstore/authorizationstatus(for:)">HealthKit authorization status documentation</a> explains that the status method concerns saving data; inaccessible records can appear absent. Do not convert a successful authorization request into a claim that all requested reading permissions were granted.</p>
<p>On Android, check the currently granted permissions using the platform's supported mechanisms and keep capability checks separate from permission checks. An installed integration, an available feature, an allowed read, and actual records are four different conditions. Their interface treatments should explain the next useful action without exposing a confusing technical checklist.</p>
<p>For example, a neutral empty state can say, “No activity is available for this period. Check your connected source and sharing settings.” It should offer the relevant settings guidance without asserting that the person rejected access.</p>

<h2 id="treat-history-as-an-explicit-requirement">Treat history as an explicit requirement</h2>
<p>A weekly view and a two-year retrospective have different access needs. Define the oldest date your feature needs, the initial import strategy, and the behavior when that history cannot be read. Do not silently shorten the requested interval and label the result a complete history.</p>
<p>Health Connect has restrictions around reading data from before permission was granted, with additional history access dependent on supported features and permissions. Check availability and authorization for the installed environment. Avoid hard-coding an assumption that every device can provide the same extended historical range.</p>
<p>For both integrations, a query only reveals records currently accessible through that route. The originating app may have written only a subset of its history. Reinstalling an app, switching phones, changing sharing settings, or reconnecting a source can alter the practical import experience. Test your supported journeys instead of using your own fully populated development phone as the reference case.</p>
<p>Store coverage information separately from data values. A chart can then distinguish “no activity recorded in an examined interval” from “this interval has not been imported.” That distinction becomes especially useful when a long initial import is still running.</p>

<h2 id="make-time-and-source-rules-consistent">Make time and source rules consistent</h2>
<p>Choose how the product assigns a workout to a day. A session can cross midnight, and the person's current time zone may differ from the zone in which it occurred. Preserve absolute timestamps and available original offsets, then document whether the view groups by session start, recorded local day, or another explicit rule.</p>
<p>Units also need a deliberate boundary. Convert values into a canonical internal representation and format them for the person's preferences at display time. Keep duration separate from clock time. A time-zone change should not make a completed workout longer.</p>
<p>Source handling is more difficult than conversion. A phone and a watch may describe overlapping activity, while another app may copy a record between stores. Adding every overlapping record can inflate totals. Prefer an explicit source policy and supported platform aggregation behavior where appropriate. Keep imported records traceable so the policy can be corrected later.</p>
<p>Do not equate two derived scores because they share a familiar label. Sleep classifications and estimated energy values can reflect different upstream methods. A consistent interface can still preserve those differences. The <a href="https://wearapi.com/blog/wearable-data-quality/">wearable data quality guide</a> develops this problem beyond the platform boundary.</p>

<h2 id="design-sync-as-a-mobile-workflow">Design sync as a mobile workflow</h2>
<p>Separate the local read from any upload to your service. Persist a durable record of what has been imported, and make uploads repeatable. If a connection fails after the local read, the application should resume the transfer without asking the source for everything again or creating duplicate server records.</p>
<p>Background execution is constrained by the operating system, permissions, device state, and the particular API. Treat timely refresh as a measured property of your supported workflow. Show the last successful refresh where freshness matters, and avoid promising instantaneous updates from a historical store.</p>
<p>Reconcile edits and deletions as well as new samples. Keep native change tracking inside each adapter, and define what happens when a checkpoint can no longer be used. A bounded rebuild may be preferable to attempting to interpret an invalid checkpoint. The <a href="https://wearapi.com/docs/">implementation notes</a> provide a broader structure for checkpoints, provenance, and recovery.</p>

<h2 id="build-a-cross-platform-test-matrix">Build a cross-platform test matrix</h2>
<p>Test equivalent product outcomes rather than requiring identical native responses. An Android permission query and an Apple empty query may reveal different information, yet both should lead to an honest, usable screen.</p>
<ul>
<li>Fresh installation with no requested access and no existing health records.</li>
<li>Partial access, including an optional metric unavailable to the application.</li>
<li>Historical data outside the application's readable interval.</li>
<li>A workout created, updated, and then deleted by the source.</li>
<li>Overlapping records from two recording applications.</li>
<li>A session crossing midnight during travel or a daylight-saving transition.</li>
<li>A terminated app resuming an interrupted import or upload.</li>
</ul>
<p>Use sanitized or synthetic fixtures for transformation tests, then validate lifecycle behavior on the actual supported device configurations. Record the originating app, operating-system version, and import path for each failure. Those details often explain a difference that a generic “sync failed” report cannot.</p>

<h2 id="choose-the-path-that-fits-the-feature">Choose the path that fits the feature</h2>
<p>For a phone-based history feature, these local stores are natural candidates when the needed records are available. For a live watch workout, investigate the watch's recording APIs; the <a href="https://wearapi.com/smart-watch-wear-api/">smart watch integration page</a> separates those concerns. For ring-specific fields, verify the vendor's export path before promising parity.</p>
<p>Build one shared meaning for each feature, then let each native adapter honor its platform's capabilities and privacy behavior. The result is easier to maintain because differences remain visible in the architecture instead of becoming unexplained exceptions in the user interface.</p>]]></content:encoded>
</item>
<item>
<title>Wearable API consent and security: design for user control</title>
<link>https://wearapi.com/blog/wearable-api-consent-security/</link>
<guid isPermaLink="true">https://wearapi.com/blog/wearable-api-consent-security/</guid>
<description>Plan consent as an ongoing user control, with scoped access, secure connection handling, revocation, deletion, and operational checks.</description>
<pubDate>Tue, 29 Apr 2025 00:00:00 +0000</pubDate>
<category>Integration</category>
<content:encoded><![CDATA[
<p>A wearable connection begins with permission, but the design work continues long after a user approves access. The application needs to explain what it imports, handle changing permissions, protect credentials, and stop work when the user disconnects. These behaviors should be visible in the product specification before the first production authorization request.</p>
<p>This guide describes an actual connected application's responsibilities using a hypothetical activity diary. WearAPI.com is an independent educational resource. The examples help you plan your own system and complement the <a href="https://wearapi.com/wearable-api/">wearable API integration overview</a>.</p>

<h2 id="start-with-purpose">Start with a purpose for every data type</h2>
<p>Write a short purpose statement for each proposed import. An activity diary might need completed workout summaries to populate a calendar. That does not automatically justify requesting detailed location traces, sleep records, or every measurement the provider offers. Map each scope to a specific feature that the user can understand.</p>
<p>Separate required and optional access in the product design, taking account of the provider's actual permission model. When scopes cannot be requested individually, explain the package clearly and decide whether that provider still fits the feature. Do not promise granular controls that its authorization flow cannot deliver.</p>
<p>Show the explanation at the decision point: what will be imported, how far back the first import may reach, and where connection settings live. Keep provider authorization distinct from your application's own choices about retention or additional processing. A successful OAuth response does not answer every product permission question.</p>

<h2 id="use-an-appropriate-oauth-flow">Use an appropriate OAuth flow</h2>
<p>Where a provider supports OAuth, select its documented authorization code flow and evaluate PKCE support. The IETF's <a href="https://www.rfc-editor.org/rfc/rfc9700.html">OAuth 2.0 Security Best Current Practice, RFC 9700</a> requires PKCE for public clients and recommends it for confidential clients. It also describes transaction-specific protection and recommends the S256 challenge method. Follow provider documentation alongside that security baseline.</p>
<p>At a high level, the application starts an authorization transaction, the user approves at the provider, and the application receives a code at its registered redirect address. The code exchange proves possession of the corresponding verifier when PKCE is used. The verifier belongs to that transaction; it should not be a fixed value shared across users.</p>
<p>Use a maintained OAuth library and explicitly test callback handling. Keep the expected provider, redirect address, and initiating application session bound to the transaction. Reject mismatches and expired attempts. If required protections are unavailable, resolve that design gap before offering the connection publicly.</p>

<h2 id="protect-credentials">Keep secrets out of delivered frontend files</h2>
<p>A browser downloads the JavaScript and configuration needed to run a page. Treat everything delivered to it as inspectable by the person using the browser. A client identifier is not the same as a client secret. Renaming a secret, hiding it in minified code, or injecting it during a static build does not make it confidential.</p>
<p>For an integration using a confidential client, keep the client secret and sensitive credential exchanges in an appropriate trusted service. Define who can read that configuration, how it is rotated, and how a suspected exposure disables its use. A public client requires a design appropriate to its inability to keep such a secret.</p>
<p>Store user tokens according to the application's architecture and threat model. Make access explicit and narrow. Avoid copying production credentials into local fixtures, screenshots, support tickets, or analytics events. Review the connection path separately from ordinary marketing pages and documentation assets.</p>

<h2 id="model-the-connection-lifecycle">Model the connection lifecycle</h2>
<p>Represent states such as pending authorization, connected, temporarily unavailable, permission changed, and disconnected. A single Boolean named “connected” leaves too much unexplained. The application may retain imported records after the provider stops accepting its token, while the user still expects new workouts to appear.</p>
<p>Decide which events move the connection between states and which require a user action. A temporary timeout should not immediately force a new authorization. A confirmed revocation should stop retries that can never succeed. Keep a human-readable explanation aligned with the internal state.</p>
<p>Where refresh tokens are part of the provider's flow, design for concurrent requests, replacement credentials, and failures during updates. Test the actual provider behavior instead of assuming every integration follows the same rotation policy. A recovery procedure should not accidentally restore an older credential after a newer one has been accepted.</p>

<h2 id="respect-changed-permissions">Treat changed permissions as ordinary behavior</h2>
<p>Build the feature so it remains understandable when optional data is unavailable. For the activity diary, the user may retain workout summaries while withdrawing access to another collection. The calendar should explain its coverage rather than removing unrelated functionality or repeatedly demanding broader access.</p>
<p>Check permission at the point where a job runs, not only when it enters a queue. A background import may wait long enough for the user to disconnect. Give queued work a connection reference and verify that the connection remains eligible before fetching or processing more records.</p>
<p>Keep unavailable, empty, and unauthorized results distinct where the source exposes that distinction. HealthKit deliberately limits what an app can learn about reading permission, so an empty result does not establish that the user denied access. When the source does expose the distinction, preserve it in both the data layer and user interface. Otherwise, describe the result as unavailable without assuming why, so an absence of data does not become an incorrect activity statement.</p>

<h2 id="separate-disconnect-and-delete">Specify disconnect and deletion behavior</h2>
<p>Define what “disconnect” does in your product: stop new collection, cancel pending jobs, dispose of usable credentials, and update the visible connection state. Use the provider's supported revocation mechanism where applicable. Do not assume that removing a local row automatically withdraws an upstream grant.</p>
<p>Define deletion separately and explain its scope. Imported records, derived summaries, exports, caches, and support attachments can have different storage paths. Maintain an inventory so a deletion workflow can identify the relevant copies. Treat retention choices as explicit product requirements that need appropriate review for the intended deployment.</p>
<p>Test a race between deletion and an in-flight import. One practical design is to mark the connection unavailable immediately, block new writes associated with it, and then complete the deletion work with auditable status. Whatever approach you choose, verify that a delayed worker cannot repopulate data after the user receives confirmation.</p>

<h2 id="keep-observability-careful">Make observability useful without copying payloads</h2>
<p>Choose operational fields that answer a troubleshooting question: integration type, operation, response category, elapsed time, retry count, and a deliberately scoped correlation reference. Avoid routine logging of access tokens, authorization headers, complete callback URLs, raw wearable records, or direct personal identifiers.</p>
<p>A correlation reference can still link events, so limit its lifetime and audience according to its purpose. Restrict log access and establish retention for diagnostic systems as well as the main database. Review error reporting tools because an automatic exception capture can include request context that your own logger excludes.</p>
<p>Use synthetic fixtures for ordinary development and demonstrations. When investigating a production issue requires additional information, create a narrowly scoped procedure with a clear reason and access path. More verbose logging should be a deliberate, temporary decision rather than a permanent response to every support problem.</p>

<h2 id="make-choices-observable">Make choices observable in the interface</h2>
<p>Give the connection settings a concrete account of current behavior: connected provider, imported collections, last successful update, and available disconnect or deletion actions. If historical records remain after disconnection, explain that before the action and reflect it afterward. A stopped import should not look like an unexplained failure.</p>
<p>During usability review, ask a participant to stop future collection and then identify which records remain. Watch whether the labels support that task without requiring knowledge of tokens or background workers. Clear controls reduce the gap between what the system technically permits and what the user reasonably believes they selected.</p>

<h2 id="exercise-real-threats">Exercise realistic threats and failures</h2>
<p>Threat-model the connection as a set of boundaries: browser to application, application to provider, queue to worker, and support tools to retained records. Ask what an attacker or mistaken operator could access at each boundary. Prioritize concrete paths such as leaked tokens, swapped user references, or overly broad support access.</p>
<p>Include cross-account tests. A worker receiving an internal user reference must not accept an unrelated provider connection simply because both records exist. Test authorization failures, disconnect during import, expired sessions, duplicate callbacks, and attempted access after deletion. These cases are more informative than checking only the happy path.</p>
<p>Assign an owner to each control and recovery procedure. The <a href="https://wearapi.com/blog/wearable-api-integration-guide/">wearable integration guide</a> and <a href="https://wearapi.com/docs/">documentation checklist</a> can organize the surrounding implementation work. A dependable consent design lets users understand their connection, change their choices, and see those choices reflected in ongoing system behavior.</p>
]]></content:encoded>
</item>
<item>
<title>Smart ring APIs: make sleep data useful without overclaiming</title>
<link>https://wearapi.com/blog/smart-ring-api-sleep-data/</link>
<guid isPermaLink="true">https://wearapi.com/blog/smart-ring-api-sleep-data/</guid>
<description>Separate daily sleep scores from recorded sleep periods, then design a sync process and interface that preserve what the ring actually reports.</description>
<pubDate>Thu, 13 Feb 2025 00:00:00 +0000</pubDate>
<category>Devices</category>
<content:encoded><![CDATA[<p>A smart ring integration often starts with a deceptively simple request: show last night's sleep. Before drawing a chart, decide what that sentence means. Is the feature showing a daily score, the longest recorded sleep period, all sleep assigned to a particular day, or the elapsed time between bedtime and waking? Those are different objects, and collapsing them into one field creates errors that a polished interface cannot explain.</p>
<p>This guide uses Oura's API as a concrete example and develops an application design around it. The principles also provide useful questions for evaluating another <a href="https://wearapi.com/smart-ring-wear-api/">smart ring wear API</a>. Each vendor still needs its own adapter and field definitions; a ring-shaped device does not imply a shared data contract.</p>
<h2 id="daily-summaries-and-sleep-periods">Keep daily summaries and sleep periods separate</h2>
<p>The <a href="https://cloud.ouraring.com/v2/docs">official Oura API v2 documentation</a> defines <code>daily_sleep</code> as a daily score with contributors, a day, and a timestamp. The separate <code>sleep</code> collection describes sleep periods, including bedtime boundaries, durations, and optional sample data. List responses use <code>next_token</code> pagination. Access requires authorization, and users consent to the data types shared. Webhooks identify changed objects for subsequent retrieval; they follow cloud synchronization rather than providing a direct live ring stream.</p>
<p>Model these as separate entities in your application. A daily summary can power a calendar tile. A sleep period can power a timeline. Join them for presentation only after defining the relationship. Do not assume that one daily document corresponds to exactly one period, or calculate duration from a score. If your product selects a primary period, keep the selection rule explicit and preserve other periods for inspection.</p>
<p>A useful internal contract contains <code>source</code>, <code>source_record_id</code>, <code>source_day</code>, <code>record_kind</code>, and a typed payload. This is a suggested application schema, not an endpoint offered by WearAPI.com. Distinguishing <code>daily_sleep_summary</code> from <code>sleep_period</code> at the type level makes it harder for a dashboard component to accidentally add scores to durations.</p>
<h2 id="preserve-the-two-kinds-of-time">Preserve the two kinds of time</h2>
<p>A calendar date answers a different question from an instant. Preserve the source's <code>day</code> grouping alongside the original timestamp and offset. Convert instants to UTC for ordering and interval arithmetic, but do not replace the vendor's day with the date extracted from UTC. Otherwise, a sleep period near midnight can move into a different calendar tile simply because the application server runs in another region.</p>
<p>Consider a fictional period starting at 23:30 and ending at 07:00 the following morning in the same offset. The elapsed interval is seven hours and thirty minutes, but the reported time asleep may be shorter. Your interface should use the supplied sleep-duration field for a label such as recorded sleep, and reserve the boundary interval for a bedtime timeline. Deriving both labels from the same subtraction would erase the distinction.</p>
<p>Travel adds another decision. A user viewing a previous trip from home may expect either the original local bedtime or a conversion to the current viewing zone. Choose and label one presentation rule. Store enough original context to change that rule without refetching history. The <a href="https://wearapi.com/blog/wearable-data-quality/">wearable data quality guide</a> describes the broader handling of offsets, missing values, and record revisions.</p>
<h2 id="design-the-first-import-as-a-job">Design the first import as a job</h2>
<p>Treat the initial history import as resumable work. Choose a bounded date window that matches the feature, fetch one page, validate it, and write records before advancing the cursor. Continue while the provider returns a next-page token. A successful first response means one page succeeded; it does not prove that the requested history is complete.</p>
<p>Keep the query window and cursor together in the job state. If a worker restarts, it should resume the same request rather than silently changing the date range to today. When a cursor becomes unusable, restart a bounded window and rely on stable record identifiers to make reprocessing safe. Keep an operational distinction between a completed empty import and an interrupted import that has returned no records yet.</p>
<p>Do not promise immediate sleep availability at a particular morning hour. The relevant chain includes recording, device synchronization, vendor processing, and your import. Show when your application last checked successfully and whether fresh data is available. A message such as awaiting your next ring sync can be useful when the integration has evidence for that state; otherwise, use the more accurate no new sleep data available.</p>
<h2 id="treat-webhooks-as-change-notices">Treat webhooks as change notices</h2>
<p>Use a webhook receiver to schedule retrieval, with validation and durable queuing before a successful acknowledgement. Verify incoming requests according to the vendor's current signing instructions. The receiver should not calculate weekly charts synchronously or expose application secrets in browser code. Maintain a mapping from the vendor's user identifier to the connection that authorized the import.</p>
<p>Process repeated notifications safely. An update can arrive while an initial import is still running, and a worker may retry after an uncertain response. Upsert the relevant source record and recalculate affected views instead of appending another night. Handle deletion as a distinct operation: fetching a deleted object and repeatedly treating its absence as a transient failure creates a pointless retry loop.</p>
<p>Track subscription health and renewal requirements, and keep a bounded reconciliation process for outages. A callback arriving successfully is evidence about that delivery, not proof that every earlier event arrived. Reconciliation should compare current source records with your stored state for an appropriate window, respecting rate limits and the connection's current authorization.</p>
<h2 id="permissions-and-partial-results">Make partial permission a normal state</h2>
<p>Ask for the data needed by the actual feature. A sleep calendar does not automatically justify collecting every available personal attribute or another category of health information. Document which screen depends on each requested permission so the consent language and implementation remain aligned as the product grows.</p>
<p>Represent an authorization problem separately from an empty dataset. Repeated authentication failures need a reconnection path, while a valid response without a sleep record needs a useful empty state. Stop scheduled imports when a connection is revoked, and apply the product's retention and deletion policy to previously stored data. See the <a href="https://wearapi.com/blog/wearable-api-consent-security/">consent and security guide</a> for the surrounding connection lifecycle.</p>
<h2 id="do-not-upgrade-a-summary-into-a-diagnosis">Do not upgrade a summary into a diagnosis</h2>
<p>Name the metric and its source. A vendor sleep score is an interpreted summary; calling it a universal measure of sleep health introduces a claim your integration has not established. Similarly, a series of sleep-stage labels is already processed information. Do not describe it as a raw physiological recording merely because it contains many points.</p>
<p>A helpful product can compare a person's recorded bedtime across dates, show available duration trends, and explain missing nights without assigning a medical meaning. Keep recommendations within the feature's demonstrated purpose. If a team wants to assess a condition or guide treatment, that is a separate product and evidence question that cannot be resolved by connecting an API.</p>
<p>When comparing rings, avoid treating similarly named scores as interchangeable. Preserve their source labels and describe the comparison you actually support. A user should be able to understand whether a change in a chart follows their records, a new device, a revised source algorithm, or your own presentation rule.</p>
<h2 id="acceptance-cases-for-a-sleep-feature">Acceptance cases for a sleep feature</h2>
<ul><li>Import a day with two sleep periods and verify that neither disappears during the summary join.</li><li>Load a record whose local date differs from its UTC date and check both the calendar and timeline.</li><li>Repeat the same update twice and confirm that the night appears only once.</li><li>Return a missing score with a valid duration and verify that each component handles its own availability.</li><li>Interrupt pagination, resume the job, and compare its final records with an uninterrupted import.</li><li>Revoke the connection while work is queued and confirm that unauthorized work stops.</li></ul>
<p>Run these cases against small synthetic fixtures before collecting more real records. Expected output should include visible labels as well as stored values. A technically correct timestamp is still confusing when a screen quietly displays it in the wrong zone.</p>
<h2 id="build-the-feature-around-explainable-records">Build the feature around explainable records</h2>
<p>A dependable sleep experience begins with clear record types, preserved time context, and an import process that can recover from interruptions. Add conservative labels and observable sync state, and the interface can explain both what it knows and why something is missing. Use the <a href="https://wearapi.com/docs/">WearAPI.com integration checklists</a> to turn these decisions into an implementation plan before expanding to more devices.</p>]]></content:encoded>
</item>
<item>
<title>Smart watch APIs: from sensors to a useful workout</title>
<link>https://wearapi.com/blog/smartwatch-health-services-guide/</link>
<guid isPermaLink="true">https://wearapi.com/blog/smartwatch-health-services-guide/</guid>
<description>Move from raw sensor access to a useful watch workout with explicit capabilities, session ownership, durable records, and recovery tests.</description>
<pubDate>Tue, 26 Nov 2024 00:00:00 +0000</pubDate>
<category>Devices</category>
<content:encoded><![CDATA[<p>A useful smart watch application does more than receive numbers from a sensor. It knows whether a workout is running, which metrics the watch supports, how old a displayed value is, and what happens when the screen turns off. Those decisions determine whether a person can trust the workout experience.</p>
<p>For a Wear OS application, Health Services provides an important starting point. This guide uses a simple walking workout to explain the path from capability discovery to a saved session. The examples describe application design; they do not imply that WearAPI.com operates a device connection service.</p>

<h2 id="understand-the-three-data-layers">Understand the three data layers</h2>
<p>Separate raw sensors, on-watch fitness services, and stored health records. Raw sensor access exposes signals your application must interpret. Health Services sits on the watch and provides activity and exercise metrics using device sensors and platform processing. A phone health store is a different layer for reading and writing records exchanged by applications.</p>
<p><a href="https://developer.android.com/health-and-fitness/health-services">Android's Health Services overview</a> describes this service on Wear OS 3 and higher, including its role in sensor configuration and derived metrics. Availability of the service does not mean that every supported watch produces every possible measurement.</p>
<p>Keep these responsibilities visible in your architecture. The watch records and presents the ongoing workout. Your application saves its own session record. A separate synchronization path can move that record to the phone or another authorized destination. Do not assume the phone's health history will appear simply because the watch received live updates.</p>
<p>The broader <a href="https://wearapi.com/smart-watch-wear-api/">smart watch API overview</a> covers other access routes. Apple Watch, proprietary watch platforms, and Wear OS require their own integration decisions.</p>

<h2 id="choose-the-client-for-the-experience">Choose the client for the experience</h2>
<p>Health Services separates three usage patterns. <code>ExerciseClient</code> supports an application managing a workout and receiving exercise state and metric updates. Use that model for a walking session with start, pause, resume, and finish controls.</p>
<p><code>MeasureClient</code> is intended for short measurements, such as showing a current reading while the person views a screen. Its live callback registration is not the right mechanism for an all-day subscription or workout recorder. Register only for the short interaction and release the callback when it ends.</p>
<p><code>PassiveMonitoringClient</code> serves longer-lived monitoring with less frequent updates. Its background-oriented pattern is useful when the product can consume data without maintaining an active workout. It should not be used to promise the same display cadence as an active exercise experience.</p>
<p>Start from the interaction rather than whichever sample application seems easiest to copy. A screen that briefly checks a metric should not create a fake workout. A recorded walk needs a coherent exercise lifecycle, even if the first design only displays elapsed time.</p>

<h2 id="discover-capabilities-before-designing-controls">Discover capabilities before designing controls</h2>
<p>Query capabilities for the client and requested exercise type. Confirm the supported metrics before building the exercise configuration. A broad list of data types in an SDK reference is a vocabulary of possibilities, not the capability profile of the watch on someone's wrist.</p>
<p>For the walking example, classify elapsed time and explicit session controls as core application behavior. Treat heart rate, distance, or other device-provided metrics as features that require support and relevant permission. The launch screen can explain which measurements are available before the person starts moving.</p>
<p>Keep capability and permission failures separate internally. An unsupported metric will not become available after another consent prompt. A supported metric without permission may become available through the appropriate request flow. Avoid repeatedly prompting when the person has chosen to proceed with a simpler workout.</p>
<p>Store a concise capability snapshot with diagnostic events, without copying raw measurements into logs. When a user reports that distance is missing, support can then establish whether that metric was requested and supported for the exercise type.</p>

<h2 id="model-the-workout-as-a-state-machine">Model the workout as a state machine</h2>
<p>Use explicit states such as ready, preparing, active, paused, finishing, and saved. Add recoverable error paths for a failed start or a lost application process. Buttons should reflect the confirmed state, with a pending state while the platform processes a request.</p>
<p>A double tap on Start must not create two application records. Assign a local session identifier when preparation begins and reuse it throughout the lifecycle. Disable conflicting transitions while a request is pending, then reconcile with the reported exercise state before enabling the next action.</p>
<p>Consider exercise ownership before starting. Another application may already be recording. Choose an interface that explains the situation and uses the platform's supported behavior, rather than silently assuming your app controls the session. Likewise, reopening your own application should investigate an existing session before presenting a fresh Start button.</p>
<p>Pause semantics deserve a written rule. Is the headline timer active exercise duration or wall-clock time since starting? Store both if the feature needs both, and label them accurately. A summary that uses one interpretation while the live display uses another creates an avoidable discrepancy.</p>

<h2 id="keep-live-values-honest">Keep live values honest</h2>
<p>A callback arrival time is not necessarily the measurement time. Use the timestamps and interval semantics supplied by the API, and follow its documented clock conversion rules. Keep receipt time separately when useful for debugging delivery delays.</p>
<p>For a live heart rate tile, track the most recent measurement and its age. If updates stop, change the presentation after a documented threshold. Showing a dash with “waiting for a reading” is more honest than leaving an old number looking current. The threshold is a product decision to test, not evidence that the person's physiology changed.</p>
<p>Do not turn a missing reading into zero. Do not derive a session average by averaging averages from unequal intervals. Choose an aggregation method that matches the available samples and metric definition, or display the platform's supplied summary with its provenance preserved.</p>
<p>A watch measurement also needs context. A recorded heart rate value alone does not establish a diagnosis or prove that a sensor is accurate for every activity. The <a href="https://wearapi.com/heart-rate-monitor-wear-api/">heart rate monitor integration page</a> explains the importance of measurement source and intended use.</p>

<h2 id="save-the-session-before-syncing">Save the session before syncing</h2>
<p>A finished workout should remain available on the watch even when the phone is unreachable. Persist the session identity, timing, exercise type, available summary, and completion state before depending on a network transfer. Treat the upload as a separate operation that can be retried.</p>
<p>Use an idempotent import key at the receiving side. If the watch sends the same saved session twice after reconnecting, the application should update one workout. Preserve the original record identifier through later exports where possible so copied records remain traceable.</p>
<p>Be deliberate about the amount of data retained. A session summary may serve the product without storing every high-frequency sample. Conversely, a feature that plots a detailed timeline needs enough resolution to support that display. Choose the retention policy from the feature and explain it in the consent experience.</p>
<p>If the phone subsequently writes the workout to a health store, track that write independently from watch-to-phone delivery. “Saved on watch,” “transferred,” and “shared with health store” are distinct states that should not be collapsed into one ambiguous success flag.</p>

<h2 id="test-battery-lifecycle-and-recovery">Test battery, lifecycle, and recovery</h2>
<p>Battery testing should reflect the actual interaction. A continuously visible metrics screen, a wrist-down workout, and a brief spot check create different workloads. Measure a representative session on supported hardware, including display use and communication, before choosing a refresh cadence.</p>
<p>Use synthetic data to check state transitions and transformations, then test physical devices for lifecycle and usability. A smooth emulator demonstration cannot establish real-world measurement availability or battery behavior.</p>
<ul>
<li>Start with one optional permission declined and complete a useful workout.</li>
<li>Pause, resume, and finish while checking timer consistency.</li>
<li>Turn the screen off and reopen the app during the session.</li>
<li>Interrupt the application and verify recovery of an ongoing or saved workout.</li>
<li>Finish with the phone disconnected, then reconnect and confirm one imported record.</li>
<li>Present unavailable metrics without stale values or invented zeros.</li>
</ul>
<p>Also test a device with a smaller capability set than your primary development watch. This exposes accidental assumptions about metrics earlier than user reports. For a broader fixture strategy, read the <a href="https://wearapi.com/blog/wearable-data-quality/">data quality testing guide</a>.</p>

<h2 id="deliver-a-workout-people-can-understand">Deliver a workout people can understand</h2>
<p>A dependable watch feature has a clear scope: the right client for its interaction, capability-aware configuration, explicit session states, and a durable saved result. Begin with a modest workout that survives interruption and missing data. Add richer metrics when the acquisition path, display meaning, and test evidence support them. The <a href="https://wearapi.com/docs/">developer checklists</a> can help carry those decisions into implementation reviews.</p>]]></content:encoded>
</item>
<item>
<title>Bluetooth heart rate monitors: a developer’s decoding guide</title>
<link>https://wearapi.com/blog/bluetooth-heart-rate-monitor-guide/</link>
<guid isPermaLink="true">https://wearapi.com/blog/bluetooth-heart-rate-monitor-guide/</guid>
<description>Walk through a real packet shape, convert RR intervals correctly, and keep sensor state, connection state, and displayed heart rate distinct.</description>
<pubDate>Wed, 07 Aug 2024 00:00:00 +0000</pubDate>
<category>Devices</category>
<content:encoded><![CDATA[<p>A Bluetooth heart rate integration has two jobs: interpret a small binary message correctly and maintain an honest account of when measurements were available. The first job is easy to demonstrate at a desk. The second becomes visible when a runner walks out of range, adjusts a strap, locks a phone, or reconnects after a break. A dependable implementation needs both.</p>
<p>This guide covers the standard Heart Rate Measurement format and the application decisions around it. The <a href="https://wearapi.com/heart-rate-monitor-wear-api/">heart rate monitor wear API overview</a> explains where direct Bluetooth access fits alongside platform health stores and vendor cloud APIs. Choose the route that matches your feature's timing requirements before writing a decoder.</p>
<h2 id="discover-and-subscribe">Discover and subscribe to the measurement</h2>
<p>The Heart Rate Service uses UUID <code>0x180D</code>; its Heart Rate Measurement characteristic uses <code>0x2A37</code>. Discover the service and characteristic through the platform's Bluetooth API, then enable notifications through the supported platform workflow. A device name containing heart rate is not a substitute for service discovery. Names are useful for selection, but the discovered service determines which parser applies.</p>
<p>The <a href="https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/HRS_v1.0/out/en/index-en.html">Bluetooth SIG Heart Rate Service specification</a> defines notification behavior, optional fields, and little-endian byte order. It does not give this measurement a timestamp or guarantee recovery of values missed during a lost connection. Treat the receiver's arrival time as arrival time, with its own uncertainty, rather than silently presenting it as a sensor-provided measurement timestamp.</p>
<p>Keep discovery, subscription, and data reception as separate states. A successful connection can precede completed discovery. A subscription request can fail. A subscribed device may not yet have produced a useful measurement. Exposing these distinctions makes troubleshooting easier and prevents a green connected indicator from claiming that a live measurement stream is already flowing.</p>
<h2 id="read-flags-before-values">Read flags before values</h2>
<p>The first byte is a set of flags. Bit 0 chooses an unsigned heart rate value: 0 means UINT8, and 1 means UINT16. Bit 2 says whether contact detection is supported; when supported, bit 1 indicates detected contact. Bit 3 marks an Energy Expended field, and bit 4 marks one or more RR intervals. The heart rate format and optional-field presence must be evaluated for each notification.</p>
<p>Advance a cursor through the bytes in the declared order. After flags, read heart rate using the selected width. If energy is present, consume its two bytes before reading any RR data. RR values are unsigned sixteen-bit integers, each measured in units of 1/1024 second. Multiple values occupy the remaining field and retain their transmitted order, from older to newer.</p>
<p>Keep unsupported contact distinct from contact not detected. A Boolean alone loses that distinction. Prefer an internal state such as <code>unsupported</code>, <code>detected</code>, or <code>not_detected</code>. Decide separately how your interface reacts to each state. Unsupported contact must not trigger an instruction to tighten a strap when the device never claimed to assess contact.</p>
<h2 id="a-six-byte-example">A six-byte example, decoded carefully</h2>
<p>Consider this synthetic notification, written as hexadecimal bytes:</p>
<pre><code>16 48 00 04 20 03</code></pre>
<p>The first byte, <code>0x16</code>, sets bits 1, 2, and 4. That selects an eight-bit heart rate, supported and detected contact, no Energy Expended field, and available RR intervals. The next byte, <code>0x48</code>, is decimal 72, so the heart rate is 72 beats per minute.</p>
<p>Two byte pairs remain. Little-endian <code>00 04</code> becomes <code>0x0400</code>, or 1024. Dividing by 1024 yields one second. The pair <code>20 03</code> becomes <code>0x0320</code>, or 800; its interval is 0.78125 seconds, or 781.25 milliseconds. The conversion is <code>milliseconds = encoded_value * 1000 / 1024</code>. Treating 800 as milliseconds would quietly change the data.</p>
<p>This fixture is useful for a unit test because it exercises several paths while remaining easy to inspect by hand. Expect one heart rate value, two RR values, a supported contact state, and no energy value. Do not force the heart rate number to equal the reciprocal of one selected RR interval. Preserve the reported values; any derived comparison needs an explicitly defined calculation and context.</p>
<h2 id="reject-broken-packets-without-breaking-the-session">Reject broken packets without breaking the session</h2>
<p>Check length before every read. A payload containing only flags is incomplete. A sixteen-bit heart rate requires two available bytes. If an energy flag is present, ensure that its field exists. When RR data is declared, require at least one complete two-byte value; an odd remaining byte count is an invalid shape for that field.</p>
<p>Separate parsing errors from physiological interpretation. A structurally valid number can still be unsuitable for a particular feature, but that decision belongs in a quality layer with its own reason codes. Do not make a binary decoder clamp values into a convenient display range, because doing so destroys the evidence needed to investigate the device or adapter.</p>
<p>Return an explicit parse result containing either decoded fields or a failure reason. Log the parser version, payload length, and connection context without routinely collecting an identifiable health history in diagnostic logs. Rate-limit repetitive error reporting so a faulty device does not overwhelm the application. The <a href="https://wearapi.com/docs/">developer checklists</a> provide a place to record these error-handling decisions.</p>
<h2 id="track-continuity-as-its-own-data">Track continuity as its own data</h2>
<p>A line chart should distinguish observed measurements from an interval with no observations. Define a freshness policy for the feature, then change the visual state when the last measurement becomes stale. The threshold is a product decision informed by the devices you test; do not hide it as an unexplained constant inside the rendering code.</p>
<p>Record connection sessions with start, end, and termination reason where available. After reconnecting, begin a new continuity segment. Repeating the last heart rate throughout the gap invents observations. Drawing a smooth line across the break can suggest the same thing. A visible gap, combined with an age label for the last known value, gives the user a more faithful account.</p>
<p>Use a monotonic clock for elapsed-time calculations within a running session, alongside wall-clock timestamps for storage and presentation. If the phone's clock changes, elapsed-time logic should not suddenly decide that a fresh reading is hours old. Where precise alignment with another sensor matters, document the limits of arrival timestamps and test the full transport path.</p>
<h2 id="rr-data-is-not-an-ecg-trace">RR data is not an ECG trace</h2>
<p>A list of beat intervals does not contain an ECG waveform. The integration should label the measurement it has and avoid implying additional sensing capabilities from the presence of an RR field. Likewise, successfully reading standard Bluetooth data does not establish that a device or application is suitable for diagnosis.</p>
<p>If your product calculates a variability metric, define the input eligibility, observation window, artifact policy, and minimum usable coverage. Store the derived value with the algorithm version and its input interval. Missing or filtered intervals should affect availability according to that documented policy, rather than being silently replaced with values that make the output look stable.</p>
<p>The same principle applies to coaching features: a calculation needs a specified purpose and validation appropriate to that purpose. Start with a transparent display of measurements and continuity. Add interpretation only when you can explain how the input supports it. The <a href="https://wearapi.com/wearable-api/">wearable API integration map</a> helps keep source access separate from application-level interpretation.</p>
<h2 id="test-across-transitions">Test across transitions, not just sample values</h2>
<ul><li>Switch between eight-bit and sixteen-bit heart rate formats within one simulated connection.</li><li>Alternate packets with and without optional energy and RR fields.</li><li>Send several identical measurements in sequence and verify that legitimate observations remain visible.</li><li>Test unsupported contact, detected contact, and lost contact independently.</li><li>Truncate a packet at each field boundary and verify controlled failure.</li><li>Disconnect during activity, reconnect, and confirm that the chart preserves the gap.</li><li>Change the wall clock during a session and check measurement freshness.</li></ul>
<p>Include representative physical devices after deterministic parser tests pass. Capture the observed behavior for each supported combination of device, firmware, phone, and operating system. A passing synthetic fixture proves the arithmetic in that case; it cannot establish how a phone manages an active connection when the application changes state.</p>
<h2 id="ship-a-measurement-you-can-explain">Ship a measurement you can explain</h2>
<p>A good decoder reads each flag, advances through the correct fields, and preserves units and optionality. A good product also shows stale data honestly and records continuity separately from value. Combine those practices with the <a href="https://wearapi.com/blog/wearable-data-quality/">data quality workflow</a>, and debugging becomes a matter of inspectable records instead of guessing why a chart looks wrong.</p>]]></content:encoded>
</item>
<item>
<title>Wearable API integration: a practical starting guide</title>
<link>https://wearapi.com/blog/wearable-api-integration-guide/</link>
<guid isPermaLink="true">https://wearapi.com/blog/wearable-api-integration-guide/</guid>
<description>Choose the right access route, define a usable data contract, and build a sync process that survives delayed, missing, and repeated records.</description>
<pubDate>Tue, 19 Mar 2024 00:00:00 +0000</pubDate>
<category>Integration</category>
<content:encoded><![CDATA[<p>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.</p>
<p>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 <a href="https://wearapi.com/wearable-api/">wearable API overview</a>.</p>

<h2 id="write-the-data-requirement-first">Write the data requirement first</h2>
<p>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.</p>
<p>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.</p>
<p>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.</p>

<h2 id="choose-an-access-route">Choose an access route</h2>
<p>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.</p>
<p>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 <a href="https://wearapi.com/blog/health-connect-vs-healthkit/">Health Connect and HealthKit comparison</a> examines this path in more detail.</p>
<p>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.</p>
<p>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.</p>

<h2 id="connect-access-to-a-visible-purpose">Connect access to a visible purpose</h2>
<p>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.</p>
<p>For a cloud integration using OAuth, separate the user's authorization from the application's own account session. The <a href="https://www.rfc-editor.org/rfc/rfc6749.html">OAuth 2.0 authorization framework</a> 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.</p>
<p>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 <a href="https://wearapi.com/blog/wearable-api-consent-security/">consent and security guide</a> covers that boundary.</p>

<h2 id="define-a-small-normalization-contract">Define a small normalization contract</h2>
<p>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.</p>
<p>A compact conceptual record might look like this:</p>
<pre><code>{
  "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"
}</code></pre>
<p>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.</p>
<p>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.</p>
<p>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.</p>

<h2 id="make-synchronization-repeatable">Make synchronization repeatable</h2>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>

<h2 id="test-the-inconvenient-cases">Test the inconvenient cases</h2>
<p>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.</p>
<ul>
<li>Import the same batch twice and confirm the visible workout count stays unchanged.</li>
<li>Interrupt processing between storage and checkpoint advancement, then resume it.</li>
<li>Revoke one optional permission and verify that unrelated features remain usable.</li>
<li>Import a workout through two routes and check the source-selection policy.</li>
<li>Move the display time zone and confirm that absolute duration remains consistent.</li>
<li>Feed an unknown activity code and preserve the source label instead of guessing.</li>
</ul>
<p>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.</p>

<h2 id="evaluate-the-whole-integration-cost">Evaluate the whole integration cost</h2>
<p>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.</p>
<p>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 <a href="https://wearapi.com/pricing/">integration cost planning page</a> offers a framework for separating provider charges from engineering and ongoing maintenance.</p>

<h2 id="start-with-one-trustworthy-feature">Start with one trustworthy feature</h2>
<p>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 <a href="https://wearapi.com/docs/">implementation checklists</a> to turn the contract, permission flow, and recovery cases into a repeatable review for the next device family.</p>]]></content:encoded>
</item>
</channel></rss>