Skip to content

vespexx/garmin2googlesheet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Garmin to Google Sheets Sync

This application fetches your running stats from Garmin Connect and writes them directly to a Google Sheet using the gspread library.

Prerequisites

  • Python 3.12+
  • uv for dependency management (pip install uv)

Setup

1. Project Environment

Copy the .env.example file to .env and fill in your Garmin credentials:

cp .env.example .env

Edit .env:

GARMIN_EMAIL=your_email@example.com
GARMIN_PASSWORD=your_password
SPREADSHEET_ID=your_spreadsheet_id

2. Google Sheets Setup (via gspread)

For a clean integration, we use the gspread library with a Google Cloud Service Account.

  1. Go to the Google Cloud Console and create a project.
  2. Enable the Google Sheets API.
  3. Go to IAM & Admin > Service Accounts, create a Service Account, and download a JSON key.
  4. You have two options for managing this key:
    • Option A (Local File): Rename the downloaded file to service_account.json and place it in this project root.
    • Option B (Secret Manager): Store the contents of the JSON key in Google Cloud Secret Manager.
      1. Enable the Secret Manager API.
      2. Create a secret and paste the JSON key content as the secret value.
      3. Add GARMIN_SHEET_SECRET_NAME to your .env file with the full resource name (e.g., projects/YOUR_PROJECT_ID/secrets/YOUR_SECRET_NAME/versions/latest).
      4. Ensure the environment where you run the script has access to Google Cloud credentials (e.g., via gcloud auth application-default login or a service account attached to the resource).
  5. Share your Google Sheet with the Service Account email (found in the JSON file) as "Editor".
  6. Add SPREADSHEET_ID to your .env file.

3. Installation & Running

You can use the provided Makefile for common commands:

make sync

Or run the script using uv directly:

uv lock
uv run python -m src.sync_stats

4. Automation with crontab

To run the sync automatically and handle cases where the laptop is asleep at the scheduled time, you can use crontab.

  1. Open your crontab for editing:

    crontab -e
  2. Add the following entry to run the script every 1 hours:

    0 * * * * cd /Users/kashnitsky/Documents/garmin_sheet && make sync >> garmin_sync.log 2>&1

    The script includes logic to ensure it only performs the sync once per hour, so running it every hour allows it to catch up if the laptop was asleep

  3. Verify the cron job is active:

    crontab -l

Example of fetched data Garmin Running Stats

5. Analysis with Gemini

In a Gemini Chat or Gem, ask

Based on my latest running stats from <link to the sheet>, provide me and advice
on how to improve my running performance.

About

Fetch garmin stats and dump them into a sheety sheet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 98.1%
  • Makefile 1.9%