Workout Generation API¶
Generate Workout¶
This endpoint generates AI-powered personalized workout recommendations based on user metadata and preferences.
Endpoint¶
URLs:
- Development:
https://api.rex.fit/[org-id]/dev/v1/generate-workout - Production:
https://api.rex.fit/[org-id]/prod/v1/generate-workout
Method: POST
Content-Type: application/json
Authorization: Bearer <api_key>
Request Fields¶
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
metadata |
object | Yes | Collection of parameters to tailor the workout | See below |
workout_description |
string | No | Free-form description of desired workout | "Beginner yoga routine focusing on flexibility" |
user_id |
string | No | Identifier to associate request with a user | "abc123" |
Metadata Object¶
The metadata object can include various parameters to customize the workout:
| Field | Type | Description | Example |
|---|---|---|---|
level |
string | Fitness level | "beginner", "intermediate", "advanced" |
duration |
string | Workout duration | "30m", "45m", "60m" |
equipment |
string | Available equipment | "basic", "full gym", "dumbbells only", "no equipment" |
target_muscles |
array | Target muscle groups | ["back", "biceps"] |
focus_area |
string | Primary focus area | "upper body", "legs", "core" |
Example Request¶
{
"metadata": {
"level": "beginner",
"duration": "30m",
"equipment": "basic",
"target_muscles": ["back", "biceps"],
"focus_area": "upper body"
},
"workout_description": "Beginner routine focusing on flexibility and relaxation.",
"user_id": "abc123"
}
Response¶
Success (200 OK):
{
"status": "success",
"workout_link": "https://[org-subdomain]/trainings/core-training",
"name": "Core Training",
"description": "Tatyana Minkovskaya's 'Core Training' workout focuses on strengthening the core of the body. The program is designed to improve stability and strength of the abdominal muscles, as well as the muscles of the lower back and pelvis. This workout is suitable for people of all levels and aims to improve overall physical fitness and functionality.",
"coach": "Tatyana Minkovskaya",
"type": "Core Training",
"duration": "27",
"target_group": "Men and Women",
"exercises": "Warm-up, 2 sets of 3 exercises for the entire abdomen, 12 reps each - V press, scissors and leg lifts through bent legs to a candle, 2 sets of 3 exercises for the side of the abdomen - plank with lifting the leg back and to the sides, side plank with lifting and side plank with bringing the leg and arm together, stretching after each exercise, 2 sets of 3 exercises for the lower abdomen - V press to the sides, plank with rotation to the sides, wheel with touching the elbow to the knee. The workout ends with stretching.",
"purpose": "Tightening",
"muscle_groups": "Abdomen",
"physical_level": "never worked out"
}
Response Fields¶
| Field | Type | Description |
|---|---|---|
status |
string | Result status ("success" or "error") |
workout_link |
string | URL to the full workout details |
name |
string | Name of the workout program |
description |
string | Detailed description of the workout |
coach |
string | Name of the coach who created the workout |
type |
string | Type or category of the workout |
duration |
string | Estimated duration in minutes |
target_group |
string | Intended audience for the workout |
exercises |
string | Detailed description of included exercises |
purpose |
string | Main goal or purpose of the workout |
muscle_groups |
string | Primary muscle groups targeted |
physical_level |
string | Recommended fitness level |
Error Responses¶
| Code | Description | Example |
|---|---|---|
| 400 Bad Request | Missing or invalid required fields | {"error": "Missing required field: metadata"} |
| 500 Internal Server Error | Failed to generate recommendation | {"error": "Failed to generate workout recommendation"} |
Physical Levels¶
The physical_level field in the response indicates the recommended experience level:
"never worked out"- Complete beginners"beginner"- Some exercise experience"intermediate"- Regular exercise routine"advanced"- Experienced fitness enthusiasts
Usage Notes¶
- Metadata is Required: The
metadataobject is mandatory for generating targeted workouts - AI-Powered: Recommendations are generated using an AI assistant that analyzes provided metadata
- Comprehensive Details: Response includes everything needed to display workout information in fitness applications
- Video Access: The
workout_linkprovides access to full workout details, including videos and additional instructions - Flexible Parameters: Mix and match metadata fields to create highly customized workout recommendations
Integration Tips¶
- Use the
user_idto track workout recommendations per user - Display the comprehensive workout details in your app interface
- Link to the
workout_linkfor full workout videos and instructions