matin / garth

Garmin SSO auth + Connect Python client
MIT License
305 stars 22 forks source link

Garmin Golf data #48

Closed Richard-Tarbell closed 8 months ago

Richard-Tarbell commented 8 months ago

I'm not sure if this is the place to put this so I apologize in advance if this belongs somewhere else!

Q: Hi everyone, I was wondering if anyone knows how to access the garmin golf data through garth?

Previously I was using the garmin_golf repo to get golf data via json file. However as of a couple months ago it no longer works. From what I can tell it appears to be a change in the API (I could be way off) and I can't figure out how to make it work again.

Garth seems like the better option to access my garmin data so I was hoping someone could point me in the right direction for accessing the golf data. I've tried a few ways but I'm still very new to APIs so I'm not sure what exactly to put in the garth.connectapi() call.

TIA

matin commented 8 months ago

I did some research on this. I'll test some of the endpoints I found over the weekend and add them here

matin commented 8 months ago

@Richard-Tarbell figured it out ...

Take a look at the endpoints in garmin-download.js and remove the initial part of https://connect.garmin.com/modern/proxy.

For example, I'm able to do the following: garth.connectapi('/gcs-golfcommunity/api/v2/player/stats')

The same should apply for the other endpoints.

Let me know if that works for you as well.

Richard-Tarbell commented 8 months ago

That works perfect for me! Thanks @matin!! Using Garth is definitely gonna be an upgrade to my project by eliminating the need for users to download the file externally.

For anyone who was previously using garmin_golf here's the garth.connectapi() equivalent for the endpoints requiring parameters.

scorecardID = 123456789
hole_number = 1

round_stats = garth.connectapi(
    f"gcs-golfcommunity/api/v2/scorecard/detail",
    params={"scorecard-ids":scorecardID,"include-longest-shot-distance":"true"},
)

hole_details = garth.connectapi(
    f"gcs-golfcommunity/api/v2/shot/scorecard/{scorecardID}/hole",
    params={"hole-numbers":hole_number, "image-size":"IMG_730X730", "_":"1635952489437"},
)