MEM: OK // MODE: ESSAY // RADRSS.XML[ADMIN]

Linking Garmin & Gemini

Gemini has no native Garmin integration. To get your workouts, VO2 max, and HRV into Gemini without running a server or exporting CSVs by hand, you can use a Google Apps Script to pull data from Garmin's Personal API into a Google Sheet every 30 minutes, then attach that sheet to a custom Gemini Gem.

Here is the exact setup.

What you need: A Garmin Connect account, a Google account, and 5 minutes. The script lives inside a single Google Sheet, runs free on Google's servers, and has zero access to the rest of your Google Drive.


Step 1: Get Your Garmin Personal API Key

  1. Log in to connect.garmin.com in a desktop browser.
  2. Click your profile avatar (top right) > Account Settings > Personal API Key (on the left menu).
  3. Click Create Key, accept the terms, choose an expiration period (up to 1 year), and click Create.
  4. Copy the GCDC_... key immediately and save it—Garmin only displays it once.

Step 2: Have Gemini Build Your Google Sheet

Instead of creating tabs and typing column headers yourself, let Gemini generate the spreadsheet directly in your Google Drive.

  1. Open gemini.google.com, click Settings (bottom left) > Extensions, and make sure Google Workspace is toggled On.
  2. Start a new chat and paste this exact prompt:

Create a new Google Sheet in my Drive named Garmin_Live_Sync. Rename the first tab to Activities with these exact headers in Row 1: Activity ID, Start Time (Local), Name, Type, Duration (min), Distance (km), Avg Pace (min/km), Avg HR, Max HR, Avg Cadence, Aerobic TE, Raw JSON. Create a second tab named VO2_and_HRV with these exact headers in Row 1: Date, VO2 Max (Running), HRV Weekly Avg, HRV Last Night, HRV Status.

  1. Gemini will create the spreadsheet and give you a clickable link. Click it to open your new sheet.

Step 3: Paste the Sync Script & Set the Timer

Garmin's Personal API uses two-step authentication: you POST your GCDC_... key to get a 24-hour JWT string (returned as plain text, not JSON), then pass that token as a Bearer header to the activity and health endpoints.

  1. In Garmin_Live_Sync, click Extensions > Apps Script.
  2. Delete function myFunction() {} and paste the complete script below. Replace YOUR_GCDC_API_KEY on line 1 with your key from Step 1:
JAVASCRIPT
const GARMIN_API_KEY = 'YOUR_GCDC_API_KEY';
const BASE_URL = '[https://personal.connectapi.garmin.com](https://personal.connectapi.garmin.com)';
const TOKEN_URL = `${BASE_URL}/personalapitoken-service/personal-api/personal-api-key/token`;  function syncGarminLive() { // 1. Exchange Personal API Key for raw 24-hour JWT access token const tokenRes = UrlFetchApp.fetch(TOKEN_URL, { method: 'post', headers: { 'Authorization': 'ApiKey ' + GARMIN_API_KEY } }); const accessToken = tokenRes.getContentText().trim(); const authHeaders = { 'Authorization': 'Bearer ' + accessToken };  const today = new Date(); const sevenDaysAgo = new Date(today.getTime() - 7 * 86400000); const fmtDate = (d) => d.toISOString().split('T')[0]; const startDate = fmtDate(sevenDaysAgo); const endDate = fmtDate(today);  const ss = SpreadsheetApp.getActiveSpreadsheet();  // 2. Pull last 20 activities const actRes = UrlFetchApp.fetch( `${BASE_URL}/activitylist-service/activities/search/activities?limit=20&start=0`,
    { method: 'get', headers: authHeaders }
  );
  writeActivities(ss, JSON.parse(actRes.getContentText()));

  // 3. Pull last 7 days of VO2 Max & HRV
  const vo2Res = UrlFetchApp.fetch(
    `${BASE_URL}/metrics-service/metrics/maxmet/daily/${startDate}/${endDate}`, { method: 'get', headers: authHeaders, muteHttpExceptions: true } ); const hrvRes = UrlFetchApp.fetch( `${BASE_URL}/hrv-service/hrv/daily/${startDate}/${endDate}`,
    { method: 'get', headers: authHeaders, muteHttpExceptions: true }
  );
  writeRecoveryMetrics(ss, vo2Res.getContentText(), hrvRes.getContentText());
}

function writeActivities(ss, activities) {
  const sheet = ss.getSheetByName('Activities');
  const existingIds = sheet.getLastRow() > 1
    ? sheet.getRange(2, 1, sheet.getLastRow() - 1, 1).getValues().flat().map(String)
    : [];

  activities.reverse().forEach(act => {
    const id = String(act.activityId);
    if (!existingIds.includes(id)) {
      const distKm = act.distance ? (act.distance / 1000).toFixed(2) : 0;
      const durMin = act.duration ? (act.duration / 60).toFixed(1) : 0;
      const pace = (act.distance && act.duration)
        ? ((act.duration / 60) / (act.distance / 1000)).toFixed(2)
        : '';

      sheet.appendRow([
        id,
        act.startTimeLocal || '',
        act.activityName || '',
        act.activityType?.typeKey || '',
        durMin,
        distKm,
        pace,
        act.averageHR || '',
        act.maxHR || '',
        act.averageRunningCadenceInStepsPerMinute || act.averageBikingCadenceInRevPerMinute || '',
        act.aerobicTrainingEffect || '',
        JSON.stringify(act)
      ]);
    }
  });
}

function writeRecoveryMetrics(ss, vo2Raw, hrvRaw) {
  const sheet = ss.getSheetByName('VO2_and_HRV');
  const map = {};

  try {
    const vo2Data = JSON.parse(vo2Raw);
    (Array.isArray(vo2Data) ? vo2Data : []).forEach(entry => {
      const d = entry.generic?.calendarDate || entry.calendarDate;
      if (d) {
        map[d] = map[d] || {};
        map[d].vo2 = entry.generic?.vo2MaxPreciseValue || entry.generic?.vo2MaxValue || '';
      }
    });
  } catch (e) {}

  try {
    const hrvParsed = JSON.parse(hrvRaw);
    const summaries = hrvParsed.hrvSummaries || (Array.isArray(hrvParsed) ? hrvParsed : []);
    summaries.forEach(entry => {
      const d = entry.calendarDate;
      if (d) {
        map[d] = map[d] || {};
        map[d].weeklyAvg = entry.weeklyAvg || '';
        map[d].lastNight = entry.lastNightAvg || '';
        map[d].status = entry.status || '';
      }
    });
  } catch (e) {}

  const existingDates = sheet.getLastRow() > 1
    ? sheet.getRange(2, 1, sheet.getLastRow() - 1, 1).getValues().flat().map(String)
    : [];

  Object.keys(map).sort().forEach(date => {
    const rowValues = [
      date,
      map[date].vo2 || '',
      map[date].weeklyAvg || '',
      map[date].lastNight || '',
      map[date].status || ''
    ];
    const rowIndex = existingDates.indexOf(date);
    if (rowIndex === -1) {
      sheet.appendRow(rowValues);
    } else {
      sheet.getRange(rowIndex + 2, 1, 1, 5).setValues([rowValues]);
    }
  });
}
  1. Press Cmd + S (or Ctrl + S) to save.
  2. Click Run in the top toolbar. When Google warns "Google hasn't verified this app", click Advanced > Go to Untitled project (unsafe) > Allow. Your sheet immediately pulls your recent workouts, VO2 max, and HRV.
  3. Click the Triggers icon (alarm clock on the left sidebar) > + Add Trigger.
  4. Set Function to syncGarminLive, Event source to Time-driven, Type to Minutes timer, and Interval to Every 30 minutes. Click Save.

Step 4: Link the Sheet to a Gemini Notebook

  1. Open gemini.google.com, click Notebooks in the left sidebar, and select + New Notebook.
  2. Name it Garmin Coach.
  3. Under Knowledge, click + > Add from Drive and select Garmin_Live_Sync (plus your training plan spreadsheet if you have one).
  4. Paste your heart rate zones, weekly schedule, and this rule into Instructions: Always read Garmin_Live_Sync (tabs: Activities and VO2_and_HRV) from Google Drive before giving training advice or prescribing workouts.
  5. Click Save, and confirm the Google Workspace extension is toggled on in Gemini Settings.

Once your watch syncs to your phone, new sessions hit the sheet within 30 minutes. Open your Gem and ask:

Pull my latest workouts and HRV from Garmin_Live_Sync, compare them against my plan, and tell me what to adjust for tomorrow.

Ads by thinkingforward.fyi

Need fewer dashboards and clearer thinking? Try reading one essay slowly without opening four new tabs.

EXPLORE /NOW ->
CC-BY 4.0 — thinkingforward.fyi // HAND-SET IN MONOCHROME LCDRSS Feed/now/about