# Xiaomi Mi Band API: get Mi Band data into FHIR (no public cloud API)

> Xiaomi has no public cloud API: read Mi Band data from Health Connect or Apple Health via Mi Fitness and store it as FHIR R4 Observations, with code.

Source: https://developers.anpheros.com/guides/xiaomi-mi-band-api

**Xiaomi has no public cloud API for Mi Band or Mi Fitness data: its older Mi Health Cloud platform is open only to Xiaomi ecosystem companies and partners. What does work is the phone. Mi Fitness writes to Health Connect on Android and to Apple Health on iPhone, so your app can read Mi Band data there and store each reading as a LOINC-coded FHIR R4 Observation with one standard API call. Anpheros does not connect to Xiaomi's cloud itself: your code reads the phone's health store, and Anpheros keeps the record with the person's consent.**

## Read Xiaomi Mi Band data and store it in FHIR

There is no Xiaomi endpoint to call, so the data is read on the phone: your app reads Health Connect (Android) or HealthKit (iPhone), and your backend writes FHIR. On Android, the person turns on cloud sync in Mi Fitness, then Health Connect under Profile → Third-party data. On iPhone, they pick heart rate, SpO₂ and sleep for Apple Health in Mi Fitness.

On the phone, read `HeartRateRecord`, `OxygenSaturationRecord` and `SleepSessionRecord` from Health Connect, or `heartRate`, `oxygenSaturation` and `sleepAnalysis` from HealthKit. The phone code is in [Health Connect to FHIR](https://developers.anpheros.com/guides/health-connect-fhir) and [Apple Health to FHIR](https://developers.anpheros.com/guides/apple-health-fhir).

Then the night's average SpO₂ as a FHIR Observation in the person's record (sandbox key `sk_test_…`):

```bash
curl -X POST https://platform.anpheros.com/fhir/R4/Observation \
  -H "Authorization: Bearer $ANPHEROS_KEY" \
  -H "Content-Type: application/fhir+json" \
  -H "X-Anpheros-Author-Type: device" \
  -d '{"resourceType":"Observation","status":"final",
       "category":[{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/observation-category","code":"vital-signs"}]}],
       "code":{"coding":[{"system":"http://loinc.org","code":"59408-5","display":"Oxygen saturation in Arterial blood by Pulse oximetry"}]},
       "subject":{"reference":"Patient/<id>"},
       "effectivePeriod":{"start":"2026-11-02T23:20:00+01:00","end":"2026-11-03T06:45:00+01:00"},
       "valueQuantity":{"value":96,"unit":"%","system":"http://unitsofmeasure.org","code":"%"},
       "device":{"display":"Mi Band (via Mi Fitness, Health Connect)"}}'
```

The same in Python, on your backend: the nights your phone app read from `SleepSessionRecord` become one transaction Bundle.

```python
import os, requests

FHIR = "https://platform.anpheros.com/fhir/R4"
fhir = {"Authorization": f"Bearer {os.environ['ANPHEROS_KEY']}", "Content-Type": "application/fhir+json"}

# What your phone app sends: one entry per sleep session it read from Health Connect or HealthKit
nights = [
    {"start": "2026-11-01T23:40:00+01:00", "end": "2026-11-02T07:05:00+01:00", "minutes": 412},
    {"start": "2026-11-02T23:20:00+01:00", "end": "2026-11-03T06:45:00+01:00", "minutes": 405},
]

entries = [{
    "request": {"method": "POST", "url": "Observation"},
    "resource": {
        "resourceType": "Observation", "status": "final",
        "category": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/observation-category", "code": "activity"}]}],
        "code": {"coding": [{"system": "http://loinc.org", "code": "93832-4", "display": "Sleep duration"}]},
        "subject": {"reference": "Patient/<id>"},
        "effectivePeriod": {"start": n["start"], "end": n["end"]},
        "valueQuantity": {"value": n["minutes"], "unit": "min", "system": "http://unitsofmeasure.org", "code": "min"},
        "device": {"display": "Mi Band (via Mi Fitness, Health Connect)"},
    },
} for n in nights]

r = requests.post(FHIR, headers=fhir, json={"resourceType": "Bundle", "type": "transaction", "entry": entries})
print(r.status_code, len(entries), "nights saved")
```

And in JavaScript (Node 18+), a daily heart rate summary with minimum and maximum:

```js
const fhir = { Authorization: `Bearer ${process.env.ANPHEROS_KEY}`, 'Content-Type': 'application/fhir+json' };
const bpm = (value) => ({ value, unit: '/min', system: 'http://unitsofmeasure.org', code: '/min' });

// What your phone app sends after reading HeartRateRecord (Android) or heartRate (iPhone) for one day
const day = { date: '2026-11-02', avg: 72, min: 51, max: 131 };

await fetch('https://platform.anpheros.com/fhir/R4/Observation', {
  method: 'POST', headers: { ...fhir, 'X-Anpheros-Author-Type': 'device' },
  body: JSON.stringify({
    resourceType: 'Observation', status: 'final',
    category: [{ coding: [{ system: 'http://terminology.hl7.org/CodeSystem/observation-category', code: 'vital-signs' }] }],
    code: { coding: [{ system: 'http://loinc.org', code: '8867-4', display: 'Heart rate' }] },
    subject: { reference: 'Patient/<id>' },
    effectivePeriod: { start: `${day.date}T00:00:00+01:00`, end: `${day.date}T23:59:59+01:00` },
    valueQuantity: bpm(day.avg),
    component: [
      { code: { text: 'minimum' }, valueQuantity: bpm(day.min) },
      { code: { text: 'maximum' }, valueQuantity: bpm(day.max) },
    ],
    device: { display: 'Mi Band (via Mi Fitness, Health Connect)' },
  }),
});
```

The payload shapes (`nights`, `day`) are your own: your phone app decides what it sends. The Anpheros side is standard FHIR R4, so the same requests work with any FHIR server.

## Ways to get Xiaomi Mi Band data into FHIR

| Path | Status | What you need |
|---|---|---|
| Your backend reads a Xiaomi cloud API, then writes FHIR to Anpheros | **Not available** | No public API. Xiaomi's Mi Health Cloud platform is for Xiaomi ecosystem companies and partners only |
| Mi Fitness → Health Connect → your Android app → Anpheros | **Works today** | Cloud sync on in Mi Fitness, Health Connect turned on under Profile → Third-party data, Health Connect permissions. See [Health Connect to FHIR](https://developers.anpheros.com/guides/health-connect-fhir) |
| Mi Fitness → Apple Health → your iPhone app reads HealthKit → Anpheros | **Works today** | Heart rate, SpO₂ and sleep, each chosen in Mi Fitness; HealthKit permissions. See [Apple Health to FHIR](https://developers.anpheros.com/guides/apple-health-fhir) |
| A direct Xiaomi connector inside Anpheros | **On our roadmap** | Not available yet. Use the button below to tell us you need it |

<!-- visual:cta-wear-xiaomi -->

## What Xiaomi offers developers

**Cloud data.** Xiaomi publishes no public cloud API for Mi Fitness or Mi Band data. Its older Mi Health Cloud open platform says it is open only to Xiaomi ecosystem companies and partners. It used an AppID and AppKey from the Xiaomi developer site plus a Xiaomi Account OAuth 2.0 token, and its Android SDK targets Android 2.2. Treat it as a legacy, partner-only platform, not a route for a new app.

**Phone health stores.** Mi Fitness supports Health Connect once cloud sync is on (Profile → Third-party data). On iPhone, it syncs heart rate, SpO₂ and sleep to Apple Health, and the person chooses each item. Xiaomi does not list which data types it writes to Health Connect, so read what your app actually finds there.

**Limits and recent changes.** No API, so no rate limits or changelog to follow. What reaches your app depends on the Mi Fitness version and the person's sharing settings.

Sources: [Xiaomi Mi Health Cloud open platform](https://dev.mi.com/docs/micloud/health/), [its Android SDK](https://dev.mi.com/docs/micloud/health/android_sdk/), [Mi Fitness and Health Connect](https://www.mi.com/global/support/faq/details/KA-728033/), [Mi Fitness and Apple Health](https://www.mi.com/global/support/faq/details/KA-703529/), [choosing Apple Health items](https://www.mi.com/global/support/faq/details/KA-731998/), November 2026.

## Xiaomi Mi Band data as FHIR Observations

| Mi Band data (as it reaches the health store) | LOINC | UCUM unit | Note |
|---|---|---|---|
| Heart rate (`HeartRateRecord`, `heartRate`) | 8867-4 | `/min` | daily average, minimum and maximum rather than every sample |
| SpO₂ (`OxygenSaturationRecord`, `oxygenSaturation`) | 59408-5 | `%` | category vital-signs |
| Sleep duration (`SleepSessionRecord`, `sleepAnalysis`) | 93832-4 | `min` | one per night |
| Sleep stages, if present | 93831-6, 93830-8, 93829-0 | `min` | deep, light, REM; Xiaomi does not say whether stages are shared |
| Other types (steps and more) | see note | | Xiaomi does not list them; map what you find with the table in [Wearable data in FHIR](https://developers.anpheros.com/guides/wearable-data-fhir) |

## Frequently asked questions

### Does Xiaomi have a public API?
Not for health data. Xiaomi has no public cloud API for Mi Fitness or Mi Band. Its Mi Health Cloud platform is for Xiaomi ecosystem companies and partners only.

### Is there a Mi Band API for developers?
Not a cloud one. The practical route is the phone: Mi Fitness writes to Health Connect and Apple Health, and your app reads it there with the person's permission.

### Can I get Mi Band data on iPhone?
Yes, through Apple Health. Mi Fitness syncs heart rate, SpO₂ and sleep to Apple Health, chosen per item by the person, and your app reads them with HealthKit.

### Can I get Mi Band data on Android?
Yes, through Health Connect. The person turns on cloud sync in Mi Fitness, then Health Connect under Profile → Third-party data. Your app then reads Health Connect.

### Which Mi Band data reaches Health Connect?
Xiaomi does not list the types. Ask Health Connect for the records you need and check what comes back with Mi Fitness as the source.

### Does Anpheros connect to Xiaomi directly?
Not yet. Today your app reads Health Connect or HealthKit and writes standard FHIR to Anpheros. A direct Xiaomi connector is on our roadmap; tell us with the button on this page if you need it.

## Related

- [Wearable APIs: every brand compared](https://developers.anpheros.com/guides/wearable-apis)
- [Wearable data in FHIR (Apple Health, Health Connect)](https://developers.anpheros.com/guides/wearable-data-fhir)
- [Apple Health (HealthKit) to FHIR](https://developers.anpheros.com/guides/apple-health-fhir)
- [Health Connect to FHIR](https://developers.anpheros.com/guides/health-connect-fhir)
- [Amazfit and Zepp API to FHIR](https://developers.anpheros.com/guides/amazfit-zepp-api) · [Huawei Health Kit API to FHIR](https://developers.anpheros.com/guides/huawei-health-api) · [Samsung Health to FHIR](https://developers.anpheros.com/guides/samsung-health-fhir)
