Skip to main content
RapidDev - Software Development Agency
retool-integrationsREST API Resource

How to Integrate Retool with Apple HealthKit

Apple HealthKit is an on-device iOS framework with no REST API — it cannot be connected to Retool directly. The practical approach is to export HealthKit data via Apple Health XML export, iOS shortcuts that push data to a server, or third-party health data bridges, then build a health analytics dashboard in Retool from the imported data stored in a database or intermediate API.

What you'll learn

  • Why HealthKit cannot be connected directly to Retool and what the architectural constraints are
  • How to export Apple Health data as XML and parse it for import into a database
  • How to use iOS Shortcuts to push HealthKit metrics to a server endpoint that Retool can query
  • How to build a health analytics dashboard in Retool using imported HealthKit data
  • How to use third-party health data APIs (like Withings or Garmin) as accessible alternatives to HealthKit
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Advanced16 min read45 minutesOtherLast updated April 2026RapidDev Engineering Team
TL;DR

Apple HealthKit is an on-device iOS framework with no REST API — it cannot be connected to Retool directly. The practical approach is to export HealthKit data via Apple Health XML export, iOS shortcuts that push data to a server, or third-party health data bridges, then build a health analytics dashboard in Retool from the imported data stored in a database or intermediate API.

Quick facts about this guide
FactValue
ToolApple HealthKit
CategoryOther
MethodREST API Resource
DifficultyAdvanced
Time required45 minutes
Last updatedApril 2026

Build a Health Data Analytics Dashboard in Retool from HealthKit Data

Apple HealthKit stores health and fitness data locally on iPhone with strong privacy protections — no server-side API exists for third-party tools like Retool to query directly. This is by design: Apple requires that HealthKit data access go through native iOS apps with explicit user consent, using entitlements granted during App Store review. External web services and internal tools platforms cannot obtain these entitlements.

Despite this constraint, there are practical patterns for getting HealthKit data into a Retool dashboard. The most common approach for internal health monitoring programs (employee wellness, clinical research, remote patient monitoring) is a bridge architecture: a native iOS app or iOS Shortcut reads HealthKit data and sends it to a server-side database or API, which Retool then queries normally. Apple's own Health Export feature produces a detailed XML file that can be parsed and loaded into PostgreSQL for analysis.

For most enterprise use cases — corporate wellness programs, clinical trial monitoring, occupational health tracking — a better alternative is to use wearable device APIs that do expose REST endpoints. Garmin Connect, Fitbit, and Withings all offer proper OAuth-based APIs that Retool can query directly, covering the same step count, heart rate, sleep, and activity metrics that HealthKit aggregates from those same devices.

Integration method

REST API Resource

HealthKit has no public REST API — all data lives on-device under iOS security controls. To surface HealthKit data in a Retool dashboard, you must first extract the data from iOS using an approved method (Apple Health XML export, iOS Shortcuts automation, or a third-party health bridge app), store it in an accessible data layer such as a PostgreSQL database or intermediate REST API, and then connect Retool to that data layer via a REST API Resource or database connector. This is a two-stage integration architecture, not a direct API connection.

Prerequisites

  • Understanding of HealthKit's architecture and why direct API access is not possible
  • An intermediate data layer: either a PostgreSQL/MySQL database, a simple REST API endpoint, or a supported third-party health API (Garmin, Fitbit, or Withings)
  • A Retool account with permission to create Resources
  • For the XML export approach: Python or Node.js environment to parse Apple Health Export XML
  • For the iOS Shortcuts approach: iPhone with iOS 13+ and a server endpoint that accepts JSON POST requests

Step-by-step guide

1

Understand the HealthKit architecture constraint and choose your data bridge

Before building anything in Retool, it is essential to understand why HealthKit cannot be queried directly and which bridge pattern fits your use case. HealthKit is an iOS framework that stores health data in a sandboxed on-device database. Apple restricts API access to native iOS apps with special entitlements — web services, internal tools platforms, and SaaS applications have no path to direct access. There are three practical bridge patterns to evaluate. The first is the Apple Health XML Export: iPhone users can go to the Health app → their profile icon → Export All Health Data to download a ZIP containing export.xml. This XML contains all stored health data and can be parsed programmatically into a database. This is best for one-time or periodic batch imports. The second pattern is iOS Shortcuts automation: using the iOS Shortcuts app, users can create personal automations that read HealthKit values (Health Records queries are not available, but personal metrics like steps and heart rate are) and use the 'Get Contents of URL' action to POST data to a server endpoint. This enables near-daily automated data delivery without native app development. The third pattern is using wearable APIs directly: if your health data actually originates from a Garmin, Fitbit, or Withings device, those manufacturers expose REST APIs that Retool can query directly — bypassing HealthKit entirely. For most enterprise scenarios, this third approach is both simpler and more scalable. Choose your bridge pattern before proceeding to the next steps.

Pro tip: For enterprise wellness programs, Garmin Health API and Fitbit Web API both offer bulk data access with proper OAuth and webhook support. These are significantly easier to integrate with Retool than HealthKit workarounds.

Expected result: You have selected a bridge pattern (XML export, iOS Shortcuts, or wearable API) appropriate for your use case and have the necessary access credentials or data files ready.

2

Parse Apple Health Export XML and load data into a database

If you are using the Apple Health XML export approach, this step covers importing the data into a queryable database. The Apple Health export produces a file called export.xml inside a ZIP archive. The XML structure uses an element called 'Record' with attributes including 'type' (e.g., HKQuantityTypeIdentifierStepCount), 'value', 'startDate', and 'endDate'. The file can be very large — years of health data from an Apple Watch can exceed 500 MB. To parse the XML efficiently, use a streaming parser rather than loading the entire file into memory. In Python, the lxml library with iterparse works well for this. Write a script that extracts records of each health type into separate database tables: steps_daily, heart_rate_readings, sleep_analysis, workouts. Create a PostgreSQL database (Supabase or a hosted PostgreSQL instance works well) with tables structured around the health metric types you need. A simple steps_daily table might include columns: record_date DATE, step_count INTEGER, source_name TEXT, user_id INTEGER. Run the import script locally or in a cloud function to load the XML data. Once the data is in PostgreSQL, configure a PostgreSQL Resource in Retool by clicking Resources tab → Add Resource → PostgreSQL, entering your database credentials, and saving. Test the connection to confirm Retool can reach the database.

health_schema.sql
1-- Example PostgreSQL table schema for HealthKit data
2CREATE TABLE health_steps_daily (
3 id SERIAL PRIMARY KEY,
4 user_id INTEGER NOT NULL,
5 record_date DATE NOT NULL,
6 step_count INTEGER NOT NULL,
7 source_name TEXT,
8 imported_at TIMESTAMP DEFAULT NOW()
9);
10
11CREATE TABLE health_heart_rate (
12 id SERIAL PRIMARY KEY,
13 user_id INTEGER NOT NULL,
14 recorded_at TIMESTAMP NOT NULL,
15 bpm DECIMAL(5,1) NOT NULL,
16 source_name TEXT
17);
18
19CREATE TABLE health_sleep (
20 id SERIAL PRIMARY KEY,
21 user_id INTEGER NOT NULL,
22 sleep_start TIMESTAMP NOT NULL,
23 sleep_end TIMESTAMP NOT NULL,
24 sleep_category TEXT, -- 'HKCategoryValueSleepAnalysisAsleep'
25 duration_minutes INTEGER
26);

Pro tip: Filter the XML import to only the metric types you need. A full Apple Health export for an active Apple Watch user can contain tens of millions of records — importing everything into a database is inefficient if you only need steps and sleep data.

Expected result: Your PostgreSQL database contains parsed HealthKit data in structured tables, and a Retool PostgreSQL Resource successfully connects to the database.

3

Set up an iOS Shortcuts endpoint for automated daily data delivery

For near-real-time health data delivery without native app development, iOS Shortcuts can read HealthKit data and POST it to a server endpoint. First, create a server endpoint that accepts JSON POST requests. A simple serverless function (Cloudflare Worker, Vercel Edge Function, or AWS Lambda) can receive the data and insert it into your database. The endpoint should accept a JSON body and store the records. In the iOS Shortcuts app on iPhone, create a new Shortcut. Add a 'Find Health Samples' action — choose the metric type (e.g., Steps), set the date range to 'Last Day', and set Sort by 'Start Date'. Add a 'Get Contents of URL' action configured as a POST request to your server endpoint URL. Set the Request Body to JSON, and construct the payload using the Shortcut variables from the previous step. Set this Shortcut to run automatically via a Personal Automation triggered each morning. This creates a daily pipeline from HealthKit to your database. In Retool, your dashboard queries the database the same way as with the XML import approach — through the PostgreSQL Resource you configured. The advantage of this approach over the XML import is freshness: data arrives automatically each day rather than requiring a manual export and import cycle.

