Parse and analyse Samsung Health export data as pandas DataFrames
Project description
samsung-health-sdk
A Python SDK for parsing and analysing Samsung Health export data.
Load any health metric from a Samsung Health export directory as a pandas DataFrame with a single function call. Compare data across multiple people or time windows. Derive higher-level health features from the raw data.
Installation
pip install samsung-health-sdk
Quick Start
from samsung_health_sdk import SamsungHealthParser, SamsungHealthComparator
# Point at your Samsung Health export directory
p = SamsungHealthParser("path/to/samsunghealth_export_dir")
# See all available metrics
print(p.list_metrics())
# Load heart rate (hourly summaries or minute-level)
hr = p.get_heart_rate("2024-10-01", "2024-10-31")
hr_min = p.get_heart_rate("2024-10-01", "2024-10-31", granularity="minute")
# All supported metrics
sleep = p.get_sleep("2024-10-01", "2024-10-31")
skin = p.get_skin_temperature("2024-10-01", "2024-10-31", granularity="minute")
stress = p.get_stress("2024-10-01", "2024-10-31")
spo2 = p.get_spo2("2024-10-01", "2024-10-31")
steps = p.get_steps("2024-10-01", "2024-10-31")
hrv = p.get_hrv("2024-10-01", "2024-10-31")
rr = p.get_respiratory_rate("2024-10-01", "2024-10-31", granularity="minute")
ex = p.get_exercise("2024-10-01", "2024-10-31")
mv = p.get_movement("2024-10-01", "2024-10-31") # per-minute activity_level
# Generic accessor for any metric by its full name
df = p.get_metric("com.samsung.shealth.vitality_score", start="2024-10-01")
Feature Engineering
HealthFeatureEngine derives meaningful higher-level features from the raw data:
from samsung_health_sdk.features import HealthFeatureEngine
eng = HealthFeatureEngine(p, tz_offset_hours=5.5) # tz_offset_hours: your UTC offset
# Per-night sleep quality: efficiency, deep/REM %, fragmentation, composite score
sleep_stats = eng.sleep_sessions("2025-01-01", "2025-03-31")
# Per-night HRV + respiratory rate + movement restlessness during sleep
physio = eng.nightly_physiology("2025-01-01", "2025-03-31")
# Columns: rmssd_mean, rmssd_min, rmssd_std, rr_mean, rr_std,
# restlessness_score, restless_min, hrv_suppression_flag
# HRV readiness: today vs your rolling N-day personal baseline
readiness = eng.hrv_readiness("2025-01-01", "2025-03-31", baseline_days=14)
# Columns: rmssd_mean, baseline_14d, deviation_pct, readiness_score, low_readiness_flag
# Previous-day stress deviation vs that night's sleep quality
impact = eng.stress_impact_on_sleep("2025-01-01", "2025-03-31")
# Uses stress deviation from rolling baseline, not absolute score
# Per-day activity breakdown + HR context + stress
profile = eng.daily_activity_profile("2025-01-01", "2025-03-31")
# Columns: sedentary_min, light_min, low_mod_min, moderate_min, vigorous_min,
# active_min, mean_hr_active, median_hr_day, mean_stress, stress_deviation_pct
# Walking cardiac load trend (HR / speed — lower = more aerobically efficient)
cardiac = eng.walking_cardiac_load("2024-11-01", "2025-06-30", source="auto")
# source='auto': pedometer (most accurate) > movement (accelerometer-based,
# extends to Nov 2024) > exercise summaries (Jun 2022+)
# Columns: date, duration_min, distance_m, speed_mps, mean_hr, cardiac_load,
# source, rolling_4w_cardiac_load, cardiac_load_trend
Multi-Person Comparison
p1 = SamsungHealthParser("path/to/person1_export")
p2 = SamsungHealthParser("path/to/person2_export")
comp = SamsungHealthComparator({"Alice": p1, "Bob": p2})
# Compare heart rate — absolute calendar window
df = comp.compare_heart_rate("2024-10-01", "2024-10-31")
# Align to relative Day 0 per person (time_shift=True)
df = comp.compare_heart_rate("2024-10-01", "2024-10-31", time_shift=True)
Export Format
Samsung Health exports a directory containing:
- CSV files per health metric (some with a metadata row, some without — auto-detected)
jsons/subdirectory with per-minute binning JSON filesfiles/subdirectory with binary attachments (ECG waveforms, photos)
The SDK handles BOM encoding, namespaced column headers, UTC offset timestamps, trailing commas, and lazy JSON loading automatically.
Sleep Stage Codes
| Code | Label |
|---|---|
| 40001 | Awake |
| 40002 | Light |
| 40003 | Deep |
| 40004 | REM |
Movement Activity Levels
Per-minute accelerometer intensity from get_movement():
| Range | Intensity |
|---|---|
| 0–5 | Sedentary |
| 5–20 | Light |
| 20–50 | Low-moderate |
| 50–100 | Moderate |
| 100+ | Vigorous |
Requirements
- Python 3.9+
- pandas >= 2.0
- numpy >= 1.24
Contributing
git clone https://github.com/Devasy/samsung-health-sdk
cd samsung-health-sdk
pip install -e ".[dev]"
pre-commit install
pytest
Run linting/format hooks on demand:
pre-commit run --all-files
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file samsung_health_sdk-0.2.5.tar.gz.
File metadata
- Download URL: samsung_health_sdk-0.2.5.tar.gz
- Upload date:
- Size: 67.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23316da63a8eb533b4ea2a3b34654d61f725a5a8477568d8e75cf443677ac04e
|
|
| MD5 |
130fb9a0bdb8fc75b450ed4f5f3025e5
|
|
| BLAKE2b-256 |
398a5bd58562e9982286a5df636fc2563c6e7478cf54c59a7bf9efb585f927fc
|
Provenance
The following attestation bundles were made for samsung_health_sdk-0.2.5.tar.gz:
Publisher:
release.yml on Devasy/samsung-health-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
samsung_health_sdk-0.2.5.tar.gz -
Subject digest:
23316da63a8eb533b4ea2a3b34654d61f725a5a8477568d8e75cf443677ac04e - Sigstore transparency entry: 1239164837
- Sigstore integration time:
-
Permalink:
Devasy/samsung-health-sdk@2aab142afa8cfa61cff1f2890008d921e3b9454f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Devasy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2aab142afa8cfa61cff1f2890008d921e3b9454f -
Trigger Event:
push
-
Statement type:
File details
Details for the file samsung_health_sdk-0.2.5-py3-none-any.whl.
File metadata
- Download URL: samsung_health_sdk-0.2.5-py3-none-any.whl
- Upload date:
- Size: 78.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b66d18162a23fd838f1007077f5a0ce2680a9473dc13f6d4aa37b977eb631016
|
|
| MD5 |
3bc9daa55e811888047c5ae1bf07b244
|
|
| BLAKE2b-256 |
f2008d16009767e57a999b6a86e94b91d7faebe563aa723588b367dbf7caaa82
|
Provenance
The following attestation bundles were made for samsung_health_sdk-0.2.5-py3-none-any.whl:
Publisher:
release.yml on Devasy/samsung-health-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
samsung_health_sdk-0.2.5-py3-none-any.whl -
Subject digest:
b66d18162a23fd838f1007077f5a0ce2680a9473dc13f6d4aa37b977eb631016 - Sigstore transparency entry: 1239164844
- Sigstore integration time:
-
Permalink:
Devasy/samsung-health-sdk@2aab142afa8cfa61cff1f2890008d921e3b9454f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Devasy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2aab142afa8cfa61cff1f2890008d921e3b9454f -
Trigger Event:
push
-
Statement type: