Crypto WebSocket API
One socket for every chain and channel. Open it once, then subscribe to as many things as your plan allows.
Connect and subscribe
Open wss://app.aurelia.build/api/live with your key in the URL as apiKey, because browsers cannot set headers on a WebSocket. Each subscription has an id you choose, and every message for it carries that id.
Follow a token's trades:
const ws = new WebSocket("wss://app.aurelia.build/api/live?apiKey=<key>");
ws.onopen = () => {
ws.send(JSON.stringify({ op: "subscribe", id: "sol", channel: "trades", chain: "solana", token: "So11111111111111111111111111111111111111112" }));
};
ws.onmessage = (e) => {
const m = JSON.parse(e.data);
if (m.type === "trades") for (const t of m.data) console.log(t.side, t.amount, t.priceUsd);
};
Channels
| Channel | Follows | Read |
|---|---|---|
trades | Every swap of a token, a pool or a wallet | Trades |
candles | The bar in progress, then each bar's final values | Candles |
token, pool | A token's or pool's page, and the price between updates | Token and pool |
holders | A token's 100 largest holders | Holders |
balances, positions | A wallet's holdings and PnL | Balances and positions |
pulse | New launches, curves and graduations | Pulse lists |
Recover from gaps
Nothing is replayed. After a resubscribed message, what was indexed during the outage was not sent: snapshot channels send their snapshot again, and for trades and candles you read the recent ones over REST and merge them.
Errors and closing
- An
errormessage ends that subscription only. The socket stays open. 4401: the key was refused.4402: your credits ran out, so add credit and connect again.- Unsubscribe with
{"op":"unsubscribe","id":"sol"}. It is free.
What it costs
Opening a socket costs 1 credit, each subscription 1, and each data message 0.01. A free account gets 5 sockets of 25 subscriptions each, and a paid one 5 sockets of 100. See authentication and limits.
Related
Free to start: 10,000 credits, with no card and no subscription.