SnookerAPI
Documentation / Guides

Snooker API live scores

Live scores

Following matches as they are played: one match, the feed, and the stream.

While an event is being played, every change we take in becomes a live event: match.started (a score first appears), frame.won (the frames won go up), match.finished (a winner) and century.made. We look for changes every five minutes, so an event usually reaches you within a few minutes of it happening; every live answer says how fresh it is in meta.seconds_behind and meta.poll_seconds.

Three ways to follow them, on every plan:

  • GET /v1/matches/{match_id}/live: one match as it stands, its frames won and its latest events.
  • GET /v1/live/events: the feed itself. Keep meta.next_since and send it back as since to carry on where you were.
  • GET /v1/stream: the same feed pushed to you as Server-Sent Events. A connection holds for five minutes, then reconnects by itself from the last event, so nothing is missed.

From a server, send the key in a header as usual:

curl -N -H "Authorization: Bearer $SNOOKER_KEY" "https://api.snookerapi.net/v1/stream?types=frame.won,match.finished"

In a browser, EventSource cannot send a header, so ask your server for a token with GET /v1/stream/token and open the address it gives:

const es = new EventSource(url);   // https://api.snookerapi.net/v1/stream?token=st_...
es.addEventListener('frame.won', e => board.frame(JSON.parse(e.data)));
es.addEventListener('match.finished', e => board.final(JSON.parse(e.data)));

A key can hold three streams open at once. To have the events posted to your app instead, see Webhooks.