Olmeca DEX
  • Bienvenido a Olmeca Relay API
  • Iniciando
    • Get Data
  • Nodos
    • Nodos
  • API
    • Mercados
    • Ordenes
    • Tokens
    • WebSockets
    • Changelog
  • Trade API
    • Trade API
Powered by GitBook
On this page
  • 1. Listing Available Tokens
  • cURL Example
  • 2. Listing Available Markets
  • cURL Example
  • 3. Listing Market Data
  • cURL Example
  • 4. WebSockets
  • Example Order Book Subscription

Was this helpful?

  1. Iniciando

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 keybut API requests are limited to 120/min

1. Listing Available Tokens

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

cURL Example

$ curl https://api.olmecarelay.com/v3/tokens

Learn more about the v3/tokens endpoint.

2. Listing Available Markets

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

cURL Example

$ curl https://api.olmecarelay.com/v3/markets

Learn more about the v3/markets endpoint.

3. Listing Market Data

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 Example

$ curl https://api.olmecarelay.com/v3/markets/zrx-weth/book

Learn more about the getting specific market data from the v3/markets endpoint.

4. WebSockets

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

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/v3');
PreviousBienvenido a Olmeca Relay APINextNodos

Last updated 5 years ago

Was this helpful?

Download a boilerplate example.