Docs› Coverage› Pricing› Status› Support›
  1. Home
  2. Documentation
  3. Node

Greyhound racing API: Node

Node

Call the greyhound racing API from Node with fetch, with polling and paging.

Node

Node 18 and later have fetch built in. Keep the key in an environment variable.

Poll today's results
const H = { "X-API-Key": process.env.KEY };
const hhmm = () => new Date().toISOString().slice(11, 16);
let since = hhmm();

setInterval(async () => {
  const r = await fetch(`https://api.greyhoundracingapi.com/v1/results/today?since=${since}`, { headers: H });
  if (r.status === 429) return;
  since = hhmm();
  for (const race of (await r.json()).data)
    console.log(race.track_name, race.no, race.result[0]?.runner);
}, 90_000);

CSV instead

Add .csv to the path and read the body as text: one row per runner, race fields repeated on each row.