1. Add a webhook
In the console: the trader, the topic and your URL. Copy its signing secret.
Tell your community, or yourself, when a trader you follow opens or closes a position. A webhook POSTs each change to your URL, signed, so a small serverless function is all you run.
import { createHmac, timingSafeEqual } from "node:crypto";
Bun.serve({
port: 3000,
async fetch(request) {
const body = await request.text();
const { t, v1 } = Object.fromEntries((request.headers.get("x-kopyon-signature") ?? "").split(",").map((p) => p.split("=")));
const expected = createHmac("sha256", process.env.WEBHOOK_SECRET).update(t + "." + body).digest();
if (!v1 || !timingSafeEqual(Buffer.from(v1, "hex"), expected)) return new Response("bad signature", { status: 401 });
const frame = JSON.parse(body);
for (const e of frame.data?.events ?? []) {
await fetch(process.env.DISCORD_WEBHOOK, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ content: frame.traderId + " " + e.event + " " + e.side + " " + e.symbol }),
});
}
return new Response("ok");
},
});In the console: the trader, the topic and your URL. Copy its signing secret.
Check the X-Kopyon-Signature header so only Kopyon can trigger an alert.
Turn each event into a message for Telegram, Discord or Slack.
The same code works on each of them; only the source id changes.
The free tier is 10,000 requests a month. That is enough to build a whole integration and test it against live data before you pay anything.
Usually answered within a day · [email protected] ·