Get Data

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.1

1. Listing Available Tokens

To obtain a list of tokens that are currently available or were previously available on Radar Relay. Use the v2/tokens endpoint.

cURL Example

$ curl https://api.radarrelay.com/v2/tokens

2. Listing Available Markets

To obtain a list of markets that are currently available available on Radar Relay. Use the v2/marketsendpoint.

cURL Example

$ curl https://api.radarrelay.com/v2/markets

3. Listing Market Data

To obtain market data. Pass a market id from the previous example into a market data endpoint, like so:/v2/markets/zrx-weth/book.

The available market data endpoints are: book | fills | ticker | candles

cURL Example

$ curl https://api.radarrelay.com/v2/markets/zrx-weth/book

4. WebSockets

To subscribe to an order book WebSocket. Send a RadarSubscribeRequest to the WebSocket endpoint: wss://ws.radarrelay.com/v2.

Example Order Book Subscription

// npm install websocket@1.0.25 --save
const 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 snapshot
send(`{
"type": "SUBSCRIBE",
"topic": "BOOK",
"market": "ZRX-WETH", // e.g. 'ZRX-WETH'
"requestId": 1 // optional requestId
}`);
// Send a ping every 10s
// to keep the connection live
setInterval(function(){
lastPing = new Date().getTime();
connection.ping();
}, 10000);
});
client.connect('wss://ws.radarrelay.com/v2');