Skip to content

Instantly share code, notes, and snippets.

@janikvonrotz
Created April 16, 2020 18:04
Show Gist options
  • Save janikvonrotz/c6faa987efef97535ed627130fdccaeb to your computer and use it in GitHub Desktop.
Save janikvonrotz/c6faa987efef97535ed627130fdccaeb to your computer and use it in GitHub Desktop.
Garmin Connect Weight

Cookie

Get Weight

https://connect.garmin.com/modern/proxy/userprofile-service/userprofile/personal-information/weightWithOutbound/filterByDay?from=1477526400000&until=1509148800000&_=1511026934431

fetch('https://connect.garmin.com/modern/proxy/userprofile-service/userprofile/personal-information/weightWithOutbound/filterByDay?from=1477526400000&until=1509148800000&_=1511026934431').then((result) => {console.log(result)})

Post Weight

https://connect.garmin.com/modern/proxy/weight-service/user-weight

{"value":74,"unitKey":"kg","date":"2017-11-18"}

fetch("https://connect.garmin.com/modern/proxy/weight-service/user-weight", {
  method: "post",
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'credentials': 'same-origin'    
  },

  //make sure to serialize your JSON body
  body: JSON.stringify({
    value: "88",
    unitKey: "kg",
    date: "2017-11-18"
  })
})
.then( (response) => { 
   console.log(response)
});

Delete Weight

ttps://connect.garmin.com/modern/proxy/biometric-service/biometric/2017-11-18

@vanlooverenkoen
Copy link

Is there a way to add your bodyfat percentage & other measurements you get from a smart scale?

@LsVzqz
Copy link

LsVzqz commented Jun 22, 2022

Is there a way to add your bodyfat percentage & other measurements you get from a smart scale?

I'm actually curious to know this too. I have data that I get from a withings scale and would like to enter it into my Garmin account.

@pedrorijo91
Copy link

pedrorijo91 commented Mar 1, 2023

there should be a way. this paid service is able to do that... https://smartscalesync.com/
I've been using it for a withings scale cc @LsVzqz

@lchagnoleau
Copy link

No way to do it with an opensource project ?

@floriangeigl
Copy link

floriangeigl commented Aug 3, 2023

I haven't found a way doing that over the API directly, but I was able to create a fit file containing a weight_scale_message (https://bitbucket.org/stagescycling/python_fit_tool/src/main/fit_tool/profile/messages/weight_scale_message.py) - afterward uploading it using the garmin lib: https://github.com/cyberjunky/python-garminconnect. works for me :)

from fit_tool.fit_file_builder import FitFileBuilder
from fit_tool.profile.messages.file_id_message import FileIdMessage
from fit_tool.profile.messages.weight_scale_message import WeightScaleMessage
from fit_tool.profile.profile_type import Manufacturer, FileType

def create_body_composition_fit_file(timestamp, weight=None, percent_fat=None, percent_hydration=None, visceral_fat_mass=None, bone_mass=None, muscle_mass=None):
    file_id_message = FileIdMessage()
    file_id_message.type = FileType.WEIGHT
    file_id_message.manufacturer = Manufacturer.DEVELOPMENT.value
    file_id_message.product = 0
    file_id_message.time_created = round(timestamp.timestamp() * 1000)
    file_id_message.serial_number = 0x12345678

    weightmsg = WeightScaleMessage()
    weightmsg.weight = weight
    weightmsg.timestamp = round(timestamp.timestamp() * 1000)
    weightmsg.percent_fat = percent_fat
    weightmsg.percent_hydration = percent_hydration
    weightmsg.visceral_fat_mass = visceral_fat_mass
    weightmsg.bone_mass = bone_mass
    weightmsg.muscle_mass = muscle_mass
    weightmsg = [weightmsg]

    builder = FitFileBuilder(auto_define=True, min_string_size=50)
    builder.add(file_id_message)
    builder.add_all(weightmsg)

    fit_file = builder.build()

    fn = '/tmp/tmp.fit'
    if os.path.isfile(fn):
        os.remove(fn)
    fit_file.to_file(fn)
    return fn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment