tokens-net
TokensNet REST client
README Overview
Install
Install with npm i tokens-net
Example
You can find a runnable example here, run via npm run example
// import { TokensNet } from "tokens-net";const TokensNet = ; // Secretsconst key = "XXX";const secret = "XXX"; const tokens = key secret; async { /* The promise only rejects on network errors or timeouts. A successfull promise always resolves in an object containing status, headers and body. status is the http status code as number, headers is an object of http response headers and body is the parsed JSON response body of the api, you dont need to parse the results yourself you can simply continue by accessing the object. */ /* PUBLIC */ const ticker = await tokens; console; const tickerHour = await tokens; console; const trades = await tokens; console; const pairs = await tokens; console; const orderbook = await tokens; console; /* PRIVATE */ const balance = await tokens; console; const allOpenOrders = await tokens; console; const openOrders = await tokens; console; const order = await tokens; console; const cancled = await tokens; console; const opened = await tokens; console;};
Debug Info
DEBUG=tokens-net:* npm start
A word on parallel requests
- The client will never generate the same nonce for two requests.
- But a new request must always contain a higher nonce, than the last request before.
- When you make multiple calls in parallel (pretty easy in node..) there is a chance
that the later calls reach the bitstamp api earlier than the first, causing the first
requests to fail with an
invalid nonce
error. - To prevent this you should make these calls sequentially.
Inspiration
https://github.com/krystianity/node-bitstamp
License
MIT