Skip to main content

Overview

The BodyWorks API provides access to a comprehensive fitness database with over 1300+ exercises and 600+ workout routines. This free, public API allows developers to build fitness applications without authentication requirements.

What You Can Access

  • 1300+ Exercises - Browse and search exercises with detailed information
  • 30+ Equipment Types - Filter exercises by available equipment
  • 20 Target Muscles - Find exercises for specific muscle groups
  • 10 Body Parts - Organize workouts by body part
  • 600+ Routines - Pre-built workout routines from 1 week to 52 weeks

Base URL

The API base URL is configured through an environment variable. By default, it uses:
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:3000/api/";
Set NEXT_PUBLIC_API_BASE_URL in your environment to point to the BodyWorks API server.

Response Format

All API responses are returned in JSON format with a consistent structure:
{
  "data": [
    // Array of resources
  ],
  "pagination": {
    "currentPage": 1,
    "totalPages": 10,
    "totalItems": 100,
    "limit": 10
  }
}

Available Endpoints

The BodyWorks API provides the following main endpoints:
EndpointDescriptionSupports Pagination
/exercisesGet all exercisesYes
/bodyPartsGet all body partsYes
/equipmentsGet all equipment typesYes
/targetMusclesGet all target musclesYes
/routinesGet all workout routinesYes
/routineCategoryGet routine categoriesYes

Query Parameters

Most endpoints support the following query parameters:
limit
number
default:"9"
Number of items to return per page
page
number
default:"1"
Page number for pagination

Making Requests

The API uses axios for HTTP requests. Here’s how the API client is configured:
lib/apiCaller.ts
import axios, { AxiosInstance } from "axios";

export const API_BASE_URL =
  process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:3000/api/";

interface ApiConfig {
  baseURL: string;
}

export const createApi = ({ baseURL }: ApiConfig): AxiosInstance => {
  if (!baseURL) {
    throw new Error("API baseURL is required");
  }
  return axios.create({
    baseURL,
  });
};

export const apiCaller: AxiosInstance = createApi({ baseURL: API_BASE_URL });

Example Request

Here’s a practical example of fetching exercises with pagination:
import { apiCaller } from "@/lib/apiCaller";

const getExercises = async (
  limit: number,
  page: number
): Promise<IExerciseData> => {
  const exercises = await apiCaller.get<IExerciseData>("/exercises", {
    params: {
      limit,
      page,
    },
  });
  return exercises.data;
};

// Fetch first page with 9 exercises
const data = await getExercises(9, 1);

Error Handling

The API client includes built-in error handling. If the base URL is not configured, it will throw an error:
if (!baseURL) {
  throw new Error("API baseURL is required");
}

Common Error Responses

error
object
Error information when a request fails
message
string
Human-readable error message
status
number
HTTP status code

Rate Limiting

The BodyWorks API is a free public API. Check the Body Works API repository for current rate limiting policies.

Next Steps

Authentication

Learn about API access and configuration

Exercises

Explore exercise endpoints

Routines

Browse workout routines

Body Parts

Filter by body parts

Build docs developers (and LLMs) love