با استفاده از Google Health API، تجربه‌های خواب خود را توسعه دهید

The Google Health API provides data types that track a user's sleep patterns, including duration, quality, and physiological metrics during rest. These metrics help applications provide insights into recovery, sleep hygiene, and long-term health trends.

Physiological metrics such as Heart Rate Variability (HRV), Oxygen Saturation (SpO2), and respiratory rate are recorded specifically during sleep because the body is in a stable, resting state. This allows the API to capture a baseline of the user's autonomic and respiratory health without the interference of daytime stressors, physical activity, or varying environmental conditions.

تفاوت‌های بین این نوع داده‌ها را درک کنید تا مشخص کنید کدام معیارها برای برنامه شما مناسب هستند.

انواع داده پشتیبانی شده

این API از انواع داده‌های زیر برای اندازه‌گیری خواب پشتیبانی می‌کند:

جدول: انواع داده‌های خواب در API سلامت گوگل
نوع داده
dataType
پارامتر filter
موجود است
عملیات
محدوده
تغییرپذیری روزانه ضربان قلب
daily-heart-rate-variability
daily_heart_rate_variability
نوع ثبت: روزانه

دستگاه‌های سازگار

فهرست کردن، تطبیق دادن .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
اشباع اکسیژن روزانه
daily-oxygen-saturation
daily_oxygen_saturation
نوع ثبت: روزانه

دستگاه‌های سازگار

فهرست کردن، تطبیق دادن .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
میزان تنفس روزانه
daily-respiratory-rate
daily_respiratory_rate
نوع ثبت: روزانه

دستگاه‌های سازگار

فهرست کردن، تطبیق دادن .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
مشتقات دمای خواب روزانه
daily-sleep-temperature-derivations
daily_sleep_temperature_derivations
نوع ثبت: روزانه

دستگاه‌های سازگار

فهرست کردن، تطبیق دادن .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
تغییرپذیری ضربان قلب
heart-rate-variability
heart_rate_variability
نوع رکورد: نمونه

دستگاه‌های سازگار

فهرست کردن، تطبیق دادن .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
اشباع اکسیژن
oxygen-saturation
oxygen_saturation
نوع رکورد: نمونه

دستگاه‌های سازگار

فهرست کردن، تطبیق دادن .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
خلاصه خواب با نرخ تنفس
respiratory-rate-sleep-summary
respiratory_rate_sleep_summary
نوع رکورد: نمونه

دستگاه‌های سازگار

فهرست کردن، تطبیق دادن .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
خواب
sleep
sleep
نوع رکورد: جلسه

دستگاه‌های سازگار

لیست کردن، دریافت کردن، تطبیق دادن، ایجاد کردن، به‌روزرسانی کردن، حذف دسته‌ای .sleep.readonly
.sleep.writeonly

جلسات خواب و بیداری‌های کوتاه

A Sleep Session ( Sleep ) represents a discrete sleep event, such as a single nightly sleep or a daytime nap. It includes a detailed breakdown of non-overlapping sleep stages alongside brief wake transition intervals known as short awakenings.

  • جلسه خواب ( Sleep ) : یک رویداد خواب گسسته (فواصل مراحل LIGHT ، DEEP ، REM ، AWAKE ) را نشان می‌دهد که جدول زمانی پیوسته استراحت اولیه را تقسیم می‌کند.
  • Short Awakenings ( shortAwakenings ) : Brief wake transitions or awakenings that occur during rest. Unlike standard AWAKE stage intervals (which divide the non-overlapping contiguous sleep stage progression), short awakenings are distinct segments that can overlap with surrounding sleep stages. They provide granular visibility into restlessness and micro-awakenings without disrupting the primary sleep stage structure.

مثال

