Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
feat: add hevy map import to csv import
Julius Haring687ef2562eb0
diff --git a/docs/DATA_IMPORTS.md b/docs/DATA_IMPORTS.mdindex fb7a484d7..95fc1c8e7 100644--- a/docs/DATA_IMPORTS.md+++ b/docs/DATA_IMPORTS.md@@ -36,7 +36,7 @@ These apps have been tested to work without adjustments to the column names:| **FitNotes 2 (iOS)** | Export workouts as CSV; also manual/auto iCloud backups || **Strong** | Settings → Export Data || **Gravl** | Profile → Export Data |-| **Hevy** | Profile → Settings → Export & Import Data (Workouts or Measurements) |+| **Hevy** | Profile → Settings → Export & Import Data (Workouts or Measurements), **or** Settings → Import from Hevy with a Pro API key |### Hevy API (direct)@@ -45,13 +45,15 @@ If you have **Hevy Pro**, you can skip the CSV and import straight from Hevy:1. Open [Hevy → Settings → Developer](https://hevy.com/settings?developer) and create an API key2. In openGym: **Settings → Import from Hevy**3. Paste the key (used only for that import — it is not saved)-4. Choose whether to bring **workouts**, **weigh-ins**, or both, then confirm--Exercises are matched by Hevy’s `exercise_template_id` through a generated lookup-table (`frontend/src/lib/hevy-id-map.js`) — not by the localized names on each set.-To regenerate the table (developers): set `HEVY_API_KEY` in the environment or-`.env`, then run `node scripts/build-hevy-id-map.mjs`. Unmapped lifts become your-own exercises. Days that already have data here are left alone.+4. Choose whether to bring **workouts**, **routines**, **weigh-ins**, or any mix, then confirm++Both the API import and a detected **Hevy CSV** resolve exercises through the same generated+lookup (`frontend/src/lib/hevy-id-map.js`): template id for the API, English title for the CSV.+To regenerate (developers): set `HEVY_API_KEY` in the environment or `.env`, then run+`node scripts/build-hevy-id-map.mjs`. Unmapped lifts become your own exercises. Workout days+that already have data here are left alone; routines are always added as **new** plans+(nothing you already have is overwritten). Localized CSV titles (non-English) still fall back+to name matching.You can also create your own `CSV` file:diff --git a/frontend/src/lib/hevy-id-map.js b/frontend/src/lib/hevy-id-map.jsindex 8c0b3d053..ce5b32f27 100644--- a/frontend/src/lib/hevy-id-map.js+++ b/frontend/src/lib/hevy-id-map.js@@ -1,6 +1,7 @@// AUTO-GENERATED by scripts/build-hevy-id-map.mjs — do not edit by hand.-// Hevy exercise_template id → openGym catalogue id.-// Regenerated from the Hevy templates API + verified title aliases.+// Hevy exercise_template id → openGym catalogue id, plus English title → id for CSV exports+// (Hevy CSV has titles, not template ids). Regenerated from the Hevy templates API ++// verified title aliases.// 283 mapped · 168 left unmatched (import as custom).// Source templates: 451 (built-in only).@@ -289,3 +290,290 @@ export const HEVY_ID_MAP = {"FFC106CB": "0753","FFDA283B": "0381",}++/** Lowercased Hevy English title → catalogue id (CSV / name path). */+export const HEVY_TITLE_MAP = {+ "ab wheel": "0857",+ "air bike": "0003",+ "arnold press (dumbbell)": "2137",+ "around the world": "2143",+ "back extension (hyperextension)": "0573",+ "back extension (machine)": "0573",+ "back extension (weighted hyperextension)": "0573",+ "battle ropes": "0128",+ "bear crawl": "3360",+ "bench dip": "0830",+ "bench press (barbell)": "0025",+ "bench press (cable)": "0151",+ "bench press (dumbbell)": "0289",+ "bench press (smith machine)": "0748",+ "bench press - close grip (barbell)": "0030",+ "bench press - wide grip (barbell)": "1258",+ "bent over row (band)": "0027",+ "bent over row (barbell)": "0027",+ "bent over row (dumbbell)": "0292",+ "bent over row (smith machine)": "1359",+ "bicep curl (barbell)": "0031",+ "bicep curl (cable)": "0868",+ "bicep curl (dumbbell)": "0294",+ "bicep curl (machine)": "0575",+ "bicep curl (suspension)": "0294",+ "bicycle crunch": "0972",+ "boxing": "2271",+ "bulgarian split squat (barbell)": "0099",+ "bulgarian split squat (dumbbell)": "0410",+ "burpee": "1160",+ "butterfly (pec deck)": "0596",+ "cable core pallof press": "0979",+ "cable crunch": "0175",+ "cable fly crossovers": "1269",+ "cable pull through": "0196",+ "cable twist (down to up)": "0243",+ "cable twist (up to down)": "0243",+ "calf press (machine)": "2289",+ "chest dip": "0251",+ "chest dip (assisted)": "0009",+ "chest dip (weighted)": "0251",+ "chest fly (dumbbell)": "0308",+ "chest fly (machine)": "0596",+ "chest press (band)": "3124",+ "chest press (machine)": "0577",+ "chest supported incline row (dumbbell)": "0327",+ "chest supported reverse fly (dumbbell)": "0383",+ "chin up": "1326",+ "chin up (assisted)": "0572",+ "chin up (weighted)": "0572",+ "clap push ups": "1273",+ "clean": "0028",+ "clean and press": "0028",+ "concentration curl": "0297",+ "cross body hammer curl": "0298",+ "crunch": "0832",+ "crunch (machine)": "1452",+ "crunch (weighted)": "0832",+ "cycling": "2331",+ "dead bug": "0276",+ "deadlift (band)": "0032",+ "deadlift (barbell)": "0032",+ "deadlift (dumbbell)": "0300",+ "deadlift (smith machine)": "0752",+ "deadlift (trap bar)": "0811",+ "decline bench press (barbell)": "0033",+ "decline bench press (dumbbell)": "0301",+ "decline bench press (machine)": "0033",+ "decline bench press (smith machine)": "0753",+ "decline crunch": "0277",+ "decline crunch (weighted)": "0277",+ "decline push up": "0279",+ "diamond push up": "0283",+ "drag curl": "0038",+ "dumbbell row": "0292",+ "dumbbell snatch": "3888",+ "dumbbell step up": "0431",+ "elbow to knee": "0443",+ "elliptical trainer": "2141",+ "ez bar biceps curl": "2404",+ "face pull": "0203",+ "farmers walk": "2133",+ "floor press (barbell)": "0065",+ "floor triceps dip": "0815",+ "flutter kicks": "0459",+ "front raise (band)": "0978",+ "front raise (barbell)": "0041",+ "front raise (cable)": "0162",+ "front raise (dumbbell)": "0310",+ "front raise (suspension)": "0834",+ "front squat": "0042",+ "full squat": "0043",+ "glute bridge (barbell)": "1409",+ "glute ham raise": "3193",+ "goblet squat": "1760",+ "good morning (barbell)": "0044",+ "hack squat": "0046",+ "hack squat (machine)": "0743",+ "hammer curl (band)": "0313",+ "hammer curl (cable)": "0165",+ "hammer curl (dumbbell)": "0312",+ "handstand push up": "0471",+ "hang clean": "0535",+ "hanging knee raise": "0472",+ "hanging leg raise": "0472",+ "high knees": "3655",+ "hip abduction (cable)": "0597",+ "hip abduction (machine)": "0597",+ "hip adduction (cable)": "0168",+ "hip adduction (machine)": "0598",+ "incline bench press (barbell)": "0047",+ "incline bench press (dumbbell)": "0314",+ "incline bench press (smith machine)": "0757",+ "incline chest fly (dumbbell)": "0319",+ "incline chest press (machine)": "1299",+ "incline push ups": "0493",+ "inverted row": "0499",+ "iso-lateral row (machine)": "0571",+ "jackknife sit up": "0507",+ "jm press (barbell)": "0052",+ "jump rope": "2612",+ "jump squat": "0514",+ "jumping jack": "3220",+ "kettlebell clean": "0535",+ "kettlebell goblet squat": "0534",+ "kettlebell high pull": "0548",+ "kettlebell snatch": "0529",+ "kettlebell swing": "0549",+ "kettlebell turkish get up": "0551",+ "knee raise parallel bars": "0826",+ "kneeling pulldown (band)": "0983",+ "kneeling push up": "3211",+ "landmine 180": "0562",+ "lat pulldown (band)": "2330",+ "lat pulldown (cable)": "2330",+ "lat pulldown (machine)": "0673",+ "lat pulldown - close grip (cable)": "2616",+ "lateral lunge": "1410",+ "lateral raise (band)": "0977",+ "lateral raise (cable)": "0178",+ "lateral raise (dumbbell)": "0334",+ "lateral raise (machine)": "0584",+ "leg extension (machine)": "0585",+ "leg press (machine)": "0739",+ "leg press horizontal (machine)": "2611",+ "leg raise parallel bars": "0826",+ "low row (suspension)": "0180",+ "lunge": "0054",+ "lunge (barbell)": "0054",+ "lunge (dumbbell)": "0336",+ "lying leg curl (machine)": "0586",+ "lying leg raise": "0865",+ "mountain climber": "0630",+ "muscle up": "0631",+ "oblique crunch": "1495",+ "overhead curl (cable)": "1636",+ "overhead press (barbell)": "0091",+ "overhead press (dumbbell)": "0405",+ "overhead press (smith machine)": "0766",+ "overhead squat": "0069",+ "overhead triceps extension (cable)": "0194",+ "pendlay row (barbell)": "3017",+ "pistol squat": "0544",+ "plank": "2135",+ "plate front raise": "0310",+ "power clean": "0648",+ "preacher curl (barbell)": "0070",+ "preacher curl (dumbbell)": "0372",+ "preacher curl (machine)": "0592",+ "pull up": "0652",+ "pull up (assisted)": "0017",+ "pull up (band)": "0970",+ "pull up (weighted)": "0652",+ "pullover (dumbbell)": "0375",+ "pullover (machine)": "2285",+ "push press": "1700",+ "push up": "0662",+ "push up (weighted)": "0662",+ "push up - close grip": "0259",+ "rack pull": "0074",+ "rear delt reverse fly (cable)": "0602",+ "rear delt reverse fly (dumbbell)": "0383",+ "rear delt reverse fly (machine)": "0602",+ "renegade row (dumbbell)": "0521",+ "reverse crunch": "0872",+ "reverse curl (barbell)": "0080",+ "reverse curl (cable)": "0206",+ "reverse grip lat pulldown (cable)": "0673",+ "reverse hyperextension": "0593",+ "reverse lunge (barbell)": "0078",+ "reverse lunge (dumbbell)": "0381",+ "reverse plank": "3663",+ "reverse wrist curl (dumbbell)": "0385",+ "ring dips": "0677",+ "romanian deadlift (barbell)": "0085",+ "romanian deadlift (dumbbell)": "1459",+ "romanian deadlift (smith machine)": "0085",+ "rope cable curl": "0165",+ "rope straight arm pulldown": "0237",+ "russian twist (bodyweight)": "0687",+ "russian twist (weighted)": "0687",+ "scapular pull ups": "0688",+ "seated cable row - bar grip": "0218",+ "seated cable row - v grip (cable)": "0218",+ "seated calf raise": "0594",+ "seated dip machine": "1451",+ "seated incline curl (dumbbell)": "0318",+ "seated lateral raise (dumbbell)": "0396",+ "seated leg curl (machine)": "0586",+ "seated overhead press (barbell)": "0091",+ "seated overhead press (dumbbell)": "0091",+ "seated palms up wrist curl": "0401",+ "seated row (machine)": "1350",+ "seated shoulder press (machine)": "0603",+ "seated wrist curl (barbell)": "1426",+ "shoulder press (dumbbell)": "0405",+ "shoulder press (machine plates)": "0603",+ "shrug (barbell)": "0095",+ "shrug (cable)": "0220",+ "shrug (dumbbell)": "0406",+ "shrug (machine)": "0604",+ "shrug (smith machine)": "0767",+ "side bend (dumbbell)": "0407",+ "side plank": "1775",+ "single arm lateral raise (cable)": "0192",+ "single leg standing calf raise (machine)": "0605",+ "sissy squat (weighted)": "1489",+ "skullcrusher (barbell)": "0060",+ "skullcrusher (dumbbell)": "0060",+ "snatch": "0067",+ "spider curl (dumbbell)": "1675",+ "split squat (dumbbell)": "0809",+ "sprints": "0858",+ "squat (band)": "1004",+ "squat (barbell)": "0043",+ "squat (bodyweight)": "3543",+ "squat (dumbbell)": "0413",+ "squat (machine)": "0043",+ "squat (smith machine)": "0770",+ "squat (suspension)": "0043",+ "squat row": "1003",+ "stair machine (floors)": "2311",+ "stair machine (steps)": "2311",+ "standing calf raise": "1372",+ "standing calf raise (barbell)": "1372",+ "standing calf raise (dumbbell)": "0417",+ "standing calf raise (machine)": "0605",+ "standing calf raise (smith)": "0773",+ "standing leg curls": "0795",+ "standing military press (barbell)": "1457",+ "straight leg deadlift": "0116",+ "sumo deadlift": "0117",+ "sumo squat": "3142",+ "sumo squat (barbell)": "3142",+ "sumo squat (dumbbell)": "3142",+ "sumo squat (kettlebell)": "3142",+ "superman": "0803",+ "t bar row": "0606",+ "thruster (barbell)": "3305",+ "thruster (kettlebell)": "0550",+ "treadmill": "3666",+ "triceps dip": "0591",+ "triceps dip (assisted)": "0019",+ "triceps dip (weighted)": "0591",+ "triceps extension (barbell)": "0607",+ "triceps extension (cable)": "0607",+ "triceps extension (dumbbell)": "0607",+ "triceps extension (machine)": "0607",+ "triceps extension (suspension)": "0607",+ "triceps pushdown": "0241",+ "upright row (barbell)": "0120",+ "upright row (cable)": "0246",+ "upright row (dumbbell)": "0437",+ "waiter curl (dumbbell)": "5201",+ "walking": "1460",+ "walking lunge": "1460",+ "walking lunge (dumbbell)": "1460",+ "walking lunge (sandbag)": "1460",+ "wall sit": "0624",+ "wide pull up": "1429",+ "yoga": "1494",+ "zercher squat": "0127",+ "zottman curl (dumbbell)": "0439",+}diff --git a/frontend/src/lib/import-csv.js b/frontend/src/lib/import-csv.jsindex 282f0bb14..73ecc94cb 100644--- a/frontend/src/lib/import-csv.js+++ b/frontend/src/lib/import-csv.js@@ -21,6 +21,7 @@import { EXDB, EXIDX } from './exercises.js'import { uid } from './format.js'import { isWarmupRow } from './workout-model.js'+import { HEVY_TITLE_MAP } from './hevy-id-map.js'/* ----------------------------------------------------------------- CSV ---- */@@ -251,6 +252,16 @@ export function matchExercise(name) {return ties === 1 ? best : null}+/**+ * Exact Hevy English title → catalogue id (from the generated title map).+ * Used when a CSV is detected as Hevy: same deterministic table as the API import,+ * keyed by title because Hevy's CSV has no template id column.+ */+export function matchHevyTitle(name) {+ const id = HEVY_TITLE_MAP[String(name || '').trim().toLowerCase()]+ return id && EXIDX[id] ? id : null+}+// Hevy exports no category column, so every invented exercise fell through to the// 'upper legs' default and a third of an imported history was attributed to the legs in// the muscle map. When there is no category, read the body part off the name instead.@@ -389,7 +400,12 @@ export function parseWorkoutCSV(text, { unit = 'kg' } = {}) {const key = keyOf(name)let id = resolved.get(key)- if (id === undefined) { id = matchExercise(name); resolved.set(key, id) }+ if (id === undefined) {+ // Hevy CSV: prefer the generated English-title map (same table as the API import).+ // Localized titles still fall through to the word-bag matcher.+ id = (source === 'Hevy' ? matchHevyTitle(name) : null) || matchExercise(name)+ resolved.set(key, id)+ }if (id) matched++else {let c = created.get(key)diff --git a/frontend/src/lib/import-hevy.js b/frontend/src/lib/import-hevy.jsindex 262f72315..aa4fafd41 100644--- a/frontend/src/lib/import-hevy.js+++ b/frontend/src/lib/import-hevy.js@@ -8,9 +8,9 @@import { EXIDX } from './exercises.js'import { uid } from './format.js'import { isWarmupRow } from './workout-model.js'-import { HEVY_ID_MAP } from './hevy-id-map.js'+import { HEVY_ID_MAP, HEVY_TITLE_MAP } from './hevy-id-map.js'-export { HEVY_ID_MAP }+export { HEVY_ID_MAP, HEVY_TITLE_MAP }export const HEVY_API = 'https://api.hevyapp.com'export const HEVY_DEV_SETTINGS = 'https://hevy.com/settings?developer'diff --git a/frontend/src/lib/import-match.test.js b/frontend/src/lib/import-match.test.jsindex 2febc5f49..c726ab854 100644--- a/frontend/src/lib/import-match.test.js+++ b/frontend/src/lib/import-match.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { matchExercise, parseWorkoutCSV } from './import-csv.js'+import { matchExercise, matchHevyTitle, parseWorkoutCSV, detectSource } from './import-csv.js'import { EXIDX } from './exercises.js'// The names other apps actually export, and the catalogue entry each has to land on.@@ -109,3 +109,36 @@ describe('invented exercises get a body part from their name', () => {expect(r.customEx[0].bp).toBe('shoulders')})})++describe('Hevy CSV uses the generated title map', () => {+ const HEVY_CSV = [+ 'title,start_time,end_time,description,exercise_title,superset_id,exercise_notes,set_index,set_type,weight_kg,reps,distance_km,duration_seconds,rpe',+ 'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Bulgarian Split Squat (Dumbbell),,,0,normal,40,10,0,,',+ 'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Lat Pulldown - Close Grip (Cable),,,0,warmup,25,15,0,,',+ 'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Lat Pulldown - Close Grip (Cable),,,1,normal,52,12,0,,8',+ 'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Reverse Lunge (Dumbbell),,,0,normal,20,10,0,,',+ ].join('\n')++ it('detects the Hevy export dialect', () => {+ expect(detectSource(HEVY_CSV.split('\n')[0].split(','))).toBe('Hevy')+ })++ it('resolves English Hevy titles through HEVY_TITLE_MAP before the word-bag', () => {+ expect(matchHevyTitle('Bulgarian Split Squat (Dumbbell)')).toBe('0410')+ expect(matchHevyTitle('Lat Pulldown - Close Grip (Cable)')).toBe('2616')+ expect(matchHevyTitle('Reverse Lunge (Dumbbell)')).toBe('0381')+ // Word-bag alone still misses these — the title map is what makes CSV work.+ expect(matchExercise('Bulgarian Split Squat (Dumbbell)')).toBeNull()+ })++ it('imports a Hevy CSV onto catalogue ids, not customs', () => {+ const parsed = parseWorkoutCSV(HEVY_CSV, { unit: 'kg' })+ expect(parsed.source).toBe('Hevy')+ expect(parsed.created).toBe(0)+ const ids = parsed.workouts[0].entries.map(e => e.id).sort()+ expect(ids).toEqual(['0410', '0381', '2616'].sort())+ const pull = parsed.workouts[0].entries.find(e => e.id === '2616')+ expect(pull.sets[0]).toMatchObject({ w: 25, r: 15, phase: 'warmup' })+ expect(pull.sets[1]).toMatchObject({ w: 52, r: 12, rpe: 8 })+ })+})diff --git a/scripts/build-hevy-id-map.mjs b/scripts/build-hevy-id-map.mjsindex f1275f6f4..a01bd03dd 100644--- a/scripts/build-hevy-id-map.mjs+++ b/scripts/build-hevy-id-map.mjs@@ -209,32 +209,44 @@ async function main() {}const map = {}+ const titleMap = {}const unmatched = []for (const t of templates) {if (!t?.id || t.is_custom) { if (t?.id && t.is_custom) unmatched.push(t); continue }const id = resolve(t)- if (id) map[t.id] = id- else unmatched.push(t)+ if (id) {+ map[t.id] = id+ const titleKey = String(t.title || '').trim().toLowerCase()+ if (titleKey && !titleMap[titleKey]) titleMap[titleKey] = id+ } else unmatched.push(t)}// Stable key order for readable diffs.const keys = Object.keys(map).sort()const lines = keys.map(k => ` ${JSON.stringify(k)}: ${JSON.stringify(map[k])},`)+ const titleKeys = Object.keys(titleMap).sort()+ const titleLines = titleKeys.map(k => ` ${JSON.stringify(k)}: ${JSON.stringify(titleMap[k])},`)const body = `// AUTO-GENERATED by scripts/build-hevy-id-map.mjs — do not edit by hand.-// Hevy exercise_template id → openGym catalogue id.-// Regenerated from the Hevy templates API + verified title aliases.+// Hevy exercise_template id → openGym catalogue id, plus English title → id for CSV exports+// (Hevy CSV has titles, not template ids). Regenerated from the Hevy templates API ++// verified title aliases.// ${keys.length} mapped · ${unmatched.length} left unmatched (import as custom).// Source templates: ${templates.length} (built-in only).export const HEVY_ID_MAP = {${lines.join('\n')}}++/** Lowercased Hevy English title → catalogue id (CSV / name path). */+export const HEVY_TITLE_MAP = {+${titleLines.join('\n')}+}`writeFileSync(OUT, body)console.log(`Wrote ${OUT}`)- console.log(`Mapped ${keys.length} / ${templates.filter(t => !t.is_custom).length}`)+ console.log(`Mapped ${keys.length} / ${templates.filter(t => !t.is_custom).length} (titles ${titleKeys.length})`)console.log(`Unmatched ${unmatched.length} (become custom on import)`)if (process.env.VERBOSE) {unmatched.slice(0, 40).forEach(t => console.log(' -', t.title, `[${t.equipment}]`))