health_endpoint.js
1// Example server endpoint that receives iOS Shortcuts health data
2// Deploy this to Cloudflare Workers, Vercel, or AWS Lambda
3
4export async function handleHealthDataUpload(request) {
5 const body = await request.json();
6 const { user_id, date, metrics } = body;
7
8 // metrics: { steps: 8432, resting_hr: 62, sleep_hours: 7.5 }
9 // Insert into your PostgreSQL database
10
11 return new Response(JSON.stringify({ success: true }), {
12 headers: { 'Content-Type': 'application/json' }
13 });
14}

Pro tip: iOS Shortcuts can only read aggregate HealthKit data (sums, averages) through the 'Find Health Samples' action — it cannot read raw sensor readings or clinical health records. This is sufficient for step counts, heart rate averages, and sleep duration.

Expected result: Your server endpoint receives daily health metrics from iOS Shortcuts and stores them in the database, which Retool queries through the PostgreSQL Resource.

4

Build the health analytics dashboard in Retool

With health data accessible in a database, build the Retool dashboard. Open or create a Retool app and in the Code panel, create a query named 'getHealthMetrics'. Select your PostgreSQL Resource. Write a SQL query that retrieves the health data filtered by date range and user. Use Retool's date picker components to bind the date filters dynamically. A useful starting query retrieves daily step counts and calculates rolling averages. Add additional queries for heart rate trends and sleep analysis. From the component panel on the right side of the Retool editor, drag a Chart component onto the canvas. Set the Chart type to Line, set the Data property to {{ getStepsQuery.data }}, configure the x-axis to the record_date column and y-axis to step_count. Add a second Chart below it showing heart rate over time using similar configuration. Add a Table component for the raw daily metrics data. Add a Date Range Picker component at the top of the dashboard and bind both queries' date parameters to its value. Add Select components for filtering by user_id if you have multi-user data. For aggregate stats, add Statistic components showing 7-day average steps, average sleep hours, and average resting heart rate — calculate these values in JavaScript transformer functions attached to each query.

steps_query.sql
1-- Query: daily steps with 7-day rolling average
2SELECT
3 record_date,
4 step_count,
5 AVG(step_count) OVER (
6 ORDER BY record_date
7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
8 ) AS rolling_7day_avg
9FROM health_steps_daily
10WHERE
11 user_id = {{ userSelect.value || 1 }}
12 AND record_date BETWEEN {{ dateRange.start }} AND {{ dateRange.end }}
13ORDER BY record_date ASC;

Pro tip: Use Retool's conditional column formatting in Tables to highlight days where step count is below a goal threshold (e.g., under 8,000 steps). Set the background color to light red for rows where step_count < 8000 using the Column's color rule settings.

Expected result: A Retool health analytics dashboard displays step count trends, heart rate data, and sleep metrics in Charts and Tables, filterable by date range and user.

5

Consider Garmin, Fitbit, or Withings APIs as direct HealthKit alternatives

