Garmin Connect To JSON
Save data from your Garmin Connect account into a JSON file. You can run it programatically (for example with GitLab or GitHub CI) to automatically back up your data into a JSON archive.
Note: Garmin doesn't offer a public API to normal users so this script scrapes the data from the Web page using your username and password. Your logins are rate limited so triggering this script too often will result in a temporary block for your IP.
- Add your Garmin Connect username and password to
GARMIN_CONNECT_PASSWORDenvironment variables (or into
.envfile in the root of your project).
Note: If you plan to use this script inside a CI pipeline, consider setting
PLAYWRIGHT_BROWSERS_PATH=0 environment variable which forces the installation of the required browser inside
node_modules which allows the binary to be cached as well. (See my notes about running in GitLab CI for more.)
When you run
garmin-connect-to-json first time, a
garminData.json file (can be overrided) is created in the same directory and your most recent data is saved into it. Subsequent invocations will check the file, and add any new items that aren't already in it. The items are saved in order, latest first.
If you run this from CI, you might find
--fail-when-zero flag handy as it returns error code 1 when there are no items.
Usage: garmin-connect-to-json [options] Options: -o, --output-file <filepath> specify where to output the tweets (default: "./garminData.json") -m, --month <YYYY-MM> the month to fetch in YYYY-MM format (default: current month) --fail-when-zero return exit status 1 if no new items are found -d, --debug debug (verbose) mode -V, --version output the version number -h, --help display help for command
All contributions are welcome! Please follow the code of conduct when interacting with others.
Follow @Uninen on Twitter.