ការណែនាំអំពីការអនុវត្ត Webhook

ចុះឈ្មោះ URL HTTPS មួយ ហើយទទួលការជំរុញព្រឹត្តិការណ៍ដែលមានហត្ថលេខា HMAC ជាពេលវេលាពិតនៅពេលដែលសញ្ញាប្រាក់ដុំឆ្លាតដំណើរការ — គ្មានការស្ទង់។ ការណែនាំនេះគ្របដណ្តប់លើការចុះឈ្មោះ ការតម្រងព្រឹត្តិការណ៍ ការផ្ទៀងផ្ទាត់ហត្ថលេខា និងឥរិយាបថព្យាយាមម្តងទៀត។

ទិដ្ឋភាពទូទៅ

ជំនួសឱ្យការស្ទង់ /v1/confirm ឬការផ្គត់ផ្គង់សញ្ញា ចុះឈ្មោះ webhook ហើយ Smart Money API នឹង POST ព្រឹត្តិការណ៍មួយទៅចំណុចបញ្ចប់របស់អ្នកនៅពេលដែលសញ្ញាដែលត្រូវគ្នាដំណើរការ។ រាល់ការផ្ញើត្រូវបានចុះហត្ថលេខាជាមួយ HMAC-SHA256 ដូច្នេះអ្នកអាចផ្ទៀងផ្ទាត់ថាវាពិតជាមកពីយើង។

Webhooks ចេញគឺអាចប្រើបាននៅលើ Pro និងផែនការសហគ្រាស។

ចុះឈ្មោះ Webhook

POST ទៅ /v1/webhooks ជាមួយនឹងកូនសោ API របស់អ្នកនៅក្នុង X-API-Key ក្បាល។ ត្រូវការបួនផ្នែកនៅក្នុងផ្នែករាងកាយ៖

ផ្នែកប្រភេទការពិពណ៌នា
urlstringចំណុចបញ្ចប់ HTTPS ដើម្បីទទួលព្រឹត្តិការណ៍ (ត្រូវតែចាប់ផ្តើមដោយ https://)
eventsarrayឈ្មោះព្រឹត្តិការណ៍ដើម្បីទទួល ឧ. ["HIGH","MEDIUM","VETO"]["*"]
symbolsarrayនិមិត្តសញ្ញាដើម្បីតម្រង ឧ. ["BTC","ETH"]["*"]
secretstringអាថ៌កំបាំងចុះហត្ថលេខារបស់អ្នក — យ៉ាងហោចណាស់ ១៦ តួអក្សរ។ ត្រូវបានផ្ទុកជាអាស្រ័យ hash; រក្សាតម្លៃដើមនៅខាងអ្នកដើម្បីផ្ទៀងផ្ទាត់ហត្ថលេខា។
cURL
curl -X POST https://api.smartmoneyapi.com/v1/webhooks \ -H "X-API-Key: sm_your_key" \ -H "Content-Type: application/json" \ -d '{ "url": "https://yourapp.com/webhooks/smartmoney", "events": ["HIGH", "MEDIUM"], "symbols": ["BTC", "ETH"], "secret": "a-long-random-secret-16-plus-chars" }'
201 Created
{ "webhook_id": 42, "url": "https://yourapp.com/webhooks/smartmoney", "events": ["HIGH", "MEDIUM"], "symbols": ["BTC", "ETH"], "message": "Webhook registered. Test with POST /v1/webhooks/test" }

តម្រងព្រឹត្តិការណ៍

ការផ្ញើដំណើរការសម្រាប់ព្រឹត្តិការណ៍ដែលឈ្មោះ និងនិមិត្តសញ្ញាត្រូវគ្នានឹងការចុះឈ្មោះរបស់អ្នក។ ឈ្មោះព្រឹត្តិការណ៍ធម្មតាគឺជាប៉ាន់ស្មានទំនុកចិត្ត — HIGH, MEDIUM, VETO — បូកជាមួយព្រឹត្តិការណ៍ទូទៅ SIGNAL ព្រឹត្តិការណ៍។ ប្រើ ["*"] ដើម្បីទទួលព្រឹត្តិការណ៍ទាំងអស់ ឬនិមិត្តសញ្ញាទាំងអស់។

ការផ្ញើ និងក្បាល

រាល់ការផ្ញើគឺជា HTTP POST ជាមួយនឹងផ្នែករាងកាយ JSON និងក្បាលទាំងនេះ៖

HeaderValue
X-SmartMoney-EventThe event name (e.g. HIGH)
X-SmartMoney-SignatureHMAC-SHA256 hex digest of the request body (see below)
Content-Typeapplication/json
User-AgentSmartMoneyAPI-Webhook/1.0
Example payload
{ "event": "HIGH", "ts": "2026-07-01T18:22:05Z", "symbol": "BTC", "direction": "long", "confidence": "HIGH", "composite": 0.74, "webhook_id": 42 }

Respond with any 2xx status to acknowledge. Non-2xx (or a timeout) triggers a retry.

Verifying Signatures

The signature in X-SmartMoney-Signature is an HMAC-SHA256 hex digest of the request body. The HMAC key is the SHA-256 hex digest of the secret you registered (your raw secret is only ever stored hashed on our side). To verify: derive the key, HMAC the raw body, and compare with a constant-time check. Reject any request that fails.

Python (Flask receiver)
import hashlib, hmac from flask import Flask, request, abort app = Flask(__name__) MY_SECRET = "a-long-random-secret-16-plus-chars" # the value you registered @app.post("/webhooks/smartmoney") def receive(): raw = request.get_data() # exact bytes of the body sig = request.headers.get("X-SmartMoney-Signature", "") key = hashlib.sha256(MY_SECRET.encode()).hexdigest() # HMAC key = sha256(secret) hex expected = hmac.new(key.encode(), raw, hashlib.sha256).hexdigest() if not hmac.compare_digest(expected, sig): abort(401) event = request.get_json() # ... act on event["event"], event["symbol"], event["composite"] ... return "", 200
Node.js (Express receiver)
import crypto from "crypto"; import express from "express"; const app = express(); const MY_SECRET = "a-long-random-secret-16-plus-chars"; // Capture the raw body so the signature check uses the exact bytes. app.post("/webhooks/smartmoney", express.raw({ type: "*/*" }), (req, res) => { const sig = req.get("X-SmartMoney-Signature") || ""; const key = crypto.createHash("sha256").update(MY_SECRET).digest("hex"); const expected = crypto.createHmac("sha256", key).update(req.body).digest("hex"); const ok = expected.length === sig.length && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(sig)); if (!ok) return res.status(401).end(); const event = JSON.parse(req.body.toString()); // ... act on event ... res.status(200).end(); });
Verify against the raw, unparsed request body — re-serializing parsed JSON can change byte order or spacing and break the check.

Retries

If your endpoint does not return a 2xx (or times out — the delivery timeout is 10s), Smart Money API retries up to 3 times with exponential backoff (approximately 1s, 4s, then 16s). Make your handler idempotent so a re-delivered event is safe to process twice.

Inbound Webhooks (TradingView)

Separately, you can send an inbound alert to us. POST /v1/tradingview/webhook receives a TradingView alert, runs it through /confirm, and returns the confirmation. Because TradingView cannot send custom headers, it authenticates via a secret field in the JSON body (not X-API-Key). Send secret, symbol, and direction (long/short); optionally timeframe, strategy, and price.

Ready to wire up real-time signals?

Get your API key
Start free — 200 calls/day, no card

Get live whale flow, funding, open interest and on-chain data across 3 exchanges from one API. Free tier, no credit card, upgrade any time.

Start free →
Try the live API console → (no account needed)
Get your API key in 30 seconds

Ready to build? Grab a free API key (200 calls/day, no card) and start pulling live whale, funding and on-chain data.

Get your API key →