Skip to content

Repository files navigation

HealthSync

Sync Samsung Health export data into Google Fit — push step counts, distance, calories, weight, body fat, hydration, sleep, and heart points; read everything back with a single command.

Setup

  1. Copy your OAuth client secret JSON to credentials.json.

    • Use a Google Cloud project with the Fitness API enabled.
    • For an installed app, the redirect URI must include http://localhost.
  2. Install dependencies:

    ./setup.sh
  3. Add your Google account as a test user (if the OAuth consent screen is still in testing):

    • Go to APIs & Services > OAuth consent screen in the Google Cloud Console.
    • Under Test users, add your Google account and save.
  4. Export your Samsung Health data and place the CSV files in Samsung_Health/. Expected structure:

    Samsung_Health/
    └── com.samsung.shealth.<category>/
    ├── tracker.pedometer_day_summary.*.csv
    ├── activity.day_summary.*.csv
    ├── pedometer_step_count.*.csv
    ├── com.samsung.health.weight.*.csv
    ├── com.samsung.health.height.*.csv
    ├── calories_burned.details.*.csv
    ├── water_intake.*.csv
    ├── com.samsung.shealth.sleep.*.csv
    └── com.samsung.health.exercise.*.csv
    

Usage

Activate the virtual environment first:

source .venv/bin/activate

Push data to Google Fit

python push.py

Reads Samsung Health CSVs and uploads the following to Google Fit:

CategoryData typeSource CSV
ActivitySteps, distance, calories (daily totals)tracker.pedometer_day_summary, activity.day_summary
ActivitySteps, distance, calories (minute-level)pedometer_step_count
ActivityHeart Points (computed from speed)pedometer_step_count, com.samsung.health.exercise
BodyWeight, body fat percentagecom.samsung.health.weight
BodyHeightcom.samsung.health.height
NutritionHydration (water intake)water_intake
NutritionTotal daily calories (resting + active)calories_burned.details
SleepSleep segmentscom.samsung.shealth.sleep

Subsequent runs skip already-uploaded dates via uploaded_dates.json.

Read data back from Google Fit

python read.py # last 30 days
python read.py 2025-01-01 # from a start date to today
python read.py 2025-01-01 2025-12-31 # explicit date range

Outputs a daily table with steps, distance, calories, heart points, and sleep, plus latest body metrics (weight, height, body fat).

How it works

  • OAuth — First run opens your browser for Google sign-in. Credentials are persisted in token.pickle (push) and token_read.pickle (read) and refreshed silently on expiry.
  • CSV parsing — Handles Samsung Health's two-row header format (metadata row + column names) and both epoch-ms and datetime-string timestamps.
  • Deduplicationuploaded_dates.json tracks every date successfully pushed per metric, so re-runs only upload new data.
  • Data source — Uses writable raw:com.google.* data sources instead of Google's read-only derived sources.
  • Heart Points — Computed from walking/running speed during minute-level intervals: ≥4 km/h earns 1 point/min, ≥7 km/h earns 2 points/min per WHO guidelines.

Troubleshooting

ErrorFix
Error 403: access_deniedAdd your Google account as a test user on the OAuth consent screen
Cannot read data of type com.google.step_count.deltaThe data source may not exist yet — run push.py first to create it
The caller does not have permissionVerify the Fitness API is enabled and your account is a test user
Unable to fetch DataSourceThe data source wasn't auto-created — re-run; if it persists, check API enablement

About

Python scripts to convert Samsung Health data to Google Fit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages