พัฒนาประสบการณ์ด้านค่าสัญญาณชีพและตัวชี้วัดสุขภาพด้วย Google Health API

Google Health API จะติดตามค่าสัญญาณชีพและเมตริกสุขภาพทางสรีรวิทยาของผู้ใช้ เช่น อัตราการเต้นของหัวใจ ความอิ่มตัวของออกซิเจน น้ำตาลกลูโคสในเลือด อุณหภูมิแกนกลางของร่างกาย และ การหาค่าอุณหภูมิขณะนอนหลับในแต่ละวัน

ทำความเข้าใจวิธีอ่านและขอการให้สิทธิ์จากผู้ใช้สำหรับข้อมูล Vitals ในแอปพลิเคชันของคุณ เพื่อมอบประสบการณ์การใช้งานที่ดีที่สุดแก่ผู้ใช้

ประเภทข้อมูลที่รองรับ

API รองรับประเภทข้อมูลต่อไปนี้สำหรับการติดตามค่าสัญญาณชีพและเมตริกด้านสุขภาพ

ตาราง: ประเภทข้อมูลค่าสัญญาณชีพของ Google Health API
ประเภทข้อมูล
  dataType พารามิเตอร์
  filter
การดำเนินการ
ที่ใช้ได้
ขอบเขต
น้ำตาลกลูโคสในเลือด
blood-glucose
blood_glucose
ประเภทระเบียน: ตัวอย่าง
list, get, reconcile, rollup, dailyRollup .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
อุณหภูมิแกนกลางของร่างกาย
core-body-temperature
core_body_temperature
ประเภทระเบียน: ตัวอย่าง
list, get, reconcile, rollup, dailyRollup .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
ความผันแปรของอัตราการเต้นของหัวใจรายวัน
daily-heart-rate-variability
daily_heart_rate_variability
ประเภทบันทึก: รายวัน

อุปกรณ์ที่เข้ากันได้

รายการ, ปรับยอด .health_metrics_and_measurements.readonly
.health_metrics_and_measurements.writeonly
โซนอัตราการเต้นของหัวใจรายวัน
daily-heart-rate-zones
daily_heart_rate_zones
ประเภทบันทึก: รายวัน
รายการ, ปรับยอด .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-resting-heart-rate
daily_resting_heart_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
คลื่นไฟฟ้าหัวใจ (ECG)
electrocardiogram
electrocardiogram
ประเภทระเบียน: เซสชัน

อุปกรณ์ที่เข้ากันได้

list .ecg.readonly
อัตราการเต้นของหัวใจ
heart-rate
heart_rate
ประเภทระเบียน: ตัวอย่าง

อุปกรณ์ที่เข้ากันได้

list, reconcile, rollup, dailyRollup .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
การแจ้งเตือนเมื่อจังหวะการเต้นของหัวใจผิดปกติ
irregular-rhythm-notification
irregular_rhythm_notification
ประเภทระเบียน: เซสชัน
list .irn.readonly
ความอิ่มตัวของออกซิเจน
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

ข้อกำหนดแบบอ่านอย่างเดียว

ระบบจะป้อนข้อมูลประเภทค่าสัญญาณชีพทางสรีรวิทยาโดยการซิงค์อุปกรณ์หรือรายการบันทึกด้วยตนเองในแอป Fitbit บนอุปกรณ์เคลื่อนที่หรือเว็บแอป และจะอ่านได้อย่างเดียวผ่าน REST API (เขียนหรือแก้ไขโดยตรงผ่านปลายทาง Google Health API ไม่ได้)

ส่วนต่อไปนี้จะให้รายละเอียดทางเทคนิคและรูปแบบการแสดง REST สำหรับข้อมูลค่าสัญญาณชีพ

อัตราการเต้นของหัวใจและสุขภาพหัวใจ

API จะให้การวัดผลระหว่างวันแบบละเอียดและการสรุปรายวันสำหรับ เมตริกอัตราการเต้นของหัวใจ

  • อัตราการเต้นของหัวใจ (heart-rate): การวัดอัตราการเต้นของหัวใจ ณ จุดใดจุดหนึ่ง ซึ่งมีจำนวน beatsPerMinute พร้อมกับ motionContext ของผู้ใช้ (เช่น SEDENTARY หรือ ACTIVE) และ sensorLocation (เช่น WRIST หรือ CHEST)
  • อัตราการเต้นของหัวใจขณะพักรายวัน (daily-resting-heart-rate): ค่าอัตราการเต้นของหัวใจขณะพักพื้นฐานรายวัน
  • ความผันแปรของอัตราการเต้นของหัวใจ (heart-rate-variability และ daily-heart-rate-variability): บันทึกค่ารากที่สองของค่าเฉลี่ยกำลังสองของความแตกต่างที่ต่อเนื่องกัน (rmssd) เป็นมิลลิวินาทีเพื่อแสดง HRV

ตัวอย่างการแสดง REST

หากต้องการค้นหาการวัดอัตราการเต้นของหัวใจ ให้ส่งคำขอ GET ไปยังปลายทาง list

ตัวอย่างต่อไปนี้แสดงจุดข้อมูล heart-rate รายการเดียวจากรายการที่ส่งคืน

ส่งคำขอ

GET https://health.googleapis.com/v4/users/me/dataTypes/heart-rate/dataPoints?startTime=2026-04-20T08:00:00Z&endTime=2026-04-20T08:05:00Z
Authorization: Bearer access-token
Accept: application/json

คำตอบ

{
  "dataPoints": [
    {
      "name": "users/me/dataTypes/heart-rate/dataPoints/hr-123456789",
      "dataSource": {
        "recordingMethod": "ACTIVELY_MEASURED"
      },
      "heartRate": {
        "sampleTime": {
          "physicalTime": "2026-04-20T08:00:00Z",
          "utcOffset": "0s"
        },
        "beatsPerMinute": "72",
        "metadata": {
          "motionContext": "SEDENTARY",
          "sensorLocation": "WRIST"
        }
      }
    }
  ]
}

น้ำตาลกลูโคสในเลือด

blood-glucoseประเภทข้อมูลแสดงระดับน้ำตาลในเลือดของผู้ใช้ จุดน้ำตาลในเลือดจะเก็บความเข้มข้นเป็นมิลลิกรัมต่อเดซิลิตร (mg/dL) บริบทของมื้ออาหารหรือเวลา และข้อมูลตัวอย่าง

ตัวอย่างการแสดง REST

หากต้องการค้นหาการวัดระดับน้ำตาลกลูโคสในเลือด ให้ส่งคำขอ GET ไปยังปลายทาง list ตัวอย่างต่อไปนี้แสดงจุดข้อมูล blood-glucose รายการเดียวจาก รายการที่แสดง

ส่งคำขอ

GET https://health.googleapis.com/v4/users/me/dataTypes/blood-glucose/dataPoints?startTime=2026-04-20T08:00:00Z&endTime=2026-04-20T09:00:00Z
Authorization: Bearer access-token
Accept: application/json

คำตอบ

{
  "dataPoints": [
    {
      "name": "users/me/dataTypes/blood-glucose/dataPoints/bg-987654321",
      "dataSource": {
        "recordingMethod": "MANUALLY_ENTERED"
      },
      "bloodGlucose": {
        "sampleTime": {
          "physicalTime": "2026-04-20T08:30:00Z",
          "utcOffset": "-25200s"
        },
        "bloodGlucoseMilligramsPerDeciliter": 95.0,
        "measurementSource": "SELF_MONITORING_BLOOD_GLUCOSE",
        "mealType": "BREAKFAST",
        "measurementTiming": "AFTER_MEAL",
        "specimen": "CAPILLARY_BLOOD",
        "notes": "Post-breakfast fingerstick reading"
      }
    }
  ]
}

ความอิ่มตัวของออกซิเจน (SpO2)

