guides

Discord odds alert bot: post price moves to a channel with a webhook

By · Published · Updated · 6 min read

A Discord odds alert bot reads price changes from an odds API and posts the large ones to a channel. The one below is a single Node script with no packages: every 30 seconds it asks GET /v1/changes for the NBA price changes since its last call and posts each moneyline, spread or total that moved 2 or more points of implied probability to a Discord webhook. In our 180-second run it saw 2,575 game-market price changes and posted 42 alerts.

What do I need to build a Discord odds bot?

  • A PricedOdds API key, sent as Authorization: Bearer $PRICEDODDS_API_KEY.
  • A Discord webhook URL for the channel. Discord explains how to create one in its Intro to Webhooks help article. Anyone with the URL can post to that channel, so keep it out of your code and your repository, like the API key.
  • Node 18 or later, which has fetch built in.

A webhook is enough for a bot that only posts. You need a full Discord bot user only if it must read messages or answer commands.

How does the bot work?

  1. It reads the events of the league once from GET /v1/events, to turn each event_id into a matchup such as DET @ ORL.
  2. A first call to GET /v1/changes with no cursor returns a starting cursor in next.
  3. Every 30 seconds it calls GET /v1/changes with since set to that cursor and keeps the new next for the following call.
  4. Each price change carries the new price in american and the one before it in prev_american. The bot turns both into implied probability and keeps the moves of 2 points or more.
  5. It posts one message per poll, split so that no message passes 2,000 characters.

The Discord side follows the Execute Webhook documentation, read on November 24, 2026: a POST to the webhook URL with a JSON body, where content takes "up to 2000 characters" and the answer is 204 No Content unless you add wait=true. When Discord limits the rate it answers HTTP 429, and its rate limit documentation says to wait the retry_after seconds of the body or the Retry-After header before trying again. The script does that.

What is the code?

// discord-odds-alerts.mjs: posts NBA price moves to a Discord channel through a webhook. Node 18 or later, no packages.
// Usage: PRICEDODDS_API_KEY=... DISCORD_WEBHOOK_URL=... node discord-odds-alerts.mjs
// Without DISCORD_WEBHOOK_URL it prints the messages instead of posting them. ROUNDS=n stops after n polls.
const BASE = "https://api.pricedodds.com/v1";
const auth = { headers: { Authorization: `Bearer ${process.env.PRICEDODDS_API_KEY}` } };
const WEBHOOK = process.env.DISCORD_WEBHOOK_URL;
const LEAGUE = process.env.LEAGUE ?? "nba";
const MARKETS = new Set(["moneyline", "spread", "total"]); // game markets only; player props move far more often
const MIN_POINTS = Number(process.env.MIN_POINTS ?? 2); // alert when implied probability moves this many points or more
const POLL_SECONDS = 30;
const COOLDOWN_MINUTES = 10; // one alert per selection in this window, so a price that flickers back and forth posts once
const ROUNDS = Number(process.env.ROUNDS ?? Infinity);

const get = async (path) => {
  const res = await fetch(BASE + path, auth);
  if (!res.ok) throw new Error(`${path}: HTTP ${res.status}`);
  return res.json();
};
const implied = (american) => (american > 0 ? 100 / (american + 100) : -american / (-american + 100));
const fmt = (american) => (american > 0 ? `+${american}` : `${american}`);
const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));

// Discord: content up to 2000 characters; on HTTP 429, wait retry_after seconds and try again.
const post = async (content) => {
  if (!WEBHOOK) return console.log(content + "\n");
  for (;;) {
    const res = await fetch(WEBHOOK, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ content }) });
    if (res.status !== 429) {
      if (!res.ok) throw new Error(`Discord webhook: HTTP ${res.status}`);
      return;
    }
    await sleep((await res.json()).retry_after ?? 1);
  }
};

// Team names for the alert text, from the event list of the league.
const names = new Map();
for (const e of (await get(`/events?league=${LEAGUE}`)).data) names.set(e.id, `${e.away.abbr} @ ${e.home.abbr}`);

const lastAlert = new Map(); // selection_id -> time of its last alert
let cursor = (await get(`/changes?league=${LEAGUE}`)).next; // the first call returns a starting cursor
for (let round = 1; round <= ROUNDS; round++) {
  await sleep(POLL_SECONDS);
  const res = await get(`/changes?league=${LEAGUE}&since=${encodeURIComponent(cursor)}`);
  cursor = res.next;
  const lines = [];
  let seen = 0, muted = 0;
  for (const frame of res.data) {
    if (frame.type !== "price") continue;
    for (const c of frame.changes) {
      if (!MARKETS.has(c.market) || c.prev_american == null || c.american == null) continue;
      seen++;
      const move = (implied(c.american) - implied(c.prev_american)) * 100;
      if (Math.abs(move) < MIN_POINTS) continue;
      if (Date.now() - (lastAlert.get(c.selection_id) ?? 0) < COOLDOWN_MINUTES * 60000) { muted++; continue; }
      lastAlert.set(c.selection_id, Date.now());
      const what = `${c.market} ${c.period} ${c.side}${c.line != null ? " " + c.line : ""}`;
      lines.push(`**${names.get(frame.event_id) ?? frame.event_id}** ${frame.book} ${what}: ${fmt(c.prev_american)} -> ${fmt(c.american)} (${move > 0 ? "+" : ""}${move.toFixed(1)} pts)`);
    }
  }
  console.log(`round ${round}: ${seen} game-market price changes, ${lines.length} alerts at or above ${MIN_POINTS} points, ${muted} muted by the cooldown`);
  // One message per poll, split so that no message passes 2000 characters.
  let msg = "";
  for (const line of lines) {
    if (msg.length + line.length + 1 > 2000) { await post(msg); msg = ""; }
    msg += (msg ? "\n" : "") + line;
  }
  if (msg) await post(msg);
}

