Build a Typed Training Data Client in TypeScript with intervals-icu
If your training dashboard starts as one HTTP request and grows into athletes, activities, wellness, workouts, gear, and performance data, a hand-written fetch wrapper becomes expensive to maintain. Every new endpoint adds another URL, another response shape, and another place to get authentication or retry behavior wrong. This tutorial shows a small, reproducible path with intervals-icu , an open-source TypeScript client for the Intervals.icu API . The goal is not to build a complete training application. It is to establish a typed client, choose the right authentication boundary, call one service, and understand what changes when you move from version 1 to version 2 of the library. TL;DR Install the stable npm package, create an IntervalsClient with an API key or OAuth access token, and use service accessors such as client.athletes or client.activities. Version 2 uses typed service methods, retries selected transient failures, and defaults requests to the authenticated athlete. Prerequisites You need: Node.js 18 or newer. npm. An Intervals.icu account with an API key, or an OAuth access token for an application acting for other users. A TypeScript project that can run ESM modules. The published package is intervals-icu version 2.2.1, and its package metadata declares Node.js >=18.0.0. The repository is public and licensed under MIT. The examples below target that stable package version, not an unreleased default-branch change. Install the stable client Create a small project and pin the package version used in this tutorial: mkdir intervals-demo cd intervals-demo npm init -y npm install intervals-icu@2.2.1 npm install -D typescript tsx The package publishes both ESM and CommonJS entry points and exposes TypeScript declarations from its package root. Add a script so a .ts file can run without a separate build step: { "type" : "module" , "scripts" : { "start" : "tsx src/index.ts" } } Create the smallest useful client Create src/index.ts. Keep the credential outside