Skip to main content

WebSocket RPC endpoint

GET 

/ws/rpc

Upgrade to a WebSocket at wss://mainnet-rpc.ama.one/ws/rpc (testnet: wss://testnet-rpc.ama.one/ws/rpc). Any path that starts with /ws/rpc is accepted.

The stream is push-only: the node sends JSON text frames and ignores JSON frames from the client; a client text frame that is not valid JSON closes the connection. There are no RPC methods or subscriptions. For every new entry it sends, in order:

opPayloadContents
event_statsstatsChain statistics, as in /api/chain/stats
event_entryentryThe new entry, as in /api/chain/tip (no txs)
event_txstxsThe entry's transactions; sent only when the entry has any
{"op":"event_entry","entry":{"hash":"455SCs5qbQPhfwzq8GfK3VLgz4AbLpdzjdC6ijGZ3NDx","header":{"height":90324330,"slot":90324330,"prev_hash":"EqvGAJK9hBcwkGW6Zb9F2FCQ7CtWY6s22cMToaNsBP1p","...":"..."},"tx_count":3,"seen_time_ms":1794240595645,"in_main_chain":true}}

Transactions in event_txs are pushed before execution results are indexed: they have no metadata, result.error is null and receipt is a placeholder (success: false, exec_used: "0"). Fetch /api/chain/tx/{txid} for the real receipt.

The node answers ping frames with pong. It closes the socket after 90 s with neither an inbound frame nor a pushed event, and when the client sends more than 1 MiB of unread data.

const socket = new WebSocket('wss://mainnet-rpc.ama.one/ws/rpc')
socket.onmessage = (event) => {
const message = JSON.parse(event.data)
if (message.op === 'event_entry') console.log(message.entry.header.height)
}

Request​

Responses​

Switching Protocols: the WebSocket is open and events start flowing