Catch TradingView alert webhooks and bridge them to local trading tools over WebSocket.
Webhook bodies must be JSON and include a channel secret. Clients subscribe on the WebSocket with a channel secret and only receive alerts for that channel.
TradingView docs: About webhooks.
HTTP webhook — POST /webhook
{"secret":"changeme-crypto-secret","symbol":"BTCUSDT","side":"buy"}Only valid JSON is accepted. Requests must come from TradingView IPs (unless DEBUG=true). Unknown secret → 401. The secret field is stripped before broadcast; channel is added.
You can put anything in the JSON payload, this program only needs the secret attribute set.
WebSocket — /ws
- Connect
- Send:
{"action":"subscribe","secret":"changeme-crypto-secret"} - Receive ack:
{"status":"ok","channel":"crypto"} - Receive forwarded alert JSON for that channel only (without
secret)
Secrets live in channels.json (mounted into the container). Copy the example and edit:
cp channels.example.json channels.json{
"channels": {
"default": "changeme-default-secret",
"crypto": "changeme-crypto-secret"
}
}Each key is a channel name; each value is that channel’s secret. Secrets must be unique.
Copy .env.template to .env (optional overrides).
| Variable | Description |
|---|---|
CHANNELS_CONFIG |
Path to channels JSON (default channels.json; Docker: /app/channels.json) |
DEBUG |
true skips TradingView IP allowlist |
HTTP_HOST / HTTP_PORT |
Bind address (default 0.0.0.0:8000) |
cp channels.example.json channels.json
cp .env.template .env
uv sync
uv run python main.pyTest client (set secret to a channel from channels.json):
WEBHOOK_SECRET=changeme-crypto-secret uv run python websocketTest.pyUse install.sh script to create a new instance using docker in a new folder with a new random token.
Caddy for HTTPS
Simple reverse proxy configuration for caddy.
webhook.example.com {
reverse_proxy 127.0.0.1:8000
}
Endpoints:
https://webhook.example.com/webhookwss://webhook.example.com/ws
TradingView only allows ports 80 and 443.