If your health data originates from a supported wearable device — Apple Watch, Fitbit, Garmin, or Withings — the most reliable long-term architecture is to connect Retool directly to those device manufacturers' REST APIs, bypassing HealthKit entirely. Garmin Health API offers OAuth 1.0a authentication and endpoints for activities, sleep, stress, and body composition. Fitbit Web API uses OAuth 2.0 with PKCE and exposes endpoints for steps, heart rate, sleep, and activity. Withings Health API uses OAuth 2.0 and covers weight, blood pressure, sleep, and activity data. These APIs are all queryable directly from Retool's REST API Resource — no bridge infrastructure required. To configure a direct wearable API connection, click Resources tab → Add Resource → REST API. Enter the base URL for the wearable API (e.g., https://apis.garmin.com for Garmin or https://api.fitbit.com for Fitbit). Set the Authentication type to OAuth 2.0 and configure the client credentials from the device manufacturer's developer portal. Retool's OAuth 2.0 support handles token refresh automatically. For complex integrations spanning multiple health data sources, custom data normalization transformers, and Retool Workflows for scheduled data synchronization, RapidDev's team can help architect and build your Retool health monitoring solution.

wearable_normalizer.js
1// JavaScript transformer: normalize data from multiple wearable API formats
2const rawData = data;
3
4// Handle both Fitbit and Garmin response shapes
5const activities = rawData['activities-steps'] || rawData.dailies || [];
6
7return activities.map(day => ({
8 date: day.dateTime || day.calendarDate,
9 steps: parseInt(day.value || day.steps || 0),
10 source: rawData['activities-steps'] ? 'Fitbit' : 'Garmin'
11}));

Pro tip: Garmin Health API and Fitbit Web API both require registering an application on their developer portals and obtaining API credentials. The approval process can take several days for Garmin's Health API — start this process early if you plan to use it.

Expected result: A direct REST API Resource connects Retool to the wearable manufacturer's API, providing the same health metrics as HealthKit with no bridge infrastructure required.

Common use cases

Build a corporate wellness program dashboard from exported HealthKit data

Create a Retool analytics panel that displays aggregated (anonymized) health metrics for a corporate wellness program — average step counts, activity trends, and wellness goal completion rates. Import data from employee-submitted Apple Health XML exports into a PostgreSQL database, then query that database from Retool. Use Charts for trend visualization and Tables for per-participant progress without exposing individual identifiable health records.

Retool Prompt

Build a Retool dashboard that connects to a PostgreSQL database containing parsed Apple Health export data. Show Charts for average daily steps by week, a Table of wellness goal completion rates by department, and a date range filter. All data should be aggregated to avoid displaying individual health records.

Copy this prompt to try it in Retool

Build an iOS Shortcuts → server → Retool health metrics pipeline

Set up an automated data pipeline using iOS Shortcuts that reads HealthKit data (steps, heart rate, sleep) daily and posts it to a REST API endpoint. Store the incoming data in a database, then build a Retool dashboard that queries the stored metrics. This pattern enables near-real-time health monitoring for individuals who have explicitly set up the automation.

Retool Prompt

Build a Retool health tracking panel that queries a REST API endpoint receiving daily health data from iOS Shortcuts. Show a Table of daily metrics (steps, resting heart rate, sleep hours), a Chart for weekly trends, and a stat card showing 7-day averages. Include a date range picker for historical analysis.

Copy this prompt to try it in Retool

Build a multi-source wearable analytics dashboard using HealthKit alternatives

Construct a Retool dashboard that pulls fitness and health data from wearable device APIs (Garmin, Fitbit, Withings) that offer proper REST APIs, covering the same underlying metrics that HealthKit aggregates. Display unified health metrics across device types, enabling health program managers to view participant data without requiring native iOS app development.

Retool Prompt

Build a Retool dashboard that queries the Garmin Connect API and Fitbit API for health metrics from multiple participants. Show a unified Table with steps, heart rate, and sleep data, a Chart comparing activity levels by week, and dropdown filters to view individual participant data. Use Retool Workflows to refresh data nightly.

Copy this prompt to try it in Retool

Troubleshooting

Apple Health XML export file is too large to parse — parsing script runs out of memory or times out

Cause: A full Apple Health export from an Apple Watch user with years of data can contain tens of millions of records and exceed 500 MB as a compressed ZIP. Loading the entire XML into memory at once causes out-of-memory errors in standard parsing approaches.

Solution: Use a streaming XML parser that reads records one at a time without loading the full file. In Python, use lxml's iterparse function: for event, elem in iterparse('export.xml', events=['end']). Process each 'Record' element as you encounter it, insert it into the database in batches of 1,000 records, and then clear the element from memory using elem.clear(). This keeps memory usage constant regardless of file size.

iOS Shortcuts health data POST fails with CORS error or connection refused

Cause: The server endpoint receiving iOS Shortcuts data must be publicly accessible over HTTPS. iOS Shortcuts cannot connect to localhost or endpoints without valid SSL certificates. A self-signed certificate causes the HTTPS connection to fail.

Solution: Deploy your receiving endpoint to a publicly accessible HTTPS URL. Cloudflare Workers, Vercel serverless functions, or AWS Lambda with API Gateway all provide free HTTPS endpoints with valid certificates. Test the endpoint by sending a curl POST request from your computer before configuring the iOS Shortcut.

Retool dashboard shows no data or empty charts after connecting to the health database

Cause: The most common causes are: the date range filter is set to a period with no imported data, the user_id filter is set to a value that does not exist in the database, or the database query uses date comparison operators that do not match the column data type.

Solution: In Retool's Code panel, run the health metrics query and inspect the raw Results tab to see what the query returns. If the results are empty, open the query and temporarily remove all WHERE clauses to check if the database contains any data. Verify that date columns in PostgreSQL are stored as DATE or TIMESTAMP types and that your Retool date range values are cast appropriately in the SQL WHERE clause.

typescript
1-- Debug query: check if health data exists in any date range
2SELECT record_date, step_count, user_id
3FROM health_steps_daily
4ORDER BY record_date DESC
5LIMIT 10;

Wearable API (Garmin or Fitbit) returns 401 Unauthorized after initial successful connection

Cause: OAuth 2.0 access tokens expire — Fitbit tokens expire after 8 hours by default, and Garmin tokens may also need refreshing. If Retool's OAuth 2.0 token refresh is not configured correctly, the resource stops working after the initial token expires.

Solution: In the Retool Resource settings for the wearable API, verify that the OAuth 2.0 configuration includes the Token URL (for token refresh), client ID, and client secret. Retool handles automatic token refresh when these fields are correctly configured. For Fitbit, the refresh token has a longer lifespan — ensure 'Use refresh token' is enabled in the resource OAuth settings.

Best practices

  • Design the integration around an intermediate data layer (PostgreSQL database) rather than attempting direct HealthKit access — this architecture is more reliable, queryable, and scalable than any real-time bridge
  • For new health monitoring programs, use Garmin Health API, Fitbit Web API, or Withings Health API instead of HealthKit — they offer direct REST access that Retool can query without bridge infrastructure
  • Anonymize and aggregate health data in the database layer before surfacing it in Retool dashboards — avoid building interfaces that display individual identifiable health records unless strictly necessary
  • Obtain explicit written consent from individuals before collecting any HealthKit-derived health data, and ensure your data handling complies with HIPAA, GDPR, or applicable health data privacy laws
  • Use Retool Workflows to schedule nightly database queries that calculate aggregate metrics (weekly averages, rolling trends) and cache them in summary tables — this improves dashboard load performance for large datasets
  • Store OAuth tokens for wearable APIs in Retool Configuration Variables marked as secrets (Settings → Configuration Variables) rather than directly in resource settings
  • Implement row-level access controls in your health database using PostgreSQL RLS or application-level user_id filtering to ensure Retool users can only see health data they are authorized to access

Alternatives

Frequently asked questions

Can Retool connect directly to Apple HealthKit?

No. HealthKit is an on-device iOS framework with no REST API — it cannot be queried by external services including Retool. Apple restricts HealthKit data access to native iOS apps that have been granted specific entitlements through App Store review. The practical approach is to extract data from HealthKit via Apple Health XML export or iOS Shortcuts, store it in an accessible database, and connect Retool to that database.

What is the easiest way to get health data into a Retool dashboard?

The easiest approach is to use a wearable device API that offers direct REST access — Garmin, Fitbit, and Withings all provide OAuth-based APIs that Retool can query directly through a REST API Resource, without any HealthKit bridge architecture. If you specifically need HealthKit data from iPhone users, iOS Shortcuts automation that POSTs daily metrics to a server endpoint is the lowest-effort HealthKit bridge option.

Is it legal to collect HealthKit data in a corporate wellness program?

This depends on your jurisdiction and program structure. In the United States, HIPAA applies if your organization is a covered entity or business associate handling protected health information. Even for non-HIPAA programs, obtaining explicit written consent from employees before collecting health data is essential. Consult your legal team before building any health monitoring program, and design the system to collect only the minimum necessary data with appropriate access controls.

How large is a typical Apple Health XML export?

A compressed ZIP export from an Apple Watch user with 2-3 years of continuous wear can be 100-500 MB compressed and several gigabytes uncompressed. The export includes raw sensor readings at high frequency for metrics like heart rate, so the volume is substantial. Parsing scripts need to use streaming XML parsers and batch database inserts to handle this size efficiently without exhausting memory.

Can I use Retool to build a HIPAA-compliant health dashboard?

Retool Cloud has SOC 2 Type II certification but is not itself HIPAA-certified without a Business Associate Agreement (BAA). For HIPAA compliance, use self-hosted Retool deployed in a HIPAA-eligible infrastructure environment (such as AWS GovCloud or a HIPAA-compliant private cloud), ensure all data in transit is encrypted with TLS, implement appropriate access controls and audit logging, and sign a BAA with all relevant vendors. Consult a HIPAA compliance specialist before processing PHI in Retool.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Integrations are where projects stall

We wire Retool integrations like this one every week — auth, webhooks, edge cases included. Fixed-price builds from $13K, delivered in 6–10 weeks.

Talk to an integration engineer

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.