cyberjunky / python-garminconnect

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

Get stats and body information for a range of dates #219

Closed bobgott closed 3 months ago

bobgott commented 3 months ago

Is it possible to get stats_and_body data via a range of dates using start date and limit?

I tried some experiments using connectapi(URL, params) but no luck. Not sure about the URL creation. Getting 400/Bad Request responses.

Of course I could always query one date at a time so this isn't urgent.

psdupvi commented 3 months ago

I know get_body_composition supports a date range. However, currently get_stats doesn't.

I mention these, because get_stats_and_body just unpacks these two calls into a single dictionary.

        return {
            **self.get_stats(cdate),
            **self.get_body_composition(cdate)["totalAverage"],
        }

If we can figure out the get_stats range version, then we could do a range for the combined function somewhat easily.

The general URL is /usersummary-service/usersummary/daily/{display_name} where display_name is a long UID of some sort, unique per user.

Similar URLs are (e.g., for hydration) /usersummary-service/stats/hydration/daily/2024-07-26/2024-08-22.

So we should be looking at something like that URL.

I'm not sure when I'll get a chance to look at this, and I'm also not positive that Garmin supports it -- because it's just a summary of like 10 other endpoints, like body battery, stress, heart rate. So you could call each of those at a range as well (if they support it). And that might be a better use of time -- to make sure all of those support date ranges.

bobgott commented 3 months ago

@psdupvi, Well, don't fuss about this, as there are other ways I can get my data. I thought perhaps I was missing something. But thank you for your clear explanation.

(also, keep up the great work!)