This is an official NodeJS wrapper for the Wazirx exchange REST and WebSocket APIs.
We are now at 1.0 and there may be things breaking, don't hesitate to raise an issue if you feel so!
Generate API KEY and Secret Key from Wazirx website here
Clone the repo and run the
npm install
- Basic implementation of REST API
- Easy to use authentication
- Methods return parsed JSON
- No need to generate timestamps
- No need to generate signatures
- Basic implementation of WebSocket API
- Call
connect
method for initiating connection - Single and multiple streams supported
- All methods runs with
await
call inside async function
- Call
- Exception handling with responses
- High level abstraction
Require Wazirx Node Rest Client:
const { Client } = require('@wazirx/node-client').v1;
Create a new instance of the REST Client:
// If you only plan on touching public API endpoints, no need to pass any arguments
let client = new Client();
// Otherwise provide an apiKey and secretKey as keyword arguments
let client = new Client(apiKey, secretKey);
Create various requests:
client.ping
Response:
{ data: {}, status: 200 }
client.time
Response:
{ data: { serverTime: 1641952885079 }, status: 200 }
client.systemStatus
Response:
{
data: { status: 'normal', message: 'System is running normally.' },
status: 200
}
client.exchangeInfo
Response:
{
data: {
"timezone": "UTC",
"serverTime": 1641952969748,
"symbols": [
{
"symbol": "wrxinr",
"status": "trading",
"baseAsset": "wrx",
"quoteAsset": "inr",
"baseAssetPrecision": 5,
"quoteAssetPrecision": 0,
"orderTypes": [
"limit",
"stop_limit"
],
"isSpotTradingAllowed": true,
"filters": [
{
"filterType": "PRICE_FILTER",
"minPrice": "1",
"tickSize": "1"
}
]
}
]
}
}
client.order({symbol: 'btcinr', side:'buy', type: 'limit', recvWindow: 10000, quantity:1, price:50});
Response:
{data:{"id"=>27007862, "symbol"=>"btcinr", "type"=>"limit", "side"=>"buy",
"status"=>"wait", "price"=>"210.0", "origQty"=>"1.0", "executedQty"=>"0.0",
"createdTime"=>1632310960000, "updatedTime"=>1632310960000}}
For other methods follow this.
For example and better understanding the api client usage refer here
Required and optional parameters, as well as enum values, can currently be found on the Wazirx Documentation. Parameters should always be passed to client methods as keyword arguments in snake_case form.
Require Wazirx Node WebSocket Client:
const { WsClient } = require('@wazirx/node-client').v1;
Create a new instance of the REST Client:
# If you only plan on touching public API endpoints, you can forgo any arguments
let ws = new WsClient();
# Otherwise provide an api_key and secret_key as keyword arguments
let ws = new WsClient(apiKey, secretKey);
Make sure to call connect
before start using other Methods
await ws.connect().catch((err) => {
console.log(err);
});
Create various WebSocket streams:
# Pass the symbol/symbols to subscribe to trades
await ws.trades(['btcinr','wrxinr'], 0, 'subscribe');
# Pass the symbol/symbols to subscribe to depth
await ws.depth(['btcinr','wrxinr'], 0, 'subscribe');
# For all market tickers
await ws.allMarketTicker(['btcinr','wrxinr'], 0, 'subscribe');
symbol
can beArray
for multiple.id
by default is0
, for unique identification any positive integer can be used.action
only needs to pass in case ofunsubscribe
, default issubscribe
if no data passed.
User data streams utilize both the REST and WebSocket APIs.
Request a listen key from the REST API, and then create a WebSocket stream using it.
await ws.userStream(['orderUpdate', 'ownTrade', 'outboundAccountPosition'], 0, 'subscribe');
For other websocket methods follow this.
For example and better understanding the websocket client usage refer here
After checking out the repo, run npm install
to install dependencies. Then, run npm test
to run the tests. You can also run node sample/index.js
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at Issues.
The gem is available as open source under the terms of the MIT License.