Run it with PRICEDODDS_API_KEY=... DISCORD_WEBHOOK_URL=... node discord-odds-alerts.mjs. Without DISCORD_WEBHOOK_URL it prints the messages to the terminal, which is a safe way to tune the threshold before it posts anything.

What did a real run return?

We ran the script on November 24, 2026, 23:40 UTC, with ROUNDS=6 so that it stopped after 6 polls, against live NBA prices. Its log:

round 1: 369 game-market price changes, 12 alerts at or above 2 points, 3 muted by the cooldown
round 2: 674 game-market price changes, 11 alerts at or above 2 points, 12 muted by the cooldown
round 3: 321 game-market price changes, 3 alerts at or above 2 points, 8 muted by the cooldown
round 4: 501 game-market price changes, 14 alerts at or above 2 points, 8 muted by the cooldown
round 5: 351 game-market price changes, 2 alerts at or above 2 points, 11 muted by the cooldown
round 6: 359 game-market price changes, 0 alerts at or above 2 points, 10 muted by the cooldown

In 180 seconds it read 2,575 price changes in game markets. 42 of them moved 2 points or more and were posted. Another 52 moved as much but came from a selection that had already been posted in the last 10 minutes, so the cooldown held them back. That cooldown is there because some prices flicker: in a first run without it, one Polymarket moneyline went from -488 to -223 and back several times within three minutes, and each swing was an alert. The first message of the run, as the channel would show it:

**MIN @ OKC** novig spread game home -19.5: +640 -> +488 (+3.5 pts)
**DET @ ORL** polymarket spread game home 22.5: -3226 -> -10000 (+2.0 pts)
**DET @ ORL** prophetx spread game home -6.5: +144 -> +158 (-2.2 pts)
**CLE @ NYK** prophetx moneyline game away: +148 -> +130 (+3.2 pts)
**DET @ ORL** polymarket total 1h under 125.5: -2381 -> -5000 (+2.1 pts)
**MIN @ OKC** kalshi spread game home -9.5: +245 -> +213 (+3.0 pts)
**MIN @ OKC** kalshi spread game home -6.5: +170 -> +156 (+2.0 pts)
**MIN @ OKC** kalshi spread game home -5.5: +144 -> +127 (+3.1 pts)

These are prices of one evening, shown as an example and not as current prices.

What we did not test. We did not post to a real Discord server. The webhook URL pointed to a small local server that answers the way the Discord documentation describes: the first request got HTTP 429 with retry_after 0.5, and the script waited and sent it again; the other requests got 204. It received 5 messages, all JSON POST requests with a content field, the longest of 973 characters. So the API side and the retry ran for real, and the Discord side ran against a stand-in.

How do I change what the bot alerts on?

  • MIN_POINTS: the size of the move, in points of implied probability. The implied probability calculator shows what a given price means, and line movement explained covers how to read a move.
  • LEAGUE: any league id from the coverage page, such as nfl or nhl.
  • MARKETS: the bot keeps moneyline, spread and total. Player prop changes also come through /v1/changes with a player object, and there are many more of them, so raise the threshold before you add them and put c.player?.name in the message.
  • COOLDOWN_MINUTES: how long a selection stays quiet after an alert.
  • Books: /v1/changes also takes a books filter, such as books=draftkings,fanduel.

The parameters of every endpoint are in the docs.

Should the bot poll or use the WebSocket?

Polling every 30 seconds is simple and enough for alerts a person reads. The WebSocket pushes the same changes as they arrive, with no polling loop; the trade-offs are in WebSocket vs polling, and the WebSocket version of a client is in the JavaScript WebSocket tutorial. Either way the message to Discord is the same.

What are the limits of a price alert bot?

A move at one book is not a move of the market: the bot posts single-book changes, so check other books before you read anything into one. In play, prices follow the score and the clock and move all the time. Many alerts on spreads and totals are on alternate lines far from the main one. Prediction markets and exchanges can show large moves on thin prices. The API returns current prices and changes, not history, so anything older than the bot's own run is not available to it. Nothing here is betting advice.

A WebSocket version that waits for several books to move together and also flags prices above the fair price is in odds alerts in Node. The same idea for Telegram, with the WebSocket instead of polling and a /best command in the chat, is the Telegram odds bot.

FAQ

Do I need a Discord bot account?

No. A webhook posts messages to one channel without a bot user or a login. You need a bot account only to read messages or answer commands.

How often can the bot post?

Discord sets the limits and says they should not be hard-coded. The script posts at most a few messages every 30 seconds and waits when Discord answers 429.

Can the bot alert on player props?

Yes. Add the prop markets to MARKETS, raise MIN_POINTS and add the player name from the player object of each change to the message.

Where do I start?

Run the script without a webhook first and watch what it would post. The fields are in the docs and the books and leagues are on the coverage page. Every plan starts with a 3-day free trial with a $1 card verification that is refunded immediately. The plan you pick at signup is charged from day 4 unless you cancel before the trial ends. See pricing or create an account.