This tutorial walks you through retrieving Radar Relay market data. Using the REST api to retrieve market data does not require an account or API key but API requests are limited to 120/min.
To obtain a list of tokens that are currently available or were previously available on Radar Relay. Use the v3/tokens
endpoint.
$ curl https://api.radarrelay.com/v3/tokens
To obtain a list of markets that are currently available available on Radar Relay. Use the v3/markets
endpoint.
$ curl https://api.radarrelay.com/v3/markets
To obtain market data. Pass a market id from the previous example into a market data endpoint, like so:/v3/markets/zrx-weth/book
.
The available market data endpoints are: book | fills | ticker | candles
$ curl https://api.radarrelay.com/v3/markets/zrx-weth/book
To subscribe to an order book WebSocket. Send a RadarSubscribeRequest to the WebSocket endpoint: wss://ws.radarrelay.com/v3
.
// npm install websocket@1.0.25 --saveconst WebSocketClient = require('websocket').client;const client = new WebSocketClient({tlsOptions: {rejectUnauthorized: false}});let lastPing = new Date().getTime();client.on('connectFailed', function(error) {console.log('Connect Error: ' + error.toString());});client.on('connect', function(connection) {console.log('Connected to Server...');connection.on('error', function(error) {console.log("Connection Error: " + error.toString());});connection.on('close', function() {console.log('Connection Closed');});connection.on('message', function(message) {if (message.type === 'utf8') {console.log(message.utf8Data);}});connection.on('pong', function(){console.log('[pingpong] response took', (new Date().getTime() - lastPing) + 'ms');})function send(message) {if (connection.connected) {connection.sendUTF(message);}}// subscribe with snapshotsend(`{"type": "SUBSCRIBE","topic": "BOOK","market": "ZRX-WETH", // e.g. 'ZRX-WETH'"requestId": 1 // optional requestId}`);// Send a ping every 10s// to keep the connection livesetInterval(function(){lastPing = new Date().getTime();connection.ping();}, 10000);});client.connect('wss://ws.radarrelay.com/v3');