WebSocket subscriptions
Subscribe with JSON-RPC over one socket. Each topic has its own method and an unsubscribe.
Connect
Connect to wss://api.tide.ad/ (also /ws) with your key in the api-key query parameter. A key is required, and your plan sets how many streams you can hold open at once.
Methods
| Subscribe | Unsubscribe |
|---|---|
| transactionSubscribe | transactionUnsubscribe |
| eventSubscribe | eventUnsubscribe |
| checkpointSubscribe | checkpointUnsubscribe |
| balanceSubscribe | balanceUnsubscribe |
| objectSubscribe | objectUnsubscribe |
The params take a filter object and an options object: [filter, options]. Options are view, fromCheckpoint, cursor and pending (checkpoints only). You can also put the options inside the filter object. The filters and views are the same as on SSE and webhooks, see Topics and filters.
| Message | Meaning |
|---|---|
| <topic>Notification | One item, with subscription, cursor and result. |
| subscriptionProgress | Every checkpoint up to this one is delivered. Sent after each replay chunk and every 15 seconds when it moved. |
| subscriptionError | The subscription ended, with a code and a message. |
Example
const ws = new WebSocket(`wss://api.tide.ad/?api-key=${process.env.TIDE_API_KEY}`);
ws.onopen = () =>
ws.send(
JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "transactionSubscribe",
params: [{ accounts: ["0xYOUR_ADDRESS"] }, { view: "enhanced", fromCheckpoint: 123456789 }],
}),
);
ws.onmessage = (e) => console.log(JSON.parse(e.data));Resume
Messages are ordered by checkpoint and transaction index and deduplicated by digest. Each carries a cursor. After a drop, connect again and subscribe with cursor set to the last cursor you handled, or the checkpoint from the last subscriptionProgress if that is newer. The stream continues after it with no gap and no duplicate.
Close code 1012 means the server is restarting. Reconnect and subscribe again the same way.
One credit covers 10 delivered events, replayed events included.