Skip to main content

Connect to premium websockets

01 - Access your premium websocket (wss) endpoint

Copy your wss endpoint from the Premium Plan page.

tip

Premium websockets are of the following format:

Arbitrum wss://rpc.ankr.com/arbitrum/ws/<YOUR_PRIVATE_KEY>

Avalanche wss://rpc.ankr.com/avalanche/ws/<YOUR_PRIVATE_KEY>

Binance Smart Chain wss://rpc.ankr.com/bsc/ws/<YOUR_PRIVATE_KEY>

Celo wss://rpc.ankr.com/celo/ws/<YOUR_PRIVATE_KEY>

Ethereum wss://rpc.ankr.com/eth/ws/<YOUR_PRIVATE_KEY>

Fantom wss://rpc.ankr.com/fantom/ws/<YOUR_PRIVATE_KEY>

Polygon wss://rpc.ankr.com/polygon/ws/<YOUR_PRIVATE_KEY>

Solana wss://rpc.ankr.com/solana/ws/<YOUR_PRIVATE_KEY>

02 - Test with wscat

The easiest way to test out your websocket endpoint is to install a command line tool such as wscat

Use wscat to send Curl requests as in the Curl example below

03 - Websocket endpoint examples

wscat -c wss://multi-rpc.com/avalanche/ws/YOUR-PRIVATE-ENDPOINT`

Connected (press CTRL+C to quit)

> {"jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newHeads"]}


> {"jsonrpc": "2.0", "id": 2, "method": "eth_unsubscribe", "params": ["The result value returned after successful subscription"]}