This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there an API to change the watch settings?

I'm getting tired of changing some of my watch settings (sleep time etc.) during vacations, weekends etc. and it got me thinking I could make a small script for myself to switch settings like that automatically or make settings profiles.

Is there a way to access the API to remotely change the watch settings?

I know the API exists, because connect.garmin.com uses it, it's clearly visible in Chrome DevTools. E.g. it sends JSON {"userSleep": {"sleepTime": time}} to /userprofile-service/userprofile/user-settings/ to change the sleep time.

But is there a way to get a key for such API?

Top Replies

All Replies

  • There is no API (at least that we can use), but you can send data to that endpoint with a script. I did a test and it works perfectly. I copied the request in DevTools, edited the payload and then sent it again.

    The tricky part is to get the authorization header correct. Garmin recently made some changes to the endpoints used by lots of services on the web which broke them.

  • Uh...That's actually what I was doing until the recent changes. I used to get cookies from a browser and use it in Curl, send it to /modern/di-oauth/exchange which returned token and then used the endpoint above with that token. It worked for months with same cookies.

    Now, it seems that all these cookies and tokens you need expire in an hour or so and need some kind of complicated renewal which is done using a ton of obfuscated javascript on the website. I can't really replicate that with my quite basic scripting abilities.

  • Write a web-browser's script, run in the Console or save as a Bookmark.

    Example: print CSV or download.

    Log-in is done by a web-browser, so just read token and add it as header.

  • Yeah, that's really the only solution I came up with too. There are supposedly even some command line parameters to run Chromium browser headless to automate things like that without it popping up on the screen.

    But unlike a shell or python script, I can't run that on my cheap linux router though, lol.

  • The tricky part is to get the authorization header correct. Garmin recently made some changes to the endpoints used by lots of services on the web which broke them.
    Now, it seems that all these cookies and tokens you need expire in an hour or so and need some kind of complicated renewal which is done using a ton of obfuscated javascript on the website. I can't really replicate that with my quite basic scripting abilities.

    You may find this helpful:

    [https://github.com/pe-st/garmin-connect-export/commit/87b5aac341ea679dd59f286e03ee79e115f5c266]

  • This is great! Too bad it requires library which requires library... which is not precompiled for my router's CPU and compiling is just another can of worms. :-)

    But never mind. I'll run that on my desktop. It's much simpler than running whole Chrome using Selenium and extracting the token from that.

    Thank you very much!