Skip to content
On this page

TrainHeroic API documentation

Use the unofficial TrainHeroic API with a TypeScript SDK, CLI or MCP server. Learn authentication, read workout history, and build coach programming integrations.

Build a TrainHeroic integration with an unofficial TypeScript API client, command-line tool, or MCP server. The toolkit uses the undocumented endpoints behind TrainHeroic’s apps and signs in with an existing TrainHeroic account. This is a community project, unaffiliated with TrainHeroic.

API access and authentication

You authenticate with your TrainHeroic email and password rather than an API key issued by this project. The SDK acquires a session token on the first request and signs in again once after a 401 or 403. Keep credentials in environment variables when using the SDK or CLI. The hosted MCP server handles sign-in through an OAuth connection.

Your account determines access: athletes can read their own training and log results; coaches also have roster, programming, analytics, and messaging tools. See the capability reference for supported operations and confirmation rules.

Choose an API client

The toolkit has four entry points over the same TrainHeroic client and typed data shapes. Pick the one that matches who drives the work, and the page shows that surface’s first request.

If you need to… Start with…
Ask Claude Code to work with your account Claude Code skill
Run repeatable shell commands or emit JSON CLI
Build an application or automation TypeScript SDK
Connect an AI client to typed tools MCP server

First request with the skill

The skill teaches Claude Code the TrainHeroic workflows and runs the CLI for each step.

$ npx skills add alandotcom/trainheroic-unofficial
$ export TRAINHEROIC_EMAIL=coach@example.com
$ export TRAINHEROIC_PASSWORD=yourpassword
$ claude

Ask for last week’s training.

Read the skill guide for the athlete variant and the version-matched reference.

First request with the CLI

Every command prints JSON to stdout, so you can pipe it into jq or another program.

$ npm install -g @trainheroic-unofficial/cli
$ export TRAINHEROIC_EMAIL=athlete@example.com
$ export TRAINHEROIC_PASSWORD=yourpassword
$ trainheroic athlete workouts --start 2026-08-01 --end 2026-08-31

Read the CLI guide for coach commands, JSON input, and confirmation flags.

First request with the SDK

npm install @trainheroic-unofficial/js
pnpm add @trainheroic-unofficial/js
yarn add @trainheroic-unofficial/js
bun add @trainheroic-unofficial/js
nub add @trainheroic-unofficial/js
aube add @trainheroic-unofficial/js
import { TrainHeroicClient, fetchAthleteProfileSummary, resolveAthleteUserId } from "@trainheroic-unofficial/js";

const client = new TrainHeroicClient(process.env.TRAINHEROIC_EMAIL!, process.env.TRAINHEROIC_PASSWORD!);

const userId = await resolveAthleteUserId(client);
console.log(await fetchAthleteProfileSummary(client, userId));

Read the SDK guide for auth behavior, the exercise library, workout building, and analytics.

First request over MCP

Add the hosted server to Claude Code. It opens the TrainHeroic sign-in the first time a tool runs.

$ claude mcp add trainheroic --transport http https://mcp.trainheroic-unofficial.com/mcp

Ask through the connected tools.

Read the MCP guide for other clients, role-scoped endpoints, and local stdio servers.

How the pieces fit

Every surface reuses the layer below it, so a fix in the SDK reaches the CLI and every MCP server in the same release.

Read the docs from scripts and coding agents

Use the Markdown documentation index to find setup and API guides. These files describe the toolkit; accessing them does not sign in to TrainHeroic or expose account data.

If a documentation request returns HTTP 403 with Cloudflare error 1010, send a descriptive user agent identifying your application:

$ curl -A "my-trainheroic-docs-client/1.0" https://trainheroic-unofficial.com/llms.txt

Cloudflare documents this behavior for non-browser clients in its error 1010 guide. An error from the TrainHeroic API itself is a separate authentication or upstream problem.

Runtime requirements

Published packages require Node 18 or a modern runtime with fetch and Web Crypto. Developing the monorepo itself requires Node 24 and pnpm 11.