Skip to content

Instantly share code, notes, and snippets.

@tsmith512
Last active November 19, 2021 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsmith512/ab9f4afe1cacb35e3a44e7bd249ac7d5 to your computer and use it in GitHub Desktop.
Save tsmith512/ab9f4afe1cacb35e3a44e7bd249ac7d5 to your computer and use it in GitHub Desktop.
FitBit Migration Script Notes

The main fitbit monthly CSV export

1. Body Data

Body
Date,Weight,BMI,Fat
"2021-10-29","140.13","20.68","0"
"2021-10-30","140.15","20.69","0"
"2021-10-31","140.17","20.69","0"

I wasn't at home on these days, so I didn't weigh in. These seem to be points on the line between the previous and next weigh-in.

No idea how FitBit calculates BMI or fat percentage.

All from one file:

  • Archive/NAME/Personal & Account/weight-DATE.json
    • One file per 30 calendar days.
    • Array of objects, one object per weigh-in. I can assume 0 or 1 per day.
      • weight in pounds
      • date in MM/DD/YY
      • bmi as number

2. Foods

Skip this?

Yes, skip this.

Foods
Date,Calories In
"2021-10-29","0"
"2021-10-30","0"
"2021-10-31","0"

3. Activities

Of these, Garmin Connect seems to accept:

  • Steps
  • Floors
  • Calories as "Active" and "Resting" but I don't know how that maps to Burned vs Activity

Doesn't seem like Distance (outside activities) or minutes turn into anything.

Activities
Date,Calories Burned,Steps,Distance,Floors,Minutes Sedentary,Minutes Lightly Active,Minutes Fairly Active,Minutes Very Active,Activity Calories
"2021-10-29","2,948","13,845","7.92","61","616","246","28","57","1,619"
"2021-10-30","3,132","15,389","8.51","70","678","289","35","53","1,820"
"2021-10-31","3,113","16,322","9.76","69","668","299","10","59","1,820"
  • Archive/NAME/Physical Activity/calories-DATE.json
    • One file per 30 calendar days.
    • Array of objects, one object per minute.
      • dateTime in MM/DD/YY HH:MM:SS (rounded to the minute, 24-hr format)
      • value = count of burned or activity calories?
  • Archive/NAME/Physical Activity/steps-DATE.json
    • One file per 30 calendar days.
    • Array of objects, one object per minute.
      • dateTime in MM/DD/YY HH:MM:SS (rounded to the minute, 24-hr format)
      • value = count of steps
    • Pattern follows for these file prefixes:
      • distance --> Distance. Don't know value for unit though.
      • altitude --> Floors. Unit??
  • Archive/NAME/Physical Activity/sedentary_minutes-DATE.json
    • One file per 30 calendar days.
    • Array of objects, one object per day.
      • dateTime in MM/DD/YY HH:MM:SS (starting at midnight, 24-hr format)
      • value = minutes as Minutes Sedentary
    • Pattern follows for these file prefixes:
      • lightly_active_minutes --> Minutes Lightly Active
      • moderately_active_minutes --> Minutes Fairly Active
      • very_active_minutes --> Minutes Very Active

So this is the one with all the aggregations.

4. Sleep

Garmin Connect did not import this from the sample. Skip it.

Sleep
Start Time,End Time,Minutes Asleep,Minutes Awake,Number of Awakenings,Time in Bed,Minutes REM Sleep,Minutes Light Sleep,Minutes Deep Sleep
"2021-10-31 3:11AM","2021-10-31 9:55AM","350","54","27","404","107","175","68"
"2021-10-30 5:08AM","2021-10-30 11:33AM","332","53","20","385","44","250","38"
"2021-10-29 12:28AM","2021-10-29 8:41AM","447","46","35","493","93","315","39"

These are backwards in the FitBit CSV...

Data not worth keeping before 2020-04.

  • Archive/NAME/Sleep/sleep-DATE.json
    • One file per 30 calendar days.
    • Array of objects, one object per sleep event. (Night of sleep or long nap)
      • startTime as YYYY-MM-DDTHH:MM:SS.000 in what looks lile local time.
      • endTime (same)
      • minutesAsleep
      • minutesAwake
      • levels.summary.wake.count --> Number of Awakenings
      • timeInBed
      • levels.summary.[light|deep|rem].minutes --> Minutes (Light, Deep, REM) Sleep

5. Food Log

Food Log 20211029
Daily Totals
"","Calories","0"
"","Fat","0 g"
"","Fiber","0 g"
"","Carbs","0 g"
"","Sodium","0 mg"
"","Protein","0 g"
"","Water","0 fl oz"

Food Log 20211030
Daily Totals
"","Calories","0"
"","Fat","0 g"
"","Fiber","0 g"
"","Carbs","0 g"
"","Sodium","0 mg"
"","Protein","0 g"
"","Water","0 fl oz"

Food Log 20211031
Daily Totals
"","Calories","0"
"","Fat","0 g"
"","Fiber","0 g"
"","Carbs","0 g"
"","Sodium","0 mg"
"","Protein","0 g"
"","Water","0 fl oz"

Skip this too.


TCX files for Running/Hiking

Data are not worth keeping before 2020-04

  • Archive/NAME/Physical Activity/exercise-ROW.json
    • One file per 100 "exercise log" entries.
    • Array of objects, one object per log event.
      • Where hasGps == TRUE
      • The tcxLink, even when authenticated, will not download a TCX file, it's a webapp with a download link in the menu.
      • logId to fetch via Web API
        • With an Oauth grant faked, fetch
        • https://api.fitbit.com/1/user/-/activities/LOG-ID.tcx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment