Quickstart
Install the SDK, set an API key, and make your first call. The SDK is a thin typed wrapper over the REST API — anything you can do with curl you can do with it, plus typed errors and SSE iteration.
#1. Install
npm install @closeline/sdk
# or
pnpm add @closeline/sdk#2. Get an API key
Sign in and copy your key from the account settings page. Keep it server-side — never commit it or ship it to a browser bundle. See Authentication for rotation + TTL details.
#3. First call
import { Closeline } from "@closeline/sdk";
// The client reads CLOSELINE_API_KEY from the environment by default.
const cl = new Closeline({ apiKey: process.env.CLOSELINE_API_KEY! });
// Today's slate, NBA only.
const today = await cl.games.today({ league: ["nba"] });
for (const game of today.data) {
console.log(game.scheduled_at, game.away.abbr, "@", game.home.abbr);
}#4. Pull a brief
// Pull the latest structured brief for a game (Lite+ tier).
const brief = await cl.games.brief(gameId);
console.log(brief.brief_md); // markdown rendering of the brief#5. Subscribe to the feed
The stream is lazy — the HTTP request is issued the first time you iterate the generator, and closed when the loop exits.
// Subscribe to the realtime event feed (Pro+ tier).
for await (const ev of cl.stream({ events: ["signal.fired", "live.signal"] })) {
console.log(ev.event, ev.data);
}