Dev.to WebDev πŸ›  Dev πŸ‘ 1 πŸ“– 4 min read

Populating Fitness Databases with 800+ Exercises from Wger

Building a workout tracker, rehab application, or gym management system usually stalls at the same bottleneck: sourcing a structured, licensed exercise library. Hand-curating hundreds of movementsβ€”complete with anatomica

Building a workout tracker, rehab application, or gym management system usually stalls at the same bottleneck: sourcing a structured, licensed exercise library. Hand-curating hundreds of movementsβ€”complete with anatomical targets, equipment requirements, localized descriptions, and media assetsβ€”takes weeks of manual data entry.

The open-source Wger database contains over 800 community-maintained exercises under LGPL licensing. However, pulling this relational data directly via ad-hoc scripts often requires managing multiple API endpoints to resolve foreign keys for primary muscles, secondary stabilizers, categories, and image assets.

Using the Wger Exercise & Workout Scraper, you can extract fully denormalized exercise records directly into structured datasets without managing authentication or raw schema joins.

Anatomy of the Extracted Exercise Record

When pulling data from Wger via this scraper, nested relational fields are resolved into flattened arrays. A single returned entity resolves the exercise's anatomical classifications, required gear, and hosted media files.

Each record in the dataset includes:

{
  "exerciseId": 73,
  "name": "Bench Press",
  "description": "Lay down on a bench, the bar should be directly above your eyes...",
  "category": "Chest",
  "primaryMuscles": ["Chest"],
  "secondaryMuscles": ["Shoulders", "Triceps"],
  "equipment": ["Barbell", "Bench"],
  "imageUrls": [
    "https://wger.de/media/exercise-images/192/Bench-press-1.png",
    "https://wger.de/media/exercise-images/192/Bench-press-2.png"
  ],
  "sourceUrl": "https://wger.de/en/exercise/73/view/bench-press",
  "createdAt": "2023-08-06T10:17:17.422900+02:00",
  "lastUpdated": "2026-06-19T18:46:21.803261+02:00",
  "recordType": "exercise",
  "scrapedAt": "2026-06-30T12:00:00+00:00"
}

The scraper standardizes anatomical naming by outputting Wger's short English muscle terms (such as "Chest" or "Triceps") when present, falling back to anatomical Latin terms (such as "Pectoralis major") when a short label does not exist.

Configuring Extraction Modes

The actor relies on the required mode string to define how it traverses the database. Depending on your data pipeline's requirements, you can target specific subsets instead of dumping the entire database.

Extracting by Muscle Target

If you are generating isolation-workout routines, configure mode: "byMuscle" alongside the muscle parameter:

{
  "mode": "byMuscle",
  "muscle": "Biceps brachii",
  "maxItems": 30
}

This retrieves exercises targeting specific groups like Latissimus dorsi, Quadriceps femoris, Gluteus maximus, or Rectus abdominis.

Extracting by Equipment Constraints

For apps building home-workout filters where users lack access to commercial machinery, use mode: "byEquipment":

{
  "mode": "byEquipment",
  "equipment": "Dumbbell",
  "includeImages": true,
  "maxItems": 50
}

Supported equipment values include Barbell, Dumbbell, Kettlebell, Pull-up bar, Resistance band, Swiss Ball, and Body weight.

Keyword and Identifier Lookups

  • Keyword search (mode: "search"): Matches terms against exercise names and descriptions using the searchQuery string.
  • Body category (mode: "byCategory"): Groups records by broad anatomical sections using the category string (Abs, Arms, Back, Calves, Cardio, Chest, Legs, Shoulders).
  • Direct ID lookup (mode: "byIds"): Pass an array of strings to exerciseIds (e.g., ["9", "73", "132"]) to refresh specific records.

Note that this scraper cannot perform multi-parameter filtering at the input stage (such as querying Chest AND Dumbbell simultaneously). To achieve intersection filtering, you must fetch by one dimension (such as byCategory) and filter the secondary fields downstream in your own processing script.

Running the Scraper with Python

You can trigger extraction programmatically and ingest the records into your application using the Apify Python client.

1. Initialize the Client and Define Input

Set up your payload with the appropriate operational mode, translation language, and item limits.

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run_input = {
    "mode": "byCategory",
    "category": "Back",
    "language": "en",
    "includeImages": True,
    "maxItems": 100
}

2. Execute the Actor Run

Start the actor run and wait for execution to complete.

run = client.actor("crawlerbros/wger-exercise-scraper").call(run_input=run_input)

3. Consume the Dataset Items

Iterate through the default dataset to transform or store the exercise records directly in your database.

dataset_items = client.dataset(run["defaultDatasetId"]).iterate_items()

for item in dataset_items:
    exercise_id = item.get("exerciseId")
    name = item.get("name")
    primary_muscles = item.get("primaryMuscles", [])
    images = item.get("imageUrls", [])

    print(f"[{exercise_id}] {name} - Targets: {', '.join(primary_muscles)} ({len(images)} images)")

Understanding Event-Based Run Costs

The actor operates strictly on a pay-per-event pricing model. There are two billable events:

  1. Actor Start (apify-actor-start): Billed at $0.005 per GB of memory allocated to the run, charged once when the run initializes.
  2. Result (apify-default-dataset-item): Billed at $0.005 per returned exercise record.

Under volume tiers, the per-result price scales as follows:

  • FREE: $0.005 per result
  • BRONZE: $0.00433 per result
  • SILVER: $0.00367 per result
  • GOLD: $0.003 per result
  • PLATINUM: $0.003 per result
  • DIAMOND: $0.003 per result

Extracting a batch of 100 exercise records on a 1 GB run under the standard FREE tier costs $0.005 (Actor Start) plus $0.50 (100 results at $0.005 each), totaling $0.505.

Data Persistence and Identifier Stability

While Wger provides stable UUIDs via the uuid field across its federation, raw numeric exerciseId values can occasionally be retired or renumbered upstream by community maintainers. If a stored exerciseId stops resolving during subsequent mode: "byIds" runs, you will need to re-query via mode: "search" or mode: "byCategory" to map your internal schema to the newly assigned identifier.

Wger Exercise & Workout Scraper is what these steps drive. The README covers the inputs this article skipped, including the ones that change how much a run costs.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.