The official JavaScript / TypeScript client for the WorkoutX API. API v2 brings 1,900+ exercises as 2,700+ clips: 720p MP4 animations at 30 fps with male and female models, step-by-step instructions, form tips and anatomical muscle names. The AI Workout Generator, supplements and the Body Scan API come in the same fully typed client, for Node.js and the browser. Zero runtime dependencies.
✓ Live on npm — npmjs.com/package/@workoutx/sdk · works in Node.js 18+ and modern browsers.
Create one client with your API key and use wx.v2. The SDK sends the key in the X-WorkoutX-Key header, the only place v2 accepts it. The same client also covers the v1 resources and the Body Scan API (user JWT).
TypeScript types for every v2 response: ExerciseV2, MediaLinks, V2RankedPage, WorkoutV2 and the rest. Autocomplete in your editor means no more guessing field names.
freshMedia(id) reuses the signed links from earlier calls until about 5 minutes before they expire, then fetches new ones. You store exercise ids; the SDK keeps the links valid.
Automatic retries with backoff on rate limits (429) and 5xx, honoring Retry-After. A used-up quota is not retried. Structured WorkoutXError with status, code and tips.
Every v2 exercise has media.mp4, a 600×720 loop at 30 fps (usually 100–300 KB), and media.poster, a JPEG still frame. Play the MP4 muted and looping: browsers only autoplay muted video, and playsinline keeps it in the page on iPhone. On the Free plan both are 300×360 watermarked previews (media.watermarked is true).
Media links are signed, expire after about 24 hours and contain no API key, so your server can hand them to the browser. Store exercise ids, never media URLs, and call freshMedia(id) when you show an exercise: it reuses the links the SDK already has and asks the API again only when they're close to expiry.
Downloading the files or serving them from your own servers or CDN isn't permitted on any plan. See Media in v2 for formats and limits.
Male and female versions are separate exercises. counterpartId points at the same movement with the other model, so you can offer a switch, and model filters a list to one of them. lang returns names, instructions, tips and muscles in Turkish (tr), German (de), Spanish (es), French (fr), Simplified Chinese (zh-SG) or Traditional Chinese (zh-HK). English is the default; filter values stay in English.
Similar exercises, alternatives with other equipment and calorie estimates, on v2 ids. Ranked results are full v2 exercises with media links plus a score, and never include the exercise itself or its other-model clip. All three take lang.
v2.workout.generate() returns one session from the rule-based workout engine: a warm-up, exercises grouped into blocks (straight sets, supersets such as C1/C2, or one circuit) with sets, reps or a duration, rest, effort (rir) and swap alternatives, then a cool-down. Every exercise in it, warm-up and cool-down items included, is a full v2 exercise with media links, and model picks the male or female clips. avoidJoints (knee, shoulder, lumbar_spine, elbow, wrist, hip, ankle) leaves out movements that load those joints heavily; it is general guidance, not medical advice. format picks straight, superset or circuit (default auto). The response carries estimatedDurationMinutes and the seed it used; pass the seed back to get the same workout. v2.workout.program() returns a schedule, the week-by-week program and an exerciseLibrary that its exercises reference by exerciseId. The generator needs Growth or Scale (legacy Pro, Ultra); multi-week programs need Scale (legacy Ultra).
The evidence-graded supplement database in the v2 page shape, { total, limit, offset, results, disclaimer }. Growth and Scale (legacy Pro, Ultra); stacks need Scale (legacy Ultra). Informational content only, not medical advice. Supplement text is English.
Narrow v2.list() by the joint a movement works through, an intensity band and descriptive tags, for physical therapy, mobility and senior-fitness apps. Growth and Scale (legacy Ultra). These are descriptive fields, not medical recommendations.
v1 keeps working on the same key, and you'll get at least 30 days' notice before it's retired. The SDK's v1 resources (exercises, gifs, workout, supplements) are unchanged, so you can move one screen at a time. Map each v1 id you've stored once with v2.legacy() and save the v2 id: 1,324 of the 1,327 v1 exercises have a v2 match.
Step by step, with code for each platform: the v2 migration guide.
Every non-2xx response throws a WorkoutXError with status, code, message, tip and the parsed body. A feature your plan doesn't include answers 403 and names the plan that has it. A 429 is either a rate limit, which the SDK retries with backoff, or a used-up request quota, which it doesn't retry. The Free plan's 500 requests are a one-time allowance.
Run npm install @workoutx/sdk (or pnpm/yarn). It works in Node.js 18+ and modern browsers, ships with TypeScript types, and API v2 lives under wx.v2.
Put media.mp4 in a <video> element with autoplay loop muted playsinline and use media.poster as the poster. The MP4s are 600×720 at 30 fps; the Free plan gets 300×360 watermarked previews.
No. Media links are signed and expire after about 24 hours. Store the exercise id and call wx.v2.freshMedia(id) when you show the exercise; it reuses links until they're close to expiry. Downloading or self-hosting the files isn't allowed on any plan.
Yes. The SDK uses the native fetch API, so it runs in Node.js 18+, Deno, Bun, edge runtimes, and browsers without polyfills. For public web apps, keep the API key on your server and send the page only the media links.
Yes. wx.exercises, wx.gifs, wx.workout and wx.supplements still call v1, which keeps working; you'll get at least 30 days' notice before it's retired. wx.v2.legacy(v1Id) maps the v1 ids you've stored to v2.
Create a free account in the Developer Portal and copy your wx_... key. Pass it as apiKey when constructing the client. The Free plan includes 500 requests in total with watermarked previews; paid plans start at $19 a month.
Body Scan uses a logged-in user's JWT. Pass scan: { token }, or scan: { email, password } to let the SDK log in automatically and cache the token.
In public frontend code, anyone can read your API key. For browser apps, call WorkoutX from your own backend and send the page only the data and media links it needs. v2 accepts the key only in the X-WorkoutX-Key header, which the SDK sets for you.
media.mp4 and media.poster are signed links that expire after about 24 hours. They contain no API key, so they're safe to put in a page. Store exercise ids, not links. (v1's gifUrl() still puts the key in the URL.)
The Body Scan email/password auto-login should only run server-side. In clients, pass a short-lived scan.token obtained from your backend instead.
Start free with 500 requests and watermarked previews. 1,900+ exercises as 720p video, workouts, and Body Scan in one SDK.
Get your free API key