TypeScript SDK
Authenticate with TrainHeroic and call the runtime-agnostic TypeScript client.
@trainheroic-unofficial/js provides the client, auth renewal, exercise library, workout
builder, athlete reads, analytics, and messaging helpers.
Install
npm install @trainheroic-unofficial/jspnpm add @trainheroic-unofficial/jsyarn add @trainheroic-unofficial/jsbun add @trainheroic-unofficial/jsRequires global fetch and Web Crypto: Node 18+, Cloudflare workerd, or a modern browser.
Create a client
import { TrainHeroicClient } from "@trainheroic-unofficial/js";
const client = new TrainHeroicClient(
process.env.TRAINHEROIC_EMAIL!,
process.env.TRAINHEROIC_PASSWORD!,
);
const response = await client.request<{ id: number }>("GET", "/user/simple");
if (response.ok) {
console.log(response.data.id);
}
The client signs in lazily on the first request. If a request returns 401 or 403, it signs in again once and retries. Concurrent requests on a cold client share one login.
Two entry points
import { TrainHeroicClient, ExerciseLibrary, buildSession } from "@trainheroic-unofficial/js";import { JsonFileLibraryCache, defaultCachePath } from "@trainheroic-unofficial/js/node";The main entry imports no node:* modules. Filesystem-backed caching stays behind ./node so
the same SDK can run inside Cloudflare Workers.
Guides
Exercise library
Resolve names to ids and persist the library locally.
Build workouts
Create draft sessions, prescribe sets, and publish deliberately.
Read athlete training
Query profiles, workouts, lift history, PRs, and working maxes.
Query analytics
Pull readiness, compliance, volume, and lift-progress reports.