{
  "name": "sleeps/12345",
  "startTime": "2026-04-20T22:30:00Z",
  "endTime": "2026-04-21T06:30:00Z",
  "sleepType": "STAGES",
  "sleepStages": [
    {
      "startTime": "2026-04-20T22:30:00Z",
      "endTime": "2026-04-20T23:45:00Z",
      "type": "LIGHT"
    },
    {
      "startTime": "2026-04-20T23:45:00Z",
      "endTime": "2026-04-21T01:15:00Z",
      "type": "DEEP"
    }
  ],
  "shortAwakenings": [
    {
      "startTime": "2026-04-20T23:10:00Z",
      "endTime": "2026-04-20T23:11:30Z",
      "type": "AWAKE"
    }
  ]
}

مشتقات دمای خواب روزانه

Daily Sleep Temperature Derivations measure the variation in a user's skin temperature during sleep compared to their baseline. This data is typically reported once per day after a major sleep session.

میزان تنفس

Respiratory rate measures the user's breaths per minute. During sleep, it is a key metric for monitoring sleep quality and potential disturbances. The API supports sample respiratory rate ( respiratory-rate ), daily summaries ( daily-respiratory-rate ), and session-level sleep summaries ( respiratory-rate-sleep-summary ).

تغییرپذیری ضربان قلب (HRV)

HRV measures the variation in time between each heartbeat. It is a key indicator of the autonomic nervous system's state; high HRV during sleep generally signifies better recovery and readiness, while low HRV can indicate stress or overtraining. The API supports sample HRV ( heart-rate-variability ) and daily summaries ( daily-heart-rate-variability ).

اشباع اکسیژن (SpO2)

SpO2 represents the percentage of oxygen-saturated hemoglobin relative to total hemoglobin in the blood. Monitoring SpO2 during sleep is critical for detecting potential breathing disturbances and ensuring the user is maintaining adequate oxygen levels throughout the night. The API supports sample SpO2 ( oxygen-saturation ) and daily summaries ( daily-oxygen-saturation ).

دیدگاه جامع در مورد سلامت خواب و بهبودی

While each metric provides specific insights, they are deeply interrelated and together offer a holistic view of a user's recovery. Sleep stages (Light, Deep, REM) provide the structural foundation of rest, while physiological markers like HRV and SpO2 indicate how the body is physically responding to that rest. For example, a high-quality sleep session with optimal Deep sleep often correlates with higher HRV, signifying effective recovery of the autonomic nervous system.

Combining these with respiratory rate and sleep temperature derivations allows applications to identify potential disturbances. A sudden spike in respiratory rate or a deviation in sleep temperature can contextualize why a user might have spent less time in restorative stages. By analyzing these data types in tandem, developers can provide a comprehensive assessment of sleep hygiene and long-term health trends.

دستورالعمل‌ها

هنگام ادغام معیارهای خواب در برنامه خود، از این دستورالعمل‌ها استفاده کنید:

  • جزئیات جلسه : برای نمایش مراحل خواب کاربر (سبک، عمیق، REM، بیدار) و بیداری‌های کوتاه، نوع داده sleep را جستجو کنید.
  • Physiological Monitoring : For advanced health monitoring, combine the sleep session data with physiological and recovery metrics such as respiratory-rate-sleep-summary , daily-sleep-temperature-derivations , daily-heart-rate-variability , and daily-oxygen-saturation .
  • Reconciliation : Use the reconcile operation to ensure that overlapping sleep logs from different devices (for example, a wearable and a mattress sensor) are merged into a single "main" sleep record.

محاسبه کل زمان خواب عمیق

برای محاسبه کل زمانی که کاربر در یک شب خاص در مرحله خواب عمیق ترمیمی گذرانده است:

  1. نوع داده sleep را برای محدوده زمانی مشخص شده پرس و جو کنید.
  2. در لیست مراحل (stages) جستجو کنید و فواصلی را که در آنها stageType DEEP است، شناسایی کنید.
  3. مدت زمان (زمان پایان - زمان شروع) را برای هر بازه خواب عمیق محاسبه کرده و آنها را با هم جمع کنید.

حاصل جمع، کل مدت زمان فیزیکی خواب عمیق را برای آن جلسه فراهم می‌کند.