V2 Migration Guide
Starting with V2, the markets endpoint is paginated, which introduces a change to the way markets are retrieved using the SDK.
A line of code like this:
const zrxWethMarket = rr.markets.get('ZRX-WETH');
const zrxWethMarket = await rr.markets.getAsync('ZRX-WETH');
Because the markets are retrieved asynchronously, they are returned by the underlying cache asynchronously, too. You can also populate the underlying cache with a specific page or markets or the next page, like so:
// Get a specific page with a specific result count. const page = 5; const perPage = 25; await rr.markets.getPageAsync(page, perPage); // Returns the resulting page of markets and caches them. // Populate the next page of markets (each page consists of 100 markets). await rr.markets.getNextPageAsync(); // Returns the resulting page of markets and caches them too.
In the markets initialization step of the SDK setup, the ZRX/WETH market is explicitly retrieved, along with the first page of 100 markets. In simple use-cases, you shouldn't have to worry about other changes in our feed and trade APIs, the SDK is already updated to handle the new schemas and endpoints seamlessly.
tokens properties of an SDK instance were derived from a TypeScript implementation of ES6 Map which included a
size() method to return the number of entries in the cache. The
tokens property is now a plain ES6 map, which uses a
size property as opposed to a method getter. So lines of code like the following:
const numTokens = rr.tokens.size(); const numMarkets = rr.markets.size();
would be rewritten as:
const numTokens = rr.tokens.size; const numMarkets = rr.markets.size;
markets property shares the above change, but note that
markets is not a plain ES6 map, rather a custom collection object with very similar features. It shares all the same methods and properties as ES6 map excluding
set methods. It's also iterable, so you can use it in a
for... of... block!
Our markets endpoint is now more modular, breaking out the market's base, ticker, history, and stats. You can specify which parts of a market you'd like in the response with the
include query parameter.
An example request might look like the following:
curl https://api.radarrelay.com/v2/markets?include=base,ticker,stats,history # OR curl https://api.radarrelay.com/v2/markets/ZRX-WETH?include=base,ticker,stats,history
By default, only the market's base is returned in the response.
Feed API Gotchas
- Our pagination middleware limits requests to 100 items per page. The affected endpoints are
per_pagequery parameter is now
perPage. The old nomenclature will no longer work.
Trade API Gotchas
saltproperty of an order is expected to be a Unix timestamp.
signatureproperty is simplified to be a hex string encoded.