Injury report alerts for your teams in Discord or Slack

A small Node.js script that checks the league's injury report change feed every 10 minutes and posts a line to your Discord or Slack channel when a player on your teams is added to the report, taken off it, or moves between designations. Fantasy players and team communities use it to hear about game-time decisions without refreshing a site.

Stack
Node.js 18+, Discord or Slack webhook
Plan
Free for a few checks a day; checking every 10 minutes (144 calls a day) needs the trial or a paid plan
Code
injury-alerts/ (MIT)

The live parts of this guide (games in progress) need the free 7-day Starter trial, no card, or a paid plan on Free keys created from November 9, 2026. Schedules, upcoming games and final scores work on Free. Start the trial

Updated 2026-11-23. Tested against the live API on that date. Data is aggregated from public sources and is typically 20-30 seconds behind live play (about 1 second after our source). There is no SLA.

1. Get a free API key

Sign up (no card) and copy the key from the dashboard. The Free plan gives you 1,000 calls in the first 30 days, then 125 a month, at 1 request per second. Every successful REST call counts as one call.

Check the key works with one call to the live-scores endpoint:

Terminal

export REALTIME_SPORTS_API_KEY=your_key
curl -H "Authorization: Bearer $REALTIME_SPORTS_API_KEY" \
  "https://www.realtimesportsapi.com/api/v1/sports/football/leagues/nfl/events/live"

2. Get the code

Everything below is in the injury-alerts/ folder of the examples repo (MIT). Clone it and work from that folder.

Terminal

git clone https://github.com/ElcoDevRepos/realtime-sports-api-examples
cd realtime-sports-api-examples/injury-alerts

3. Make a webhook

Discord: Server Settings, Integrations, Webhooks, New Webhook, pick the channel, Copy Webhook URL. Slack: create an incoming webhook for the channel. Put the URL in .env as WEBHOOK_URL, next to your API key. Leave it empty and the script prints the alerts instead.

Terminal

cp .env.example .env    # REALTIME_SPORTS_API_KEY, WEBHOOK_URL

4. How it works

The availability history endpoint is a feed of changes to the league's injury report, newest first. Each row has the player, team, the normalized designation (OUT, QUESTIONABLE, DAY_TO_DAY…), the team's note, the expected return date and a changeType: new, change or cleared; most change rows also carry previousAvailability. The script asks for everything since the newest change it has already seen, keeps your teams, and stores that timestamp in .injury-alerts-state.json so a restart never repeats an alert.

Many change rows only update the note or the return date while the designation stays the same, so by default the script alerts on additions, removals and designation changes only. --all sends every update. Lines are batched into posts under Discord's 2,000-character limit; Slack webhooks get the same text.

injury-alerts/injury-alerts.mjs

#!/usr/bin/env node
// Injury report alerts: post NFL / NBA / NHL availability changes for your teams to a Discord or Slack
// webhook (or just print them). Node 18+, no dependencies.
//
// Reads GET /sports/{sport}/leagues/{league}/player-availability/history?since=… (newest first). By default it
// alerts when a player is added to the report, comes off it, or their designation changes (e.g. QUESTIONABLE ->
// OUT); --all also sends updates where only the note or return date changed.
//
//   node injury-alerts.mjs --league nfl --team KC,BUF            # poll every 10 minutes
//   node injury-alerts.mjs --league nba --since 24h --dry-run    # print the last day's changes, no webhook
//   node injury-alerts.mjs --league nhl --once                   # one check (for cron)
//
// Env: REALTIME_SPORTS_API_KEY (required), WEBHOOK_URL (Discord or Slack incoming webhook; omit to print only).
// Cost: one call per league per check (10-minute polling = 144 calls a day per league).
import { readFileSync, writeFileSync, existsSync } from "node:fs";

const API = process.env.RSA_API_BASE || "https://www.realtimesportsapi.com/api/v1";
const SPORT = { nfl: "football", nba: "basketball", nhl: "hockey" };
const STATE = new URL("./.injury-alerts-state.json", import.meta.url);

function loadDotenv() {
  for (const f of [new URL("./.env", import.meta.url), `${process.cwd()}/.env`]) {
    if (!existsSync(f)) continue;
    for (const line of readFileSync(f, "utf8").split("\n")) {
      const m = /^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)\s*$/.exec(line);
      if (m && !(m[1] in process.env)) process.env[m[1]] = m[2].replace(/^['"]|['"]$/g, "");
    }
  }
}

function args(argv) {
  const a = { league: "nfl", teams: [], every: 10, since: "1h", once: false, dryRun: false, all: false };
  for (let i = 0; i < argv.length; i++) {
    const k = argv[i], v = argv[i + 1];
    if (k === "--league") a.league = v, i++;
    else if (k === "--team") a.teams = v.split(",").map((s) => s.trim().toUpperCase()), i++;
    else if (k === "--every") a.every = Number(v), i++;
    else if (k === "--since") a.since = v, i++;
    else if (k === "--once") a.once = true;
    else if (k === "--dry-run") a.dryRun = true;
    else if (k === "--all") a.all = true;
  }
  if (!SPORT[a.league]) throw new Error(`--league must be one of ${Object.keys(SPORT).join(", ")}`);
  return a;
}

/** "24h" / "90m" / ISO date -> ISO timestamp */
export function sinceToIso(s, now = Date.now()) {
  const m = /^(\d+)([hm])$/.exec(s);
  return m ? new Date(now - Number(m[1]) * (m[2] === "h" ? 3600e3 : 60e3)).toISOString() : new Date(s).toISOString();
}

async function api(path, key) {
  const r = await fetch(API + path, { headers: { Authorization: `Bearer ${key}` } });
  const j = await r.json().catch(() => ({}));
  if (!r.ok) throw new Error(`HTTP ${r.status} ${j.error?.code ?? ""}: ${j.error?.message ?? ""}`);
  return j;
}

/** Abbreviation -> team id, so --team KC works (the history rows carry teamId and teamName). */
async function teamIds(sport, league, abbrs, key) {
  if (!abbrs.length) return null;
  const j = await api(`/sports/${sport}/leagues/${league}/teams?limit=200`, key);
  const ids = new Set();
  for (const t of j.data ?? []) if (abbrs.includes(String(t.abbreviation).toUpperCase())) ids.add(String(t.id));
  if (ids.size !== abbrs.length) console.warn(`warning: matched ${ids.size} of ${abbrs.length} teams (${abbrs.join(",")})`);
  return ids;
}

/** Which rows are worth an alert. */
export function interesting(row, all = false) {
  if (all) return true;
  if (row.changeType === "new" || row.changeType === "cleared") return true;
  return row.changeType === "change" && row.previousAvailability && row.previousAvailability !== row.availability;
}

const pretty = (s) => String(s ?? "").replace(/_/g, " ").toLowerCase().replace(/\b\w/g, (c) => c.toUpperCase());
export function format(row) {
  const who = `${row.name}${row.position ? ` (${row.position})` : ""}, ${row.teamName}`;
  if (row.changeType === "cleared") return `✅ ${who}: off the injury report`;
  const what = row.changeType === "new" ? `added as ${pretty(row.availability)}` :
    row.previousAvailability && row.previousAvailability !== row.availability ? `${pretty(row.previousAvailability)} → ${pretty(row.availability)}` : `still ${pretty(row.availability)} (update)`;
  const note = row.detail && row.detail !== "Not Specified" ? `\n> ${row.detail}` : "";
  const back = row.returnDate ? ` · expected back ${row.returnDate}` : "";
  return `🩹 ${who}: ${what}${back}${note}`;
}

/** Discord wants {content}, Slack wants {text}; both cap message size, so batch lines under 1,900 characters. */
async function post(url, lines) {
  const slack = /hooks\.slack\.com/.test(url);
  let chunk = [];
  const flush = async () => {
    if (!chunk.length) return;
    const text = chunk.join("\n");
    const r = await fetch(url, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(slack ? { text } : { content: text }) });
    if (!r.ok) console.error(`webhook HTTP ${r.status}`);
    chunk = [];
  };
  for (const l of lines) {
    if ([...chunk, l].join("\n").length > 1900) await flush();
    chunk.push(l.slice(0, 1900));
  }
  await flush();
}

