Build a stock alert bot

Every alert bot has two halves: watching the market, and saying something when a condition trips. The watching half is infrastructure here — write the condition in SQL, get a push when it fires — so the half you build is just the message.

The recipe

1. Test the condition

Run it as a scan first — same grammar the alert will use — to see who matches right now.

curl -s -X POST https://api.tickerbot.io/v2/scan \
  -H "Authorization: Bearer $TICKERBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "q": "volume_burst_3x AND day_change_pct > 0.05 AND market_cap > 1e9" }'

2. Subscribe it

The same q becomes a webhook: evaluated continuously, POSTed to your endpoint when tickers enter or leave the match set.

curl -s -X POST https://api.tickerbot.io/v2/scan/subscribe \
  -H "Authorization: Bearer $TICKERBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "q": "volume_burst_3x AND day_change_pct > 0.05 AND market_cap > 1e9",
        "target_url": "https://your-bot.example.com/hook" }'

Four delivery channels per subscription: webhook, discord, in_app, mobile_push. Run several subscriptions to fan out.

3. Or skip the server entirely

Pass discord_url instead and a formatted embed posts straight to your channel — a working alert bot with zero code and zero hosting.

curl -s -X POST https://api.tickerbot.io/v2/scan/subscribe \
  -H "Authorization: Bearer $TICKERBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "q": "volume_burst_3x AND day_change_pct > 0.05 AND market_cap > 1e9",
        "discord_url": "https://discord.com/api/webhooks/…" }'

4. Write the bot

If you run your own handler, the payload carries the matched tickers with the fields your condition referenced — format and forward anywhere.

app.post('/hook', async (req, res) => {
  for (const row of req.body.matches) {   // tickers that just tripped the condition
    await telegram.send(
      chatId,
      `${row.ticker} up ${(row.day_change_pct * 100).toFixed(1)}% on ${row.volume_today.toLocaleString()} shares`,
    )
  }
  res.sendStatus(200)
})

// Validate the receiver before it matters: POST /v2/webhooks/{id}/test
// sends a real-shape delivery with X-Tickerbot-Test: true.

Endpoints used

EndpointRole in this build
POST /v2/scan/subscribeAny SQL condition as an alert: fires when the match set changes
POST /v2/tickers/{ticker}/subscribeSingle-ticker shorthand: alert on one symbol’s state
GET /v2/webhooksThe registry: list, edit, disable, re-enable every alert
POST /v2/webhooks/{id}/testFire a real-shape test delivery at your receiver

More guides