Websocket URL: wss://ws.web3api.io
Due to the huge volume of data for order book events and tickers, please use the following dedicated URLs when subscribing to these type of data.
Subscription | Connection URL |
---|---|
market:futures:order:events market:futures:tickers market:futures:liquidations | wss://ws.web3api.io/futures |
market:options:order:events market:options:tickers | wss://ws.web3api.io/options |
market:spot:reference-quote:1s | wss://ws.web3api.io/quotes |
market:spot:order:events market:spot:tickers | wss://ws.web3api.io/spot |
market:swaps:order:events market:swaps:tickers market:swaps:liquidations | wss://ws.web3api.io/swaps |
market:dex:trades | wss://ws.web3api.io/defi/dex |
<any other subscription> | wss://ws.web3api.io |
In order to establish a connection between client and server an initial http handshake is required. This is known as subscribing. Subscription requests are performed using JSON-RPC, similar to Geth and Parity.
All subscriptions follow the same pattern, let's first cover what all websocket subscription endpoints share in common before diving into the types of subscriptions and their response formats. To explore these API's, we will use the npm-provided command wscat, but any websocket-client library will work.
Note: If a valid API key is not found in the initial request you will receive a response invalid api key '<api_key>'
and the websocket connection will be closed. If you don't have an API Key at this time please see Authentication for more details on obtaining one.
You may optionally include a blockchain-id
with the request. If no blockchain id is supplied then it will default to ethereum-mainnet
. Refer to the Blockchain Id to obtain a list of blockchain ids.
First, connect to the Amberdata web3api.io endpoint via SSL websocket with your API key:
Connecting
❯ npm install -g wscat
❯ wscat -c "wss://ws.web3api.io" -H "x-api-key: <api-key>" -H "x-amberdata-blockchain-id: ethereum-mainnet"
connected (press CTRL+C to quit)
>
You are now connected and ready to initiate any websocket request.