cyberjunky / python-garminconnect

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

Add Hill Score Endpoint #146

Closed psdupvi closed 1 year ago

psdupvi commented 1 year ago

Garmin recently added Hill Score, description available here: https://www.garmin.com/en-US/garmin-technology/running-science/running-dynamics/hill-score/

I believe the endpoint should be something along the lines of proxy/metrics-service/metrics/hillscore (possibly specifying a calendar date or a range of dates), but that is currently not working. I'm raising this issue with the intent of adding it in myself, but if someone gets to it before I do, great.

The output I see in the console of their official endpoint for a single date (basically, that but without proxy) is something along the lines of:

{
    "userProfilePK": 123456789,
    "deviceId": 987654321,
    "calendarDate": "2023-09-08",
    "strengthScore": 46,
    "enduranceScore": 44,
    "hillScoreClassificationId": 3,
    "overallScore": 59,
    "hillScoreFeedbackPhraseId": 12,
    "vo2Max": 59.0,
    "vo2MaxPreciseValue": 59.1,
    "primaryTrainingDevice": true
}

https://connect.garmin.com/metrics-service/metrics/hillscore?calendarDate=2023-09-08

A range of dates looks like:

{
    "userProfilePK": 123456789,
    "startDate": "2023-08-12",
    "endDate": "2023-09-08",
    "periodAvgScore": {
        "2023-08-12": 57
    },
    "maxScore": 59,
    "hillScoreDTOList": [
        {
            "userProfilePK": 123456789,
            "deviceId": 9876543231,
            "calendarDate": "2023-09-08",
            "strengthScore": 46,
            "enduranceScore": 44,
            "hillScoreClassificationId": 3,
            "overallScore": 59,
            "hillScoreFeedbackPhraseId": 12,
            "vo2Max": null,
            "vo2MaxPreciseValue": null,
            "primaryTrainingDevice": true
        },
        # Arbitrarily many dates
        {
            "userProfilePK": 123456789,
            "deviceId": 9876543231,
            "calendarDate": "2023-09-07",
            "strengthScore": 46,
            "enduranceScore": 44,
            "hillScoreClassificationId": 3,
            "overallScore": 59,
            "hillScoreFeedbackPhraseId": 11,
            "vo2Max": null,
            "vo2MaxPreciseValue": null,
            "primaryTrainingDevice": true
        }
    ]
}
psdupvi commented 1 year ago

Closed with https://github.com/cyberjunky/python-garminconnect/pull/147