From a3b52e3c1e169d9a7a7e892ac2f8b82be973ebad Mon Sep 17 00:00:00 2001 From: Balthazar Gronon Date: Tue, 2 Jan 2018 20:43:50 -0800 Subject: [PATCH] Add exchangeInfo route Closes #16. --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/http.js | 1 + test/index.js | 5 ++++ 3 files changed, 69 insertions(+) diff --git a/README.md b/README.md index 510eb0ed..1c661dae 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Following examples will use the `await` form, but that's totally up to you. - [Public REST Endpoints](#public-rest-endpoints) - [ping](#ping) - [time](#time) + - [exchangeInfo](#exchangeinfo) - [book](#book) - [candles](#candles) - [aggTrades](#aggtrades) @@ -92,6 +93,68 @@ console.log(await client.time()) +#### exchangeInfo + +Get the current exchange trading rules and symbol information. + +```js +console.log(await client.exchangeInfo()) +``` + +
+Output + +```js +{ + "timezone": "UTC", + "serverTime": 1508631584636, + "rateLimits": [ + { + "rateLimitType": "REQUESTS", + "interval": "MINUTE", + "limit": 1200 + }, + { + "rateLimitType": "ORDERS", + "interval": "SECOND", + "limit": 10 + }, + { + "rateLimitType": "ORDERS", + "interval": "DAY", + "limit": 100000 + } + ], + "exchangeFilters": [], + "symbols": [{ + "symbol": "ETHBTC", + "status": "TRADING", + "baseAsset": "ETH", + "baseAssetPrecision": 8, + "quoteAsset": "BTC", + "quotePrecision": 8, + "orderTypes": ["LIMIT", "MARKET"], + "icebergAllowed": false, + "filters": [{ + "filterType": "PRICE_FILTER", + "minPrice": "0.00000100", + "maxPrice": "100000.00000000", + "tickSize": "0.00000100" + }, { + "filterType": "LOT_SIZE", + "minQty": "0.00100000", + "maxQty": "100000.00000000", + "stepSize": "0.00100000" + }, { + "filterType": "MIN_NOTIONAL", + "minNotional": "0.00100000" + }] + }] +} +``` + +
+ #### book Get the order book for a symbol. diff --git a/src/http.js b/src/http.js index eb51d425..7849d3f9 100644 --- a/src/http.js +++ b/src/http.js @@ -171,6 +171,7 @@ export default opts => { return { ping: () => publicCall('/v1/ping').then(() => true), time: () => publicCall('/v1/time').then(r => r.serverTime), + exchangeInfo: () => publicCall('/v1/exchangeInfo'), book, aggTrades, diff --git a/test/index.js b/test/index.js index 05f304d1..7d16ca2b 100644 --- a/test/index.js +++ b/test/index.js @@ -20,6 +20,11 @@ test.serial('[REST] time', async t => { t.truthy(new Date(ts).getTime() > 0, 'The returned timestamp should be valid') }) +test.serial('[REST] exchangeInfo', async t => { + const res = await client.exchangeInfo() + checkFields(t, res, ['timezone', 'serverTime', 'rateLimits', 'symbols']) +}) + test.serial('[REST] book', async t => { try { await client.book()