cyberjunky / python-garminconnect

Python 3 API wrapper for Garmin Connect to get activity statistics
MIT License
802 stars 132 forks source link

Daily calories #189

Closed jflournoy closed 4 days ago

jflournoy commented 5 months ago

Hi there,

I may have missed it but is there any way to pull daily calories? Thank you!

psdupvi commented 4 months ago

Use the get_stats(cdate) or get_stats_and_body(cdate) endpoint, which returns (among many other things) a lot of calorie information. In the Demo, this is option 7:

cdate is a string

api = init_api(email=os.environ['GARMIN_USERNAME'], password=os.environ['GARMIN_PASSWORD'])

stats_data = api.get_stats('2024-03-10')

# Returns object including the following fields:
{
'userProfileId': 123456789, # Your User ID
...
'totalKilocalories': 4067.0,
 'activeKilocalories': 1874.0,
 'bmrKilocalories': 2193.0,
 'wellnessKilocalories': 4067.0,
 'burnedKilocalories': None, # Always None for me
 'consumedKilocalories': 3937.0, # For me, this comes from MyFitnessPal. Not sure if Garmin has built in calorie consumption tracking
 'remainingKilocalories': 130.0,
'netCalorieGoal': 1770,
...
}

Under the hood, get_stats_and_body calls get_stats which calls get_user_summary

cyberjunky commented 3 months ago

@jflournoy did you manage to get the data you wanted, is there mode needed?

jflournoy commented 3 months ago

I haven't had a chance to test this out yet but will report back when I do. thank you! I think i just missed this in the example.

AnonJohn commented 1 month ago

I can confirm that this works.

cyberjunky commented 4 days ago

Closing since tested and solved, thanks all!