Skip to content
On this page

Command-line interface

Install the trainheroic CLI, sign in with environment variables, and run coach and athlete commands that print JSON for scripts and agents.

The CLI is designed for terminals, scripts, and AI agents. Successful commands print JSON to stdout; failures write to stderr and exit nonzero.

Install

$ npm install -g @trainheroic-unofficial/cli
$ npx @trainheroic-unofficial/cli whoami

Authenticate

The CLI reads your TrainHeroic login from two environment variables and signs in on the first command.

$ export TRAINHEROIC_EMAIL=coach@example.com
$ export TRAINHEROIC_PASSWORD=yourpassword
$ trainheroic whoami

Common commands

$ trainheroic coach athletes
$ trainheroic coach teams
$ trainheroic coach programs
$ trainheroic coach exercise resolve "Back Squat"
$ trainheroic coach message list
$ trainheroic athlete profile
$ trainheroic athlete workouts --start 2026-08-01 --end 2026-08-31
$ trainheroic athlete export

Run trainheroic with no arguments for the full command tree.

Compose with other tools

Because every result is JSON, you can redirect it to a file or pipe it into jq and other programs. athlete export writes a folder of files, and --out chooses where it goes.

$ trainheroic coach athletes > roster.json
$ trainheroic athlete working-maxes | jq .
$ trainheroic athlete export --out ./training-history

Input and confirmation

Workout specs and other JSON inputs can be passed inline, read from --file, or piped on stdin. Inputs are validated against the shared DTO schemas before the request is sent.

Actions that publish, delete, send, archive, or write athlete results require --yes. Building a draft does not; building and publishing in one command does.

$ trainheroic coach workout build --program 12345 --date 2026-08-17 --file squat.json
$ trainheroic coach workout publish --pw 67890 --yes