jpcx / node-kraken-api Goto Github PK
View Code? Open in Web Editor NEWa typed REST/WS Node.JS client for the Kraken cryptocurrency exchange
License: MIT License
a typed REST/WS Node.JS client for the Kraken cryptocurrency exchange
License: MIT License
Hello,
For a few days I have been receiving an error on my code which has been working for some time and I cannot find what is causing the problem
Using the exportStatus method I have a return EGeneral:Invalid arguments
the only arguments is a string report, I hardly see how I can be wrong on this arguments
here is my test code (is the same on my original code):
import { Kraken } from 'node-kraken-api'
const apikey = {
pubKey: '************.....',
privKey: '************.....',
}
const apiKraken = new Kraken({
key: apikey.pubKey,
secret: apikey.privKey
});
(async () => {
try {
const balance = await apiKraken.balance();
console.log(balance) // Good
const status = await apiKraken.exportStatus({ report: "ledgers" });
console.log(status) // Error
} catch (error) {
console.error(error)
}
})();
This is the returned error:
PS tests> node .\test.js
RESTAPIError: ["EGeneral:Invalid arguments"]
at _UTF8Receiver.finalize (node_modules\node-kraken-api\index.js:915:23)
at IncomingMessage.<anonymous> (node_modules\node-kraken-api\index.js:1081:21)
at IncomingMessage.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1334:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
body: { error: [ 'EGeneral:Invalid arguments' ] }
I specify that I made several tests with the same code by asking balance for example and using another api key, the code works well for balance and my file is saved in UTF8
Thank you for the time to see if on your side the error is also returned
Hi Justin,
Thanks for the awesome work.
When i was using subscribe function from websocket, it basically return:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
code: 'ERR_UNHANDLED_REJECTION'
}
Even adding catch() doesn't help on this case.
Any help would be appreciated
Hi I notice that subscribing on ohlc using web socket does not return all data.
this.krakenClient.ws.ohlc({interval: topic.interval})
.on('update', (update, pair) => {
this.processOhlcMessage(update, pair)
})
.on('status', (status) => {
this.logger.log(`${status.event}, ${status.channelName} for pair ${status.pair} = ${status.status}`)
})
.on('error', (error, pair) => {
this.logger.error(`Unable to get ohlc data from Kraken for pair: ${pair.pair}`, error.stack)
})
.subscribe(...topic.pairs)
on update event will return array of data and pair defined here https://docs.kraken.com/websockets/#message-ohlc but it will not return channel name. Chanell name is important because we can extract interval from it, for example ohlc5-1440, we know that this is update for interval 1440.
It is even better if we can have third parameter return on update event for ohlc which is interval specified for which we are getting response, or simply return channel name with array and pairs.
I have 2 instances of an object that use this library with different api key/secret. It seems the 2nd instance overwrites the settings for the first.
So, for example, if I get balances I always get the values from the account that was initialized last even though the api/kraken
object is initialized with different key/secret.
Hello,
It is possible to add the missing methods ?
AddOrderBatch, CancelOrderBatch
Thanks you very much
Best regards
https://docs.kraken.com/rest/#tag/Funding/operation/getWithdrawalMethods
This method is not in the package, but it should be. It's quite useful to get information about withdrawal fees for all assets at once.
Howdy,
Sweet project! I'm just now checking it out, and have to say it would be much easier to prototype with some static TypeScript types.
Not sure if this repository is actively maintained (last commit 3 years ago), if not then DefinitelyTyped would be the best option forward
Opening this issue to track interest and any effort towards this goal
Context:
I am using the addOrder method from the kraken module in a Node.js environment to place orders on the Kraken exchange.
Error Message:
Uncaught RESTAPIError: ["EGeneral:Invalid arguments:volume"]
at _UTF8Receiver.finalize (~/node_modules/node-kraken-api/index.js:978:31) {
body: { error: [ 'EGeneral:Invalid arguments:volume' ] }
Reproduction Steps:
const { txid } = await kraken.addOrder({ pair: "MATIC/EUR", type: "buy", ordertype: "limit", price: "0.9237", volume: "5" });
Expected Behavior:
I expected the addOrder method to successfully place the buy order for 5 units of MATIC/EUR at a limit price of 0.9237.
Actual Behavior:
Instead, I encountered the "EGeneral:Invalid arguments:volume" error message, indicating an issue with the volume parameter.
Environment:
Node.js version: 16.14.0
node-api-kraken module version: 2.2.2
Operating System: macOs 14.2.1 (23C71)
Additional Information:
I have tried adjusting the parameters, such as converting the volume parameter to a number instead of a string, but the error persists.
Tags/Labels:
error
hi there,
I am calling the api with the following code, but get the error :
Error: EAPI:Invalid nonce
Can you please point out what I am doing incorrectly ?
#!/usr/bin/env node
const fs = require('fs');
const kraken = require('node-kraken-api');
const api = kraken({
key: fs.readFileSync('creds.key').toString('utf8'),
secret: fs.readFileSync('creds.private').toString('utf8')
});
// api.call('Depth', { pair: 'XXBTZUSD', count: 1 })
// .then(data => console.log(data))
// .catch(err => console.error(err))
api.call('Balance')
.then(data => console.log(data))
.catch(err => console.error(err))
Awesome strongly typed lib, Justin... thanks for this. :) Getting this Error when calling getWebSocketsToken() (line 10 in the image). Had been seeing the same with some other REST calls I'd tried as well. My work around has been to use https://www.npmjs.com/package/kraken-api ) to get the token (and other REST calls) and then provide that token to node-kraken-api private websocket connection. Privates work like a champ after that!
Is there something I'm missing that I need to do? Nonce window for my Kraken API keys is set to 0. Tips?
(node:16640) UnhandledPromiseRejectionWarning: Error: ["EAPI:Invalid nonce"] at _UTF8Receiver.finalize (E:\slab\dev\kraken-ws-rt-work\node_modules\node-kraken-api\index.js:915:31) at IncomingMessage.<anonymous> (E:\slab\dev\kraken-ws-rt-work\node_modules\node-kraken-api\index.js:1081:29
Hi!
I try to use the websockets to fetch some data from Kraken, but after the subscribe function runs properly, I don't receive any further messages. This is my code:
const kraken = new Kraken();
const subscribers: Record<string, KrakenSubscriberType> = {};
const subscribe = async (pair: string) => {
if (typeof subscribers[pair] != 'undefined') {
Logger.warn(`You are already subscribed for kraken's '${pair}' ticker channel!`);
return;
}
subscribers[pair] = await kraken.ws
.ohlc({ interval: 1 })
.on('payload', (payload, pair) => Logger.info('payload', payload, pair))
.on('update', (update, pair) => Logger.info('update', update, pair))
.on('error', (error, pair) => Logger.info('error', error, pair))
.on('status', status => Logger.info('status', status))
.subscribe(pair);
Logger.info(`Successfully subscribed to the '${pair}' kraken ticker channel!`);
};
Sample output:
[2023-06-27 21:06:17] (INFO): status {"channelID":4247,"channelName":"ohlc-1","event":"subscriptionStatus","pair":"TBTC/EUR","reqid":1687892776395,"status":"subscribed","subscription":{"interval":1,"name":"ohlc"}}
[2023-06-27 21:06:17] (INFO): Successfully subscribed to the 'TBTC/EUR' kraken ticker channel!
[2023-06-27 21:06:17] (INFO): update ["1687874734.507294","1687874760.000000","27700.00000","27700.00000","27700.00000","27700.00000","27700.00000","0.00025000",1] TBTC/EUR
[2023-06-27 21:06:17] (INFO): payload [4247,["1687874734.507294","1687874760.000000","27700.00000","27700.00000","27700.00000","27700.00000","27700.00000","0.00025000",1],"ohlc-1","TBTC/EUR"] {"channelID":4247,"channelName":"ohlc-1","event":"subscriptionStatus","pair":"TBTC/EUR","reqid":1687892776395,"status":"subscribed","subscription":{"interval":1,"name":"ohlc"}}
Hi,
I'm subscribing to many orderbooks at once (more than 100) using this sample code
const book100 = await kraken.ws.book({depth: 100})
// live book construction from "snapshot", "ask", and "bid" events.
.on("mirror", (mirror, pair) => console.log(mirror, pair))
.on("error", (error, pair) => console.log(error, pair))
// resubscribes if there is a checksum validation issue (emits statuses).
.on("status", (status) => console.log(status)
.subscribe("XBT/USD", "ETH/USD", .....); // subscribe to multiple pairs at once
Most of them subscribe within a few seconds, but a few take some minutes. Any idea what could be causing this delay?
Thank you
Hi bro, i was trying to use the stake function, but it has a required param called "method", i was searching in to Kraken API documentation but i didn't find something about it.
I think in an older version it was required but now i tried removing it from the required params and it worked.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.