async function check(a, key, ids, state) {
  const sport = SPORT[a.league];
  const since = state.since ?? sinceToIso(a.since);
  const j = await api(`/sports/${sport}/leagues/${a.league}/player-availability/history?since=${encodeURIComponent(since)}&limit=500`, key);
  if ((j.data ?? []).length >= 500) console.warn("warning: 500 changes in one check (the maximum); use a shorter --since or check more often");
  const rows = (j.data ?? []).filter((r) => r.observedAt > since && (!ids || ids.has(String(r.teamId))));
  const hits = rows.filter((r) => interesting(r, a.all)).reverse(); // oldest first
  const newest = (j.data ?? [])[0]?.observedAt;
  if (newest && newest > since) state.since = newest;
  if (hits.length) {
    const lines = hits.map(format);
    if (a.dryRun || !process.env.WEBHOOK_URL) console.log(lines.join("\n"));
    else await post(process.env.WEBHOOK_URL, lines);
  }
  console.log(`${new Date().toISOString()} ${a.league}: ${rows.length} changes since ${since}, ${hits.length} alerted`);
}

async function main() {
  loadDotenv();
  const key = process.env.REALTIME_SPORTS_API_KEY;
  if (!key) throw new Error("Set REALTIME_SPORTS_API_KEY (or put it in .env). Free key: https://www.realtimesportsapi.com/signup");
  const a = args(process.argv.slice(2));
  const ids = await teamIds(SPORT[a.league], a.league, a.teams, key);
  const state = !a.dryRun && existsSync(STATE) ? JSON.parse(readFileSync(STATE, "utf8"))[a.league] ?? {} : {};
  const save = () => { if (a.dryRun) return; const all = existsSync(STATE) ? JSON.parse(readFileSync(STATE, "utf8")) : {}; all[a.league] = state; writeFileSync(STATE, JSON.stringify(all)); };
  for (;;) {
    try { await check(a, key, ids, state); save(); } catch (e) { console.error(String(e.message ?? e)); }
    if (a.once || a.dryRun) return;
    await new Promise((r) => setTimeout(r, a.every * 60e3));
  }
}

if (import.meta.url === `file://${process.argv[1]}`) main().catch((e) => { console.error(e.message); process.exit(1); });

5. Run it

On 23 November 2026 a 24-hour NBA dry run found 98 report changes and 58 worth an alert, including Jerami Grant moving from Day-To-Day to Out with an expected return of December 12. Sent to a webhook, the 58 lines went out as 4 posts of at most 1,870 characters, and the next check found nothing new, so nothing was repeated.

Terminal

node injury-alerts.mjs --league nfl --team KC,BUF            # every 10 minutes
node injury-alerts.mjs --league nba --since 24h --dry-run    # print the last day
node injury-alerts.mjs --league nhl --once                   # one check, for cron
node --test injury.test.mjs

Endpoints used

  • GET /sports/{sport}/leagues/{league}/player-availability/history?since=…&limit=500
  • GET /sports/{sport}/leagues/{league}/teams

Full reference: docs · OpenAPI · what each endpoint returns, by league

FAQ

Is injury data on the Free plan?
Yes. Injury reports and their change history are on every plan. Each check is one call. Every 10 minutes is 144 calls a day per league, which uses up the Free plan's 1,000 calls for the first 30 days in about a week (then it is 125 a month), so on Free run it with --once a few times a day from cron, or use the 7-day trial or a paid plan.
Which leagues work?
The script is set up for the NFL, NBA and NHL, the leagues it was tested on.
How far back does the change history go?
History begins from the date tracking was enabled for each league and is not backfilled. Use --since 24h on the first run to see the last day.
Why did I not get an alert when the note changed?
By default only additions, removals and designation changes alert. Run with --all to get note and return-date updates too.

More guides