1.1.3 • Published 1 month ago

valr-api-client v1.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
1 month ago

valr-api-client

VALR Api REST and web-socket client

See VALR API documentation

valr-api-client is a node.js client for calling the VALR(https://www.valr.com) REST and WebSocket API.

Examples

e.g. To call a rest end-point

const { ValrV1RestClient, ValrV1WsClient } = require('valr-api-client')

// N.B. keep these safe.  don't commit to source control etc...
var apiKey = '<your-api-key>';
var apiSecret = '<your-api-secret>';

const  valrClient = new ValrV1RestClient({ apiKey, apiSecret })
valrClient
    .account
    .getBalances()
        .then((balance) => console.log(balance))

e.g. To subscribe to the trade web socket events

var valrWsTradeClient = new ValrV1WsClient(ValrV1WsClient.WSPATHS.TRADE, { apiKey, apiSecret })
valrWsTradeClient.connect();

valrWsTradeClient.on('connected', () => console.log('TRADE:', 'connected'));

valrWsTradeClient.on('message', (data) => {
    if (data.type == 'AUTHENTICATED') {
        valrWsTradeClient.subscribe(ValrV1WsClient.TRADE_SUBSCRIPTIONS.AGGREGATED_ORDERBOOK_UPDATE, 'BTCZAR');
    } else if (data.type == ValrV1WsClient.TRADE_SUBSCRIPTIONS.AGGREGATED_ORDERBOOK_UPDATE) {
        console.log('TRADE OrderBook Updated:', util.inspect(data, { depth: 99, colors: true }));
    } else {
        console.log(data);
    }
});

valrWsTradeClient.on('error', (err) => console.log('TRADE:', err));
valrWsTradeClient.on('close', (code, reason) => console.log('TRADE:', code, reason));
valrWsTradeClient.on('disconnected', () => console.log('TRADE:', 'disconnected'));
1.1.3

1 month ago

1.1.2

2 years ago

1.1.1

2 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago