nothingisdead / npm-kraken-api Goto Github PK
View Code? Open in Web Editor NEWNodeJS Client Library for the Kraken (kraken.com) API
License: Other
NodeJS Client Library for the Kraken (kraken.com) API
License: Other
All endpoints that I'm hitting are working correctly, except "WithdrawStatus", "DepositMethods" and "DepositStatus" (and probably some others that I haven't tried), that require just asset
.
My request input params are, f.e. {asset: 'XXBT'}
or {asset: 'ZEUR'}
. The EAPI: Invalid signature
means that the input is not correct (the conclusion is derived from previous experience).
I talked with the tech support and that didn't help.
I am not saying the problem is in this module, but rather I'm asking whether someone knows why is this happening and how to fix it?
Working with React 16.4 it doesn't allow responses without Access-Control-Allow-Origin'. I've got this error:
Failed to load https://api.kraken.com/0/private/Balance: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
How can we set the request to {'mode': 'no-cors'}?
Thank for your help.
Please could you update the got
dependency to the last version?
In some case it appears that using got is throwing some timeout errors.
I saw some people complaining about that as well in other projects using got
.
Updating got
to the last version seems to resolve the issue.
Thanks
Hi,
I haven't really had time to maintain this library for a while now, and I don't use Kraken anymore so it's difficult for me to test pull requests. I know that it's still used in a lot of projects, so if someone would like to volunteer to maintain it, please let me know!
I'm using a pattern of
function callKraken(method, params, next) {
async.retry(3, next => {
kraken.api(method, params, next);
}, next);
}
If I rely on Kraken-Api to set the nonce, then all my retries will fail with "API: Invalid nonce".
Work around: I'll set the nonce myself.
Fix suggestion: Kraken-Api does not alter params other than a possible copy of params.
when I import the kraken-api
and run the project.
I get this error.
const rawRequest = async (url, headers, data, timeout) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Volumes/Work/SourceTree/financial/dist/market/Kraken.js:11:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Volumes/Work/SourceTree/financial/dist/test.js:17:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
The API is throwing a lot of errors with the current timeout (even though requests get processes by kraken). I have an extremely better experience with 60. It should be expected to deal with huge delays when working with kraken.
There is an error, when adding an order. It says:
[ 'EGeneral:Invalid arguments:volume' ]
Is this due to a different naming or change in the API?
This is the code I use:
kraken.api('AddOrder', { 'pair': 'XBTCZEUR', 'type': 'buy', 'ordertype': 'limit', 'price': '10000.0', 'volume': '1.0' }, function(error, data) {
if(error) {
console.log("ERROR WHILE ORDERING.");
console.log(error);
}
else {
console.log("ADDED ORDER.");
console.log(data);
}
});
Same occurs with the PHP-API-Client.
Hello I've gotten the script working for buying USDT with ETH but when I try and sell the USDT for ETH I get insufficient funds error, even though I am sure I have more USDT than the 3 it would require for this test to submit an order, does anyone have suggestions?
const KrakenClient = require('kraken-api'); const kraken = new KrakenClient(key, secret); var vend = "sell"; var volume = 0.2; var price = 15; (async () => { // Get Ticker Info //var value = await kraken.api('AddOrder', { pair : 'ETHUSDT', type :
${type}, orderType: 'limit', price:
${price}, volume :
${volume}}); var value = await kraken.api('AddOrder', { pair : 'ETHUSDT', type :
${vend}, ordertype: 'limit', price:
${price}, volume:
${volume} }); var arrays = JSON.stringify(value); console.log(arrays); })();
I had added support for AddExport previously (#72) and that worked like a charm.
However after krakens most recent api update (I assume, timing fits) AddExport stopped working. Kraken server will give "Invalid Arguments" error. Same call with python example code works.
I'm in talk with kraken support about this, but I thought I'd leave it here, too.
I tried your module with node v0.11.14 since kraken-api is using the binary format which is deprecated now in recent nodejs versions
There must me something wrong with the request module since I always got [Error: Kraken API returned error: General:Internal error]
So I replaced the call to request by a standard https request and this is now working
Not sure what the pb is exactly but at least you should replace the binary format and see what happens with recent nodejs versions, maybe take a look at https://github.com/Ayms/bitcoin-wallets/blob/master/SHA256Compress.js for "stupid" binary manipulations
I am having the following code in index.js
and I'm trying to call a private api endpoint:
const key = 'FWdFaXOLt8B4ihmGC6a....4kTEMH8LffmLWt'; // API Key
const secret = 'fo1Ck2I5VRwqZBWcE1FCcwqdqC....IReqqwd8C9r...A=='; // API Private Key
const KrakenClient = require('kraken-api');
const kraken = new KrakenClient(key, secret');
(async () => {
try {
// Display user's balance
console.log(await kraken.api('Balance'));
// Get Ticker Info
console.log(await kraken.api('Ticker', { pair : 'XXBTZUSD' }));
} catch (e) {
console.log(e);
}
})();
When I run node index.js
;
To read the Balance
Error: General:Permission denied
at rawRequest (home/me/worpskace/project-kraken/node_modules/kraken-api/kraken.js:54:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
Version used : [email protected]
Node: v9.6.0
Npm: 5.6.0
Extract an API key with read permissions.
The dependency tree for Got is very large, for needle it's just 3. Please compare:
http://npm.anvaka.com/#/view/2d/got
http://npm.anvaka.com/#/view/2d/needle
What is excellent about your package is that anyone can easily read and review all of your code. However, the use of Got makes it very dificult to trust the dependecy tree.
why this error timeout? how i can solve?
(node:2119) UnhandledPromiseRejectionWarning: RequestError: Timeout awaiting 'request' for 5000ms
at ClientRequest.<anonymous> (/content/iwin2/node_modules/got/dist/source/core/index.js:956:65)
at Object.onceWrapper (events.js:422:26)
at ClientRequest.emit (events.js:327:22)
at ClientRequest.origin.emit (/content/iwin2/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
at Timeout.timeoutHandler [as _onTimeout] (/content/iwin2/node_modules/got/dist/source/core/utils/timed-out.js:36:25)
at listOnTimeout (internal/timers.js:556:17)
at processTimers (internal/timers.js:497:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2119) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2119) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hi,
The API worked very well till the 2 factor authent (A2F).
Do you know how to connect with static password as configured on Kraken site. Following your exemple, I tried:
const kraken = new KrakenClient(key, secret, staticPassword);
...
console.log(await kraken.api('Balance'));
leads to a 'API error Balance call: Error: API:Invalid signature
at rawRequest (C:\Utils\D\Dropbox\CryptoMoney\kraken-eye\kraken.js:54:9)
at process._tickCallback (internal/process/next_tick.js:103:7)'
FYI:
const kraken = new KrakenClient(key, secret);
...
console.log(await kraken.api('Balance'));
leads to a 'API error Balance call: Error: General:Permission denied'
Thanks for your help,
I'm trying to get my tradebalance of a certain asset on Kraken. However I'm getting a vague internal error.
Response.error: EGeneral:Internal error
It throws the exception at kraken.js:54
Code
kraken.api('TradeBalance', { asset: 'XBT' }, function(error, data) { ... }):
Please mention that this package is only compatible with node version 8. Because it uses async/wait functions.
request
is too bloated for this purpose. Recommend using needle instead.
I wrote the following code to set up a test sell order on kraken. However, the response that I got back from this code is: 'EAPI:Invalid key'
var param = {
'pair': 'XXBTZEUR',
'type': 'sell',
'ordertype': 'limit',
'price': '721.003',
'volume': '.01'
};
kraken.api('AddOrder', param, function(error, data){
if(error){
console.log(error);
} else {
console.log(data.result);
}
});
I am sure that I got the right key since I can properly call and see the balance on my own account.
Here is the screen capture of my key's permission: https://goo.gl/N5Cnp7. It has all the boxes checked except deposit and withdraw funds.
I know this may not be coming from npm-kraken-api but kraken's. I just want to make sure :)
The ticker example code does fails to return the array outputs. The following works to get content of the arrays.
` // Get Ticker Info
console.log(JSON.stringify(await kraken.api('Ticker', { pair : 'XETHZUSD' })));
`
Hi
I am attempting to CancelOrders
, but it doesn't work.
Can someone perhaps give me an example?
This is my code:
await kraken.api("CancelOrder", {"txid":"hidden-hidden-hidden"});
Here is the Error:
...kraken-api/kraken.js:54 throw new Error(error.join(', ')); ^ Error: Order:Unknown order
Using your nice little tool to communicate with Kraken, but getting EAPI:Invalid nonce from Kraken. Tried to console.log the nonce generated, and it increments nicely. Yet still getting error from Kraken, not consistently but rather randomly and often. And when I get it, its when I run two calls in parallel, not waiting for one to complete before the other initiates (not chaining them thru the callback). The nonce increments with 2000 or 3000 (2-3 miliseconds). I have tried using a variety of different key/secret to Kraken, but same result. Any idea what it could be or how to investigate further.
added: Im thinking it may be a race condition on the internet, in which the latter request sometimes passes the former request en route to Kraken. This is solved by always sequencing two dependent calls to Kraken. But if my service becomes busy and receives two independent request each going to Kraken around the same time, Im back to facing the same issue. Any suggestions ?
Hi.
I tried to use the lib in an ionic/angular app but parameters failed with the error: "EGeneral: invalid arguments"
adding "headers['Content-Type'] = 'application/x-www-form-urlencoded';" to line 35 in kraken.js fixed the error, maybe you can include this in future versions?
Thanks for the nice lib :-)
kind regards.
Hummm, I really don't know why it would like to resolve electron xD
Is there anyone else having this problem?
I'm using webpack to bundle my JS.
Ahh here the problem
sindresorhus/got#345
cheers!
There are 11 pull requests that all look like they make sense and tons of open issues. It doesn't look like this is maintained any more, but it's reachable through npm...
There are 181 forks of this code. Who knows which one is well-maintained and can be installed through npm.
Anyone have other suggestions on what to use, like maybe https://github.com/jpcx/node-kraken-api ?
Hi,
I am getting this error, all seems ok, the Api key is good, so I guess the problem comes from the encoding. Is someone having or had the same problem
Regards.
Hi,
I'm just new at all of this. But when i try to run the example code i get this error
(node:1420) UnhandlesPromiseRejectionWarning: unhandled promise rejection (rejection id: 1) Error: General: Premission denied
(node1420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Is it me or the code?
When I use the module locally everything is fine but when used on Heroku I get the following error:
2017-08-11T10:34:14.648559+00:00 app[web.1]: /app/node_modules/kraken-api/kraken.js:31
2017-08-11T10:34:14.648573+00:00 app[web.1]: const rawRequest = async (url, headers, data, timeout) => {
2017-08-11T10:34:14.648575+00:00 app[web.1]:
2017-08-11T10:34:14.648575+00:00 app[web.1]: SyntaxError: Unexpected token (
2017-08-11T10:34:14.648576+00:00 app[web.1]: at createScript (vm.js:56:10)
2017-08-11T10:34:14.648576+00:00 app[web.1]: at Object.runInThisContext (vm.js:97:10)
2017-08-11T10:34:14.648577+00:00 app[web.1]: at Module._compile (module.js:542:28)
2017-08-11T10:34:14.648578+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-08-11T10:34:14.648578+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-08-11T10:34:14.648579+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-08-11T10:34:14.648580+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-08-11T10:34:14.648580+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-08-11T10:34:14.648581+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-08-11T10:34:14.648582+00:00 app[web.1]: at Object.<anonymous (/app/bin/krakenBalances.js:1:84)
The corresponding code line generating the error is just the loading of the package:
const KrakenClient = require('kraken-api');
I use:
- kraken-ap v1.0.0
- node v8.2.1
Do you have any suggestion ?
Thank you for your help
kraken.api("CancelAll");
Error: CancelAll is not a valid API method. at KrakenClient.api (/workspace/node_modules/kraken-api/kraken.js:99:10)
https://api.kraken.com/0/private/CancelAll
it's a thing now
https://www.kraken.com/en-us/features/api#general-usage
TypeError: response.error.filter is not a function
at rawRequest (/home/ibinex/bridge/node_modules/kraken-api/kraken.js:47:5)
at
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
Hi Kraken Team,
After a few API requests i start gettting Error: API:Invalid nonce
I already increased by the nonce window from 7 to 7000 & 15000, i got the same result anyway.
I also start sparsing by calls to the API by random milliseconds, it did not help either... :(
Error: API:Invalid nonce
at rawRequest (C:\Users\adomingues\Documents\testKraken\node_modules\kraken-api\kraken.js:54:9)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
Any help?
Thanks,
Axel
const res = await client.api("Time");
My app was working few months ago and now i don't know why but the rawrequest function don't work anymore in the repo. It put POST request to everything and some function like Time are GET request so the API return this error. I try to replace the POST with GET so Time works now but all others API path won't work. Any idea how to fix it?
Thank you
Good morning,
I am trying to make purchases but they do not work, and they return error, why?
Code:
var buy1 = await kraken.api('OpenOrders', {
pair : 'XETHXXBT',
type : buy,
ordertype: market,
volume: 0.10
});
console.log(buy1);
Error:
UnhandledPromiseRejectionWarning: ReferenceError: buy is not defined
Thank you very much, greetings.
When using this API wrapper I sometimes receive following error:
Error: Error in server response: {"code":"ENOTFOUND","errno":"ENOTFOUND","syscall":"getaddrinfo"}
at Request._callback (node_modules/kraken-api/kraken.js:133:12)
at self.callback (node_modules/kraken-api/node_modules/request/request.js:121:22)
at Request.EventEmitter.emit (events.js:95:17)
at ClientRequest.self.clientErrorHandler (node_modules/kraken-api/node_modules/request/request.js:230:10)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at CleartextStream.socketErrorListener (http.js:1547:9)
at CleartextStream.EventEmitter.emit (events.js:95:17)
at Socket.onerror (tls.js:1445:17)
at Socket.EventEmitter.emit (events.js:117:20)
at net.js:833:16
at process._tickCallback (node.js:415:13)
Still using version of 28 june, anyway I'm getting "Error: Kraken API returned error: General:Invalid arguments:volume" whenever I try to set an order.
Funny thing is that this happens even if I don't include "volume" field in the json during the API call.
Have you been able to make the conditional close work? The addOrder documentation is very unclear. I've tried many different combinations to enter the data, but none work.
Hi Robert, have you thought about sending a PR to integrate into https://github.com/michaelgrosner/tribeca#configuration ?
Posted a sell market order and the order went through but the request timed out. I'm gonna submit a PR to increase the default timeout :)
Hi all,
I'm not developing on Node but hoping you guys can give a hand, having trouble with nonce like so many others before me lol.
I use a semaphore to make sure only one nonce is generated and the response is received before trying another one but still getting a nonce error.
From fiddler capture, the requests in order (added nonce header for debugging):
POST https://api.kraken.com/0/public/AssetPairs HTTP/1.1
nonce: 108622843
POST https://api.kraken.com/0/public/Depth HTTP/1.1
nonce: 146190498
POST https://api.kraken.com/0/public/Trades HTTP/1.1
nonce: 156578556
POST https://api.kraken.com/0/private/AddOrder HTTP/1.1
nonce: 171383828
Response to AddOrder:
{"error":["EAPI:Invalid nonce"]}
What else could be wrong??
Hey there,
I need help for sandbox, i have google but i didn't found any sandbox , can you please let me know that is there any sandbox available out ????
Everything works best until I added Binance Api support for my application.
Error I get:
RequestError: connect ECONNREFUSED 127.0.0.1:443
at ClientRequest.<anonymous> (/server-bot/node_modules/got/dist/source/core/index.js:956:111)
at Object.onceWrapper (node:events:510:26)
at ClientRequest.emit (node:events:402:35)
at ClientRequest.origin.emit (/server-bot/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
at TLSSocket.socketErrorListener (node:_http_client:447:9)
at TLSSocket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1146:16) {
code: 'ECONNREFUSED',
timings: {
start: 1646464300686,
socket: 1646464300686,
lookup: 1646464300686,
connect: undefined,
secureConnect: undefined,
upload: undefined,
response: undefined,
end: undefined,
error: 1646464300687,
abort: undefined,
phases: {
wait: 0,
dns: 0,
tcp: undefined,
tls: undefined,
request: undefined,
firstByte: undefined,
download: undefined,
total: 1
}
}
}
If I remove node-binance-api from code it works just fine.
What should be the patch I need to do to make it work?
Thanks
I want to place an order with Kraken Api, and I found this module. How should I build this ?
DepositAddresses throws an error
"EFunding:No funding method"
`kraken.api('DepositAddresses', { "new": 'true' }, function (error, data) {
if (error) {
console.log(error);
}
else {
console.log(data.result);
res.status(200).json({
message: data.result
});
}
});`
How do I create a deposit address?
adding 'AddExport', 'ExportStatus', 'RetrieveExport', 'RemoveExport' to function list was easy.
But RetrieveExport response is binary data, not json, so I used this ugly hack to make it work and return a Buffer:
8c8
< private : [ 'Balance', 'TradeBalance', 'OpenOrders', 'ClosedOrders', 'QueryOrders', 'TradesHistory', 'QueryTrades', 'OpenPositions', 'Ledgers', 'QueryLedgers', 'TradeVolume', 'AddOrder', 'CancelOrder', 'DepositMethods', 'DepositAddresses', 'DepositStatus', 'WithdrawInfo', 'Withdraw', 'WithdrawStatus', 'WithdrawCancel', 'GetWebSocketsToken', 'AddExport', 'ExportStatus', 'RetrieveExport', 'RemoveExport' ],
---
> private : [ 'Balance', 'TradeBalance', 'OpenOrders', 'ClosedOrders', 'QueryOrders', 'TradesHistory', 'QueryTrades', 'OpenPositions', 'Ledgers', 'QueryLedgers', 'TradeVolume', 'AddOrder', 'CancelOrder', 'DepositMethods', 'DepositAddresses', 'DepositStatus', 'WithdrawInfo', 'Withdraw', 'WithdrawStatus', 'WithdrawCancel', 'GetWebSocketsToken' ],
42,46d41
< // hackjob molec
< if ( url.endsWith('RetrieveExport')) {
< options.responseType = 'buffer'
< return await got(url, options).buffer()
< } else {
61,62d55
< return response;
< }
63a57
> return response;
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.