# OwnGym exercise library

A free library of gym exercises: **463 exercises**, each with step-by-step instructions, the muscles it trains, and media that shows how to do it.

| What | Count | Format |
|---|---|---|
| Exercise catalogue: names, muscle groups, equipment, level, steps | 463 | [`exercises.json`](exercises.json), readable as [`EXERCISES.md`](EXERCISES.md) |
| Animated guides (one full repetition, looping), female body | 463 | GIF, about 360 px, 200–700 KB |
| Animated guides, male body | 463 | GIF, about 360 px, 200–700 KB |
| Pictures (start and end position, male body) | 239 | WebP, 768 px, 20–60 KB |
| 3D figures used by the OwnGym app | 8 | OwnGym binary format |

Everything is served from a CDN at **<https://owngym-assets.pages.dev/>**, with no account or key. It is the library the [OwnGym](https://owngym-92n.pages.dev) Android app uses for its exercise guides.

**Browse:** [EXERCISES.md](EXERCISES.md) lists every exercise by muscle group, with its steps and links to its GIF and picture.

## Website

The browser library is a static site with five routes: `/`, `/exercises/`, `/collections/`, `/figures/` and `/developers/`. The figures page parses the real OGM2 `.bin` files and textures in the browser, so the 3D viewer uses the same models the app downloads.

The HTML routes are generated from `site/layout.html`, `site/partials/` and `site/pages/`:

```bash
python scripts/build_site.py   # writes index.html, exercises/, collections/, figures/, developers/, sitemap.xml
python scripts/check.py        # checks the catalogue, media and route assets
```

Deploy the generated site with:

```bash
npx wrangler pages deploy . --project-name owngym-assets --branch main
```

## Quick start

Find an exercise by name and get its animated guide:

```bash
curl -s https://owngym-assets.pages.dev/exercises.json \
  | jq -r '.exercises[] | select(.name == "Dumbbell Bench Press") | .media.gifs.female'
# gifs/female/SpYC0Kp.gif  ->  https://owngym-assets.pages.dev/gifs/female/SpYC0Kp.gif
```

```js
const BASE = "https://owngym-assets.pages.dev/";
const { exercises } = await (await fetch(BASE + "exercises.json")).json();
const squat = exercises.find(e => e.name === "Bodyweight Squat");
console.log(squat.steps);                    // how to do it, step by step
console.log(BASE + squat.media.gifs?.female); // animated guide
```

```python
import json, urllib.request
BASE = "https://owngym-assets.pages.dev/"
lib = json.load(urllib.request.urlopen(BASE + "exercises.json"))
chest = [e["name"] for e in lib["exercises"] if e["group"] == "chest" and e["level"] == "beginner"]
```

## Layout

```text
exercises.json              the catalogue, with each exercise's media paths (start here)
EXERCISES.md                the same catalogue as a readable page
index.json                  every media file with a content hash (for apps that cache files)
gifs/female/<id>.gif        animated guide, female body
gifs/male/<id>.gif          animated guide, male body
exercises/<id>.webp         picture; a second or third one is <id>@2.webp, <id>@3.webp
models/<name>.bin, .webp    3D figures and their textures (OwnGym's own format)
models/<name>.thumb.webp    figure thumbnails
```

Media paths are relative to the base URL. An exercise's `id` is the same everywhere: in `exercises.json`, `index.json` and the file names.

## `exercises.json`

```json
{
  "version": 1,
  "base_url": "https://owngym-assets.pages.dev/",
  "exercises": [
    {
      "id": "SpYC0Kp",
      "name": "Dumbbell Bench Press",
      "group": "chest",
      "primary": ["chest"],
      "secondary": ["triceps", "front_delts"],
      "equipment": "dumbbell",
      "level": "intermediate",
      "kind": "strength",
      "steps": ["Lie flat on a bench ...", "Hold a dumbbell in each hand ...", "..."],
      "aliases": ["Bench Press (Dumbbell)"],
      "media": {
        "gifs": { "female": "gifs/female/SpYC0Kp.gif", "male": "gifs/male/SpYC0Kp.gif" },
        "pictures": ["exercises/SpYC0Kp.webp"]
      }
    }
  ]
}
```

| Field | Values |
|---|---|
| `group` | `chest`, `back`, `shoulders`, `biceps`, `triceps`, `forearm`, `trapezius`, `abdomen`, `obliques`, `lower_back`, `glutes`, `quads`, `hamstrings`, `calves` |
| `primary`, `secondary` | Muscles the exercise trains most, and the ones that help: `chest`, `lats`, `mid_back`, `lower_back`, `traps`, `front_delts`, `side_delts`, `rear_delts`, `biceps`, `triceps`, `forearms`, `abs`, `obliques`, `glutes`, `abductors`, `adductors`, `quads`, `hamstrings`, `calves` |
| `equipment` | `barbell`, `dumbbell`, `kettlebell`, `cable`, `machine`, `band`, `bodyweight`, `rings`, `weighted`, `other` |
| `level` | `beginner`, `intermediate`, `advanced` |
| `kind` | `strength`, `calisthenics`, `cardio`, `stretch` |
| `steps` | The movement in order, written for someone doing it for the first time |
| `aliases` | Other names the exercise is known or logged under |
| `media` | Only what exists: `gifs` by body (`female`, `male`) and `pictures` in display order. An empty `media` means the exercise has no media yet; use its steps. |

## Using it from an app

- **Download on demand.** Fetch an exercise's GIF or picture when someone opens that exercise, not the whole library: the GIFs alone are about 340 MB. This is what the OwnGym app does. It also keeps a downloaded GIF only until about 40 MB of GIFs are stored, removing the least recently viewed ones first.
- **Show the GIF first.** It explains the movement best; the picture and the text steps are the fallback when offline or on a slow connection.
- **Cache by hash.** `index.json` lists every file with a short content hash. Request files as `<path>?v=<hash>` and keep them; when the hash changes, the file was replaced. Media files are served with a one-year immutable cache, `index.json` for five minutes.

`index.json`:

```json
{
  "version": 1,
  "exercises": { "<id>": "<hash>", "<id with several pictures>": [{ "f": "<id>.webp", "h": "<hash>" }, { "f": "<id>@2.webp", "h": "<hash>" }] },
  "gifs": { "female": { "<id>": "<hash>" } },
  "figures": [{ "id": "aria", "name": "Aria", "female": true, "bytes": 1234567, "hash": "<hash>" }]
}
```

## For AI assistants and LLM agents

To explain how to do an exercise:

1. Fetch `https://owngym-assets.pages.dev/exercises.json`. Match the exercise by `name` first, then `aliases`, ignoring case. If several match, prefer the one whose `equipment` fits the question.
2. Answer with the exercise's `steps` in order, keeping their wording close. Name the `primary` muscles it trains, and the `secondary` ones if they help.
3. Link the animated guide as `base_url + media.gifs.female` or `media.gifs.male` and the picture as `base_url + media.pictures[0]`. Only link paths that are in `media`; never build a URL for a file that is not listed.
4. To suggest exercises, filter by `group` or `primary` (the muscle), `equipment` (what the person has) and `level` (start beginners on `beginner`).

[`EXERCISES.md`](EXERCISES.md) has the same content as a single page if you can only read text.

## Notes

- The guides show general technique and are not medical advice. Start light, and ask a qualified trainer or doctor if you have an injury or a health condition.
- The GIFs and pictures were generated with AI image tools from the steps in the catalogue and checked by hand. If one looks wrong, please open an issue with the exercise id.

## Licence

The catalogue and media are licensed under [CC BY 4.0](LICENSE): use, share and adapt them, including commercially, with credit to "OwnGym exercise library" and a link to this repository.
