Changelog

Changelog

Call the API from TypeScript

  • Install & API
Share on X
stats.ts
import { createApi } from "highseat/api"const api = createApi({ token: process.env.HIGHSEAT_API_KEY })const { data } = await api.getOverview({ site: "example.com", period: "30d" })for await (const row of api.paginate.getPages({ site: "example.com" })) {  console.log(row.path, row.visitors)}

highseat/api is a typed client for the Highseat API. Every endpoint is a method named after what it does, such as getOverview(), getPages() or createNote(). Its parameters and its answer are typed from the API itself, so your editor completes them and a wrong parameter fails to compile.

A list comes back in pages. api.paginate walks every page for you in a for await loop, and .toArray() collects them all.

The client handles the API's limits too. When the API refuses a call and asks for a wait of a few seconds, the client waits and tries once more. Every create carries an idempotency key, so that second try never creates a second row.

It uses plain fetch and has no dependencies, so it runs in Node.js, Bun and Cloudflare Workers. Update the highseat package to 0.10.0 or later to get it.

Older entry

Connect Claude to Highseat by signing in

Read entry

Follow the changelog

New entries in your feed reader, or on X.

Start with 14 days free.No card required.