API จะติดตามระดับออกซิเจนโดยใช้ oxygen-saturation (ค่าตัวอย่างระหว่างวัน) และ daily-oxygen-saturation (สถิติสรุปรายวัน) ความเข้มข้นเป็นเปอร์เซ็นต์จะแสดงเป็นตัวเลขตั้งแต่ 0 ถึง 100

ตัวอย่างการแสดง REST

หากต้องการค้นหาการวัดค่าความอิ่มตัวของออกซิเจน ให้ส่งคำขอ GET ไปยังlist ปลายทาง ตัวอย่างต่อไปนี้แสดงจุดข้อมูล oxygen-saturation รายการเดียว จากรายการที่ส่งคืน

ส่งคำขอ

GET https://health.googleapis.com/v4/users/me/dataTypes/oxygen-saturation/dataPoints?startTime=2026-04-20T03:00:00Z&endTime=2026-04-20T03:05:00Z
Authorization: Bearer access-token
Accept: application/json

คำตอบ

{
  "dataPoints": [
    {
      "name": "users/me/dataTypes/oxygen-saturation/dataPoints/spo2-555555",
      "dataSource": {
        "recordingMethod": "ACTIVELY_MEASURED"
      },
      "oxygenSaturation": {
        "sampleTime": {
          "physicalTime": "2026-04-20T03:00:00Z",
          "utcOffset": "0s"
        },
        "percentage": 98.2
      }
    }
  ]
}

อุณหภูมิ

การติดตามอุณหภูมิประกอบด้วยเมตริกอุณหภูมิแกนกลางของร่างกายและแนวโน้มอุณหภูมิผิวหนังขณะนอนหลับ ข้ามคืน ดังนี้

  • อุณหภูมิแกนกลางของร่างกาย (core-body-temperature): บันทึกอุณหภูมิของอวัยวะภายในเป็นองศาเซลเซียส พร้อมระบุตำแหน่งที่วัด (เช่น ARMPIT, EAR หรือ FOREHEAD)
  • การหาค่าอุณหภูมิขณะนอนหลับ (daily-sleep-temperature-derivations) ความแปรปรวนของอุณหภูมิผิวหนังที่มีความถี่สูงซึ่งบันทึกไว้ตลอดทั้งคืน

ตัวอย่างการแสดง REST

หากต้องการค้นหาการวัดอุณหภูมิแกนกลางของร่างกาย ให้ส่งคำขอ GET ไปยังปลายทาง list ตัวอย่างต่อไปนี้แสดงจุดข้อมูล core-body-temperature รายการเดียว จากรายการที่แสดง

ส่งคำขอ

GET https://health.googleapis.com/v4/users/me/dataTypes/core-body-temperature/dataPoints?startTime=2026-04-20T22:00:00Z&endTime=2026-04-20T23:00:00Z
Authorization: Bearer access-token
Accept: application/json

คำตอบ

{
  "dataPoints": [
    {
      "name": "users/me/dataTypes/core-body-temperature/dataPoints/cbt-666666",
      "dataSource": {
        "recordingMethod": "ACTIVELY_MEASURED"
      },
      "coreBodyTemperature": {
        "sampleTime": {
          "physicalTime": "2026-04-20T22:30:00Z",
          "utcOffset": "-18000s"
        },
        "temperatureCelsius": 36.8,
        "measurementLocation": "FOREHEAD"
      }
    }
  ]
}

คลื่นไฟฟ้าหัวใจ (ECG) และการแจ้งเตือน

สำหรับอุปกรณ์ที่มีเซ็นเซอร์ระดับการแพทย์ API จะแสดงประเภทข้อมูลสุขภาพหัวใจขั้นสูง ดังนี้

  • คลื่นไฟฟ้าหัวใจ (electrocardiogram): ผลลัพธ์เซสชัน ECG แบบ 1 ลีด ซึ่งมีการจัดประเภท (SINUS_RHYTHM, ATRIAL_FIBRILLATION, INCONCLUSIVE) อัตราการเต้นของหัวใจโดยเฉลี่ย ความถี่ในการสุ่มตัวอย่าง และตัวอย่างแรงดันไฟฟ้าของรูปคลื่นดิบ
  • การแจ้งเตือนเมื่อจังหวะการเต้นของหัวใจผิดปกติ (irregular-rhythm-notification): เหตุการณ์การแจ้งเตือนตามบริบทที่บ่งบอกถึงสัญญาณของภาวะ AFib ที่อาจเกิดขึ้นซึ่งตรวจพบระหว่างการตรวจสอบแบบพาสซีฟ

ตัวอย่างการแสดง REST

หากต้องการค้นหาข้อมูลเซสชันคลื่นไฟฟ้าหัวใจ ให้ส่งGETคำขอไปยังlist ปลายทาง ตัวอย่างต่อไปนี้แสดงจุดข้อมูล electrocardiogram รายการเดียว จากรายการที่ส่งคืน

ส่งคำขอ

GET https://health.googleapis.com/v4/users/me/dataTypes/electrocardiogram/dataPoints?startTime=2026-04-20T10:00:00Z&endTime=2026-04-20T10:05:00Z
Authorization: Bearer access-token
Accept: application/json

คำตอบ

{
  "dataPoints": [
    {
      "name": "users/me/dataTypes/electrocardiogram/dataPoints/ecg-777777",
      "dataSource": {
        "recordingMethod": "ACTIVELY_MEASURED"
      },
      "electrocardiogram": {
        "interval": {
          "startTime": "2026-04-20T10:00:00Z",
          "startUtcOffset": "0s",
          "endTime": "2026-04-20T10:00:30Z",
          "endUtcOffset": "0s"
        },
        "resultClassification": "SINUS_RHYTHM",
        "beatsPerMinuteAvg": "70",
        "samplingFrequencyHertz": 250,
        "millivoltsScalingFactor": 1000,
        "leadNumber": 1,
        "waveformSamples": [
          -12, -8, 4, 18, 30, 42, 50, 48, 32, 10
        ]
      }
    }
  ]
}

ขอบเขตและการให้สิทธิ์

หากต้องการใช้ฟีเจอร์ข้อมูลสำคัญและสุขภาพหัวใจ แอปของคุณต้องขอขอบเขต OAuth ต่อไปนี้

  • อ่าน: https://www.googleapis.com/auth/googlehealth.ecg.readonly
  • อ่าน: https://www.googleapis.com/auth/googlehealth.health_metrics_and_measurements.readonly
  • เขียน: https://www.googleapis.com/auth/googlehealth.health_metrics_and_measurements.writeonly
  • อ่าน: https://www.googleapis.com/auth/googlehealth.irn.readonly

หลักเกณฑ์

ใช้หลักเกณฑ์ต่อไปนี้เมื่อออกแบบฟีเจอร์ที่มีค่าสัญญาณชีพและตัวชี้วัดสุขภาพ

  • จัดการการแปลงหน่วย: ค่าอุณหภูมิจะแสดงเป็นเซลเซียส แปลงเป็นฟาเรนไฮต์ในโค้ดส่วนหน้าตามค่ากำหนดที่แปลเป็นภาษาท้องถิ่นของผู้ใช้
  • จัดการการแจ้งเตือน Webhook: สมัครรับการแจ้งเตือน Webhook สำหรับค่าสัญญาณชีพเพื่อเรียกใช้การวิเคราะห์แบ็กเอนด์ทันทีหลังจากที่ผู้ใช้ซิงค์ค่าใหม่ (เช่น อัตราการเต้นของหัวใจหรือน้ำตาลกลูโคสในเลือด)
  • เคารพความละเอียดอ่อนของข้อมูล: ตรวจสอบว่าผลิตภัณฑ์ของคุณอธิบายบริบททางคลินิกหรือบริบทด้านสุขภาพที่ใช้ในการอ่านค่าสัญญาณชีพทางสรีรวิทยาที่มีความถี่สูงให้ผู้ใช้ทราบอย่างชัดเจน อธิบายว่าเหตุใดจึงต้องมีขอบเขต เช่น health_metrics_and_measurements หรือ ecg ก่อนเรียกใช้ ข้อความแจ้งการให้สิทธิ์