Discord Alerts from Binance API: Complete Setup Guide
Learn how to build real-time Discord trading alerts using the Binance API — from authentication to live price notifications in under 50 lines of code.
Learn how to build real-time Discord trading alerts using the Binance API — from authentication to live price notifications in under 50 lines of code.
Missing a breakout because you were away from your screen is one of the most frustrating experiences in trading. The good news: the Binance API paired with Discord webhooks gives you a real-time alert system that fires straight to your phone — no third-party subscriptions, no delays, just raw market data routed wherever you need it. This guide walks through the full setup, from API keys to working code you can run today.
Discord has become the de facto communication layer for crypto communities — and for good reason. Webhooks are dead simple: one POST request sends a formatted message to any channel you control. No OAuth dance, no app approval process. Traders using platforms like Bybit and OKX often run separate Discord servers for different strategies, routing futures alerts to one channel and spot signals to another. The free tier handles thousands of messages per day, which is more than enough for most personal setups.
Before writing a single line of code you need two things: a read-only Binance API key and a Discord webhook URL. On Binance, go to Account > API Management and create a new key. For price monitoring you only need read permissions — disable withdrawals and trading if your sole goal is alerts. Store the key and secret in environment variables, never hardcoded in scripts.
For Discord, open your server, go to a channel's settings, select Integrations, then Webhooks. Click 'New Webhook', name it (e.g. 'Binance Alerts'), and copy the URL. That URL is the only thing you need to POST messages. Treat it like a password — anyone with the URL can post to your channel.
import os
import requests
from dotenv import load_dotenv
load_dotenv()
BINANCE_API_KEY = os.getenv('BINANCE_API_KEY')
BINANCE_SECRET = os.getenv('BINANCE_SECRET')
DISCORD_WEBHOOK_URL = os.getenv('DISCORD_WEBHOOK_URL')
def send_discord_alert(title: str, description: str, color: int = 3066993):
"""Send a rich embed alert to Discord."""
payload = {
"embeds": [{
"title": title,
"description": description,
"color": color, # 3066993 = green, 15158332 = red
"footer": {"text": "Binance API Alert"}
}]
}
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
response.raise_for_status()
return response.status_code
# Test the webhook
send_discord_alert(
title="✅ Alert System Online",
description="Binance → Discord pipeline connected successfully."
)
print("Webhook test sent")
The simplest approach is polling the Binance REST API on an interval and firing a Discord message when your condition is met. This works well for low-frequency checks — daily highs, support/resistance levels, or percentage moves over a time window. The `/api/v3/ticker/price` endpoint is public and doesn't require authentication, which simplifies things considerably.
import time
import requests
BINANCE_BASE = 'https://api.binance.com'
def get_price(symbol: str) -> float:
"""Fetch current price from Binance REST API."""
url = f"{BINANCE_BASE}/api/v3/ticker/price"
try:
response = requests.get(url, params={'symbol': symbol}, timeout=5)
response.raise_for_status()
return float(response.json()['price'])
except requests.exceptions.RequestException as e:
print(f"[ERROR] Failed to fetch {symbol}: {e}")
return None
def monitor_price_alert(symbol: str, target_price: float, direction: str = 'above'):
"""
Poll Binance every 30s and alert Discord when price crosses target.
direction: 'above' or 'below'
"""
print(f"Monitoring {symbol} — alert when price goes {direction} {target_price}")
alerted = False
while not alerted:
price = get_price(symbol)
if price is None:
time.sleep(10)
continue
condition_met = (
(direction == 'above' and price >= target_price) or
(direction == 'below' and price <= target_price)
)
if condition_met:
color = 3066993 if direction == 'above' else 15158332
send_discord_alert(
title=f"🚨 {symbol} Price Alert",
description=(
f"**{symbol}** is now **{direction} {target_price}**\n"
f"Current price: `${price:,.4f}`"
),
color=color
)
alerted = True
print(f"Alert fired: {symbol} @ {price}")
else:
print(f"{symbol}: ${price:,.4f} | Target: {direction} ${target_price}")
time.sleep(30)
# Example: alert when BTC breaks above $70,000
monitor_price_alert('BTCUSDT', 70000.0, direction='above')
Binance rate limits REST API calls to 1,200 requests per minute per IP. For 30-second polling across 10 symbols, you're using roughly 20 requests/minute — well within limits. If you monitor more than 50 symbols simultaneously, switch to WebSockets to avoid hitting the ceiling.
For fast markets — scalping setups, liquidation watches, momentum breakouts — polling every 30 seconds is too slow. Binance WebSocket streams push data the moment it changes, giving you sub-second latency. The trade stream fires on every executed order, the ticker stream updates every second, and the kline stream fires when a candle closes. Compared to polling, WebSockets are also more efficient: one persistent connection replaces hundreds of HTTP requests per hour.
import asyncio
import json
import websockets
BINANCE_WS_BASE = 'wss://stream.binance.com:9443/ws'
async def stream_price_alerts(
symbol: str,
target_price: float,
direction: str = 'above'
):
stream = f"{symbol.lower()}@ticker"
url = f"{BINANCE_WS_BASE}/{stream}"
alerted = False
print(f"WebSocket connected: {stream}")
async with websockets.connect(url, ping_interval=20) as ws:
while not alerted:
try:
raw = await asyncio.wait_for(ws.recv(), timeout=60)
data = json.loads(raw)
price = float(data['c']) # 'c' = current close price
change_pct = float(data['P']) # 'P' = price change percent
condition_met = (
(direction == 'above' and price >= target_price) or
(direction == 'below' and price <= target_price)
)
if condition_met:
emoji = '📈' if change_pct >= 0 else '📉'
color = 3066993 if change_pct >= 0 else 15158332
send_discord_alert(
title=f"{emoji} {symbol} Real-Time Alert",
description=(
f"Price crossed **{direction} ${target_price:,.2f}**\n"
f"Current: `${price:,.4f}` | 24h change: `{change_pct:+.2f}%`"
),
color=color
)
alerted = True
except asyncio.TimeoutError:
print("[WARN] WebSocket heartbeat timeout — reconnecting")
break
except json.JSONDecodeError as e:
print(f"[ERROR] JSON parse failed: {e}")
continue
# Run the WebSocket monitor
asyncio.run(stream_price_alerts('ETHUSDT', 4000.0, direction='above'))
Traders on Coinbase Advanced and KuCoin run similar WebSocket setups for their respective APIs — the pattern is nearly identical, just with different endpoint URLs and authentication headers. Once you build this once for Binance, porting it to Bybit or Gate.io takes maybe 20 minutes.
Raw price alerts are useful but context-free. Knowing BTC hit $70,000 is one thing — knowing it hit $70,000 with a confirmed breakout signal, elevated volume, and bullish momentum behind it is actionable intelligence. This is where layering a platform like VoiceOfChain on top of your Binance API alerts adds real edge. VoiceOfChain aggregates on-chain data, derivatives metrics, and technical signals into consolidated trade alerts, which you can pipe into the same Discord channel alongside your custom Binance triggers.
A practical setup: use your Binance WebSocket to monitor price levels and volume spikes, then cross-reference with VoiceOfChain's signal feed before acting. When both systems agree — price alert fires AND VoiceOfChain shows a confirmed bullish signal — you have a much higher-confidence setup than either source alone. Discord's channel organization makes this clean: one channel for raw Binance alerts, another for VoiceOfChain signals, and a third for your own manual notes.
Pro tip: Use Discord role mentions (@here or @everyone) sparingly — only for the highest-priority alerts like liquidation levels or major support breaks. Reserve quiet notifications for routine price checks. Alert fatigue is real and will cause you to ignore the signals that matter.
A Binance API to Discord pipeline is one of those setups that pays dividends immediately and compounds over time. Start with a single price alert for your main position, verify the webhook fires correctly, then expand to cover your full watchlist. Add WebSocket streams when you need sub-second latency. Layer in signals from VoiceOfChain when you want context alongside raw price data. The entire foundation covered here — REST polling, WebSocket streaming, Discord embeds, and error handling — is production-ready code you can extend without rewriting from scratch. The best alert system is the one that's actually running when the market moves.