This endpoint is only available to Growth and Enterprise plans.
WebSocket
Mobula provides WSS support for retrieving any raw events and curated events like Swaps or Liquidity.
Endpoint details
- URL: wss://production-stream.mobula.io
- Message (string):
{
"name": "MyWalletTransactions",
"chainIds": ["evm:1", "evm:56"],
"events": ["trace", "log", "transaction", "block", "swap", "transfer", "pool"],
};
Parameters
Implementation example
Let’s take a look at:
Coming soon.
You can use the Network tab in your browser to see the WSS requests.
const socket = new WebSocket("wss://production-stream.mobula.io");
socket.addEventListener("open", () => {
socket.send(`{
"type": "stream",
"payload": {
"chainIds": ["evm:1", "evm:56"],
"events": ["trace", "log", "transaction", "block", "swap", "transfer", "pool"],
}
}`);
});
socket.addEventListener("message", (event) => {
const data = JSON.parse(event.data);
if (event.reorg) {
// Handle reorg
return;
}
});
// No need to close the socket, it will close automatically.
Connection Keepalive (Ping/Pong)
To maintain active WebSocket connections and prevent timeouts, you can use the ping/pong mechanism:
Send ping:
Receive pong:
The server will respond with a pong message to confirm the connection is active.
Use ping messages periodically (every 30-60 seconds) to keep long-lived connections alive.
Webhook
Mobula provides Webhook support for retrieving any raw events and curated events like Swaps or Liquidity.
Endpoint details
{
"name": "MyFirstWebhook",
"chainIds": ["evm:1", "evm:56"],
"events": ["trace", "log", "transaction", "block", "swap", "transfer", "pool"],
"apiKey": "xxxxxxxxxx",
"url": "https://webhook.com/xxxxxxxxxxx",
};
Parameters
- chainIds: details here
- events: transactions, traces, logs, blocks, swaps, transfers, pools
- filters: details here
- webhookUrl: URL to send the data
Create a webhook
First we need to create a webhook:
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: {
"name": "FirstWebhook",
"chainIds": ["evm:1"],
"events": ["trace"],
"apiKey": "xxxxx",
"filters": {
"eq": ["action.input", "0xd55ec697"]
},
"url": "https://webhook.com/xxxxx"
}
});
The API key is mandatory to create a webhook.
If you receive data from your webhook in response, then your webhook is functional and will start receiving events.
Delete a webhook
To delete a webhook:
await fetch(url + `/${webhook_id}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
});
If you receive:
{
"message": "Stream deleted successfully"
}
Then your webhook is deleted.
Can’t find what you’re looking for? Reach out to us, response times < 1h.