cyberjunky / python-garminconnect

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

Add Endurance Score endpoint #145

Closed psdupvi closed 1 year ago

psdupvi commented 1 year ago

Garmin recently released "Endurance Score", which is detailed here: https://www.garmin.com/en-US/garmin-technology/running-science/physiological-measurements/endurance-score/

I believe the endpoint should be something along the lines of proxy/metrics-service/metrics/endurancescore, 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 (basically, that but without proxy) is something along the lines of:

{
    "userProfilePK": 987654321,
    "deviceId": 12345678910,
    "calendarDate": "2023-09-08",
    "overallScore": 8000,
    "classification": 6,
    "feedbackPhrase": 78,
    "primaryTrainingDevice": true,
    "gaugeLowerLimit": 3570,
    "classificationLowerLimitIntermediate": 5100,
    "classificationLowerLimitTrained": 5800,
    "classificationLowerLimitWellTrained": 6600,
    "classificationLowerLimitExpert": 7300,
    "classificationLowerLimitSuperior": 8100,
    "classificationLowerLimitElite": 8800,
    "gaugeUpperLimit": 10560,
    "contributors": [
        {
            "activityTypeId": null, # This appears to be Running for me?
            "group": 0,
            "contribution": 88.53
        },
        {
            "activityTypeId": 4,
            "group": null,
            "contribution": 6.6
        },
        {
            "activityTypeId": 13,
            "group": null,
            "contribution": 4.03
        },
        # Arbitrarily many?
        {
            "activityTypeId": null,
            "group": 8,
            "contribution": 0.84
        },
            ]
}

Note the inconsistencies in when it's group vs. activityTypeId, but that's a problem for the end user I think

The multi day endpoint returns something like the following:


{
    "userProfilePK": 123456789,
    "startDate": "2023-06-17",
    "endDate": "2023-09-08",
    "avg": 8133,
    "max": 8334,
    "groupMap": {
        "2023-07-22": {
            "groupAverage": 8055,
            "groupMax": 8058,
            "enduranceContributorDTOList": [
                {
                    "activityTypeId": 4,
                    "group": null,
                    "contribution": 1.0875001
                },
                {
                    "activityTypeId": null,
                    "group": 6,
                    "contribution": 1.0875001
                },
                {
                    "activityTypeId": null,
                    "group": 0,
                    "contribution": 86.2175
                },
                {
                    "activityTypeId": 13,
                    "group": null,
                    "contribution": 7.1875
                },
                {
                    "activityTypeId": null,
                    "group": 8,
                    "contribution": 4.42
                }
            ]
        },
        # 12 weeks grouped
        "2023-09-02": {
            "groupAverage": 8280,
            "groupMax": 8334,
            "enduranceContributorDTOList": [
                {
                    "activityTypeId": 4,
                    "group": null,
                    "contribution": 6.5299997
                },
                {
                    "activityTypeId": null,
                    "group": 0,
                    "contribution": 87.50715
                },
                {
                    "activityTypeId": 13,
                    "group": null,
                    "contribution": 5.114286
                },
                {
                    "activityTypeId": null,
                    "group": 8,
                    "contribution": 0.8485714
                }
            ]
        }
    },
    "enduranceScoreDTO": {
        "userProfilePK": 123456789,
        "deviceId": 987654321,
        "calendarDate": "2023-09-08",
        "overallScore": 8271,
        "classification": 6,
        "feedbackPhrase": 78,
        "primaryTrainingDevice": true,
        "gaugeLowerLimit": 3570,
        "classificationLowerLimitIntermediate": 5100,
        "classificationLowerLimitTrained": 5800,
        "classificationLowerLimitWellTrained": 6600,
        "classificationLowerLimitExpert": 7300,
        "classificationLowerLimitSuperior": 8100,
        "classificationLowerLimitElite": 8800,
        "gaugeUpperLimit": 10560,
        "contributors": [
            {
                "activityTypeId": null,
                "group": 0,
                "contribution": 88.53
            },
            {
                "activityTypeId": 4,
                "group": null,
                "contribution": 6.6
            },
            {
                "activityTypeId": 13,
                "group": null,
                "contribution": 4.03
            },
            {
                "activityTypeId": null,
                "group": 8,
                "contribution": 0.84
            }
        ]
    }
}
matin commented 1 year ago

Where do you see this information in the app or on the website?

psdupvi commented 1 year ago

In the app, I see it under "Performance Stats", towards the bottom. On the website, I see it in "Reports". Endurance Score falls under "All Activities", while Hill Score falls under running specifically.

If you don't see them, it's possible they weren't released to your device?

psdupvi commented 1 year ago

Closed in https://github.com/cyberjunky/python-garminconnect/pull/148