coddingtonbear / python-myfitnesspal

Access your meal tracking data stored in MyFitnessPal programatically
MIT License
794 stars 136 forks source link

Add methods for accessing report data #118

Closed samlader closed 1 year ago

samlader commented 3 years ago

This PR includes the addition of functionality to access report data.

thisweek = datetime.date(2015, 5, 11)
lastweek = datetime.date(2015, 5, 4)
net_calories = client.get_report("Net Calories", "Nutrition", thisweek, lastweek)
net_calories
# >> OrderedDict([(datetime.date(2015, 5, 11), 1721.6), (datetime.date(2015, 5, 10), 1722.4), (datetime.date(2015, 5,9), 1720.2),
#                 (datetime.date(2015, 5, 8), 1271.0),  (datetime.date(2015, 5, 7), 1721.2),  (datetime.date(2015, 5, 6), 1720.8),
#                 (datetime.date(2015, 5, 5), 1721.8),  (datetime.date(2015, 5, 4), 1274.2)])

Report data is returned as ordered dictionaries. The first argument specifies the report name, the second argument specifies the category name - both of which can be anything listed in the MyFitnessPal Reports page.

coddingtonbear commented 2 years ago

It's going to be a while before I can find the time to review this; I wonder if anybody else using this library who has some understanding of the library could give the code a glance and try it out?