Streaming

A single long-lived Server-Sent Events connection that delivers the same envelope shape as outgoing webhooks — handy for CLI tooling, dashboards, or anywhere you don't want to host a public webhook endpoint.

#Endpoint

GET/api/v1/stream
Auth requiredPro
Response content type is text/event-stream. The connection stays open until the client closes it or the server restarts.

Query parameters

eventsstring[]optional
CSV of event-type names. Unknown names are silently dropped.
gamesstring[]optional
CSV of game ids.
sportsstring[]optional
CSV of league keys.
teamsstring[]optional
CSV of team ids; matches any event whose data.team_ids intersects.
min_strengthnumberoptional
Decimal in [0, 1]. Out-of-range values are silently dropped.
bash
curl -N "https://api.closeline.io/v1/stream?events=signal.fired,live.signal" \
  -H "Authorization: Bearer $CLOSELINE_API_KEY" \
  -H "Accept: text/event-stream"

#Frame format

Standard SSE:

text
id: evt_01HXY...
event: signal.fired
data: {"id":"evt_01HXY...","type":"signal.fired","created_at":"2026-04-17T22:10:03Z","data":{}}

  • On connect the server emits a single :connected request_id=… comment so proxies commit the 200.
  • A keep-alive comment ships every 25s to keep nginx/CF from reaping the connection.
  • ev.data is parsed JSON where possible; the SDK falls back to the raw string if parsing fails.

#Event types

  • brief.published
  • brief.regenerated
  • brief.superseded
  • signal.fired
  • signal.fired.highstrength
  • live.signal
  • live.injury
  • live.state
  • line.material_move
  • game.lineup_confirmed
  • game.started
  • game.final
  • methodology.top_match

#SDK

ts
import { Closeline } from "@closeline/sdk";

const cl = new Closeline({ apiKey: process.env.CLOSELINE_API_KEY! });

const ac = new AbortController();
setTimeout(() => ac.abort(), 60_000); // stop after 60s

for await (const ev of cl.stream({
  events: ["signal.fired", "signal.fired.highstrength"],
  games: [gameId],
  signal: ac.signal,
})) {
  // ev.event — event type string
  // ev.data  — parsed JSON payload (falls back to raw string on parse failure)
  console.log(ev.event, ev.data);
}

The SDK stream is lazy — the HTTP request is issued only when the returned async iterator is first iterated, and the underlying connection closes when the loop exits or the AbortSignal aborts. See Webhooks for the push-based alternative.