How to Import and Use the Exercises Dataset in Node.js
You can import the exercises dataset directly into any Node.js application by requiring the data/exercises.json file, which exposes an array of 1,324 exercise objects that you can filter, map, and reduce using standard JavaScript array methods.
The hasaneyldrm/exercises-dataset repository provides a comprehensive, ready-to-use JSON collection of fitness exercises designed for developers building workout applications. Since the dataset is stored as a plain JSON module at data/exercises.json, you can import and use the exercises dataset in Node.js without any external dependencies or complex setup. Each record contains multilingual instructions, equipment requirements, and media links structured according to the formal schema documented in the repository’s README【/cache/repos/github.com/hasaneyldrm/exercises-dataset/main/README.md#L72-L99】.
Dataset Structure and Schema
The exercises dataset is structured as a single JSON array where each element follows the JSON Schema defined in data/exercises.schema.json. This schema validates 1,324 exercise records, ensuring consistency across all entries.
Core Data Fields
Each exercise object contains the following key properties:
id– Unique numeric identifier stored as a string (e.g.,"0001")name– Human-readable exercise namecategory/body_part– Primary anatomical classification (e.g., "chest", "back")equipment– Required equipment type (e.g.,"dumbbell","body weight","cable")instructions– Nested object containing step-by-step descriptions in multiple languages (en,es, etc.)image/gif_url– Relative paths to 180×180 pixel thumbnail and animation filesmedia_id– Source identifier for the original media content
According to the repository source code, these fields enable precise filtering and localization for fitness applications【/cache/repos/github.com/hasaneyldrm/exercises-dataset/main/README.md#L72-L99】.
Loading the Dataset in Node.js
Since data/exercises.json is a standard JSON file, you can load it synchronously using Node.js’s require() function. This approach caches the data on the first import, making subsequent accesses instantaneous.
// Load the entire dataset into memory
const exercises = require('./data/exercises.json');
console.log(`Dataset loaded: ${exercises.length} exercises available`);
For ES Module projects using .mjs files or "type": "module" in package.json, use dynamic import instead:
const exercises = await import('./data/exercises.json', { assert: { type: 'json' } });
Querying and Filtering Exercise Data
Once loaded, the exercises array supports all native JavaScript array methods. The following patterns demonstrate how to extract specific subsets of data as shown in the repository’s JavaScript usage examples【/cache/repos/github.com/hasaneyldrm/exercises-dataset/main/README.md#L62-L94】.
Filtering by Equipment Type
To retrieve exercises that require specific equipment, use the Array.filter() method on the equipment field:
// Find all body-weight exercises
const bodyweight = exercises.filter(ex => ex.equipment === 'body weight');
console.log(`Found ${bodyweight.length} body-weight exercises`);
Grouping by Category
You can organize exercises by body part or category using Array.reduce() to build a lookup map:
const byCategory = exercises.reduce((map, exercise) => {
const key = exercise.category || exercise.body_part;
(map[key] = map[key] || []).push(exercise);
return map;
}, {});
// Display counts per category
Object.entries(byCategory).forEach(([category, list]) => {
console.log(`${category}: ${list.length} exercises`);
});
Accessing Multilingual Instructions
Each exercise contains localized instructions accessible via the instructions object. Retrieve specific languages using dot notation:
const firstExercise = exercises[0];
console.log('Exercise:', firstExercise.name);
console.log('English:', firstExercise.instructions.en);
console.log('Spanish:', firstExercise.instructions.es);
Validating Data Integrity
While the dataset is pre-validated, you can enforce schema compliance at runtime using the data/exercises.schema.json file. Install a JSON Schema validator like ajv to check imported data before processing:
const Ajv = require('ajv');
const ajv = new Ajv();
const schema = require('./data/exercises.schema.json');
const validate = ajv.compile(schema);
const isValid = validate(exercises);
if (!isValid) console.error('Validation errors:', validate.errors);
Summary
- The hasaneyldrm/exercises-dataset repository provides
data/exercises.json, a ready-to-use array of 1,324 fitness exercises. - Import the dataset using
require('./data/exercises.json')for synchronous loading in CommonJS modules. - Each exercise object includes
category,equipment,instructions(multilingual), and media URLs. - Filter records by equipment or body part using standard
Array.filter()and group results withArray.reduce(). - Reference
data/exercises.schema.jsonto validate data structure when building strict TypeScript interfaces or API contracts.
Frequently Asked Questions
What is the structure of the exercises dataset?
The dataset is a single JSON array containing 1,324 objects, where each object represents a fitness exercise with fields for id, name, category, equipment, multilingual instructions, and media assets. The structure is formally defined in data/exercises.schema.json and documented in the repository README【/cache/repos/github.com/hasaneyldrm/exercises-dataset/main/README.md#L72-L99】.
How do I filter exercises by equipment type in Node.js?
After requiring the JSON file, chain the filter() method to the exercises array: exercises.filter(ex => ex.equipment === 'dumbbell'). This returns a new array containing only exercises matching your equipment criteria, such as "body weight", "cable", or "barbell".
Can I use ES6 import syntax instead of require?
Yes, but you must use dynamic import with JSON assertions: await import('./data/exercises.json', { assert: { type: 'json' } }). Alternatively, rename your file to use the .mjs extension or set "type": "module" in your package.json to enable ES module syntax.
How do I validate the dataset against its schema?
Load the data/exercises.schema.json file alongside your dataset, then use a validator library like ajv to compile the schema and test the exercises array. This ensures your application handles only properly structured records, catching any corruption or version mismatches before runtime processing.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →