EAPI:Invalid nonce means Kraken received a private request whose nonce was not higher than the last one it accepted for that API key. Your key and signature can be perfectly fine. The problem is ordering.
Every private Kraken REST call carries a nonce, and Kraken tracks the last accepted value per API key. Anything equal to it or lower is rejected.
The usual causes
| What you’re doing | Why it breaks |
|---|---|
| Two scripts, bots or servers share one API key | Each keeps its own counter, so one of them will eventually send a lower nonce than the other |
| Several requests fired in parallel | They can arrive out of order, and the one that lands late gets rejected |
A nonce built from seconds (Math.floor(Date.now() / 1000)) |
Two calls in the same second send the same value |
| Restarting a process that used a big custom counter | The new process starts lower than the value Kraken already saw |
| Retrying a failed request with the same signed payload | The nonce was already used, or a newer one has gone through since |
Kraken’s own advice lines up with this: use a nonce that always increases (Unix time in milliseconds is the common choice), give each bot or app its own API key, and don’t resend the same nonce on retry.
What the SDK does for you
@siebly/kraken-api creates the nonce for every private REST call, so you don’t build or sign it yourself. Each client instance starts its counter at the current time in milliseconds. If two calls happen in the same millisecond, it adds one, so the value always goes up within that client.
import { SpotClient } from '@siebly/kraken-api';
const client = new SpotClient({
apiKey: process.env.KRAKEN_API_KEY,
apiSecret: process.env.KRAKEN_API_SECRET,
});
async function main() {
const time = await client.getServerTime();
console.log('Kraken time:', time.result.rfc1123);
try {
const balances = await client.getAccountBalance();
console.log(balances.result);
} catch (err) {
// Kraken errors come back as { error: ['EAPI:Invalid nonce'] } and similar
console.error('Balance failed:', err?.body?.error ?? err);
}
}
main();
When a private call fails, the promise rejects and Kraken’s error array is on err.body.error. That’s the place to check for EAPI:Invalid nonce, EAPI:Invalid key or EGeneral:Permission denied.
Patterns that keep nonces in order
One client per API key, shared across your process. Create the SpotClient once and import it wherever you need it. Two SpotClient instances using the same key in one process each keep their own counter, and that’s the same problem as two bots sharing a key.
// kraken.js
import { SpotClient } from '@siebly/kraken-api';
export const kraken = new SpotClient({
apiKey: process.env.KRAKEN_API_KEY,
apiSecret: process.env.KRAKEN_API_SECRET,
});
One API key per bot, worker or server. Kraken tracks nonces per key, so separate keys can’t clash. This is also the simplest fix when you run the same code on more than one machine.
Don’t hammer private endpoints in parallel on one key. If you need many private calls, run them one after another or in small batches:
// Instead of Promise.all([...]) on one key:
const balances = await kraken.getAccountBalance();
const tradeBalance = await kraken.getTradeBalance();
const openOrders = await kraken.getOpenOrders();
Use the WebSocket API for order flow where it fits. The SDK’s WebsocketAPIClient sends awaitable trading commands over Kraken’s WebSocket API, which avoids lots of parallel signed REST calls. See the Kraken JavaScript SDK docs for the client setup.
What about the nonce window?
You can set a nonce window when you create a Kraken API key. Within that window, Kraken won’t reject a slightly lower nonce. Kraken suggests keeping it at 0 by default and using it only for network-ordering problems, not to hide a broken nonce scheme. With a millisecond nonce, a setting of 5000 gives a 5 second window.
If you only send a few calls and still get invalid nonce errors, Kraken’s support team suggests the key itself may be in a bad state. In that case, create a new key, which starts from zero again.
Quick checklist
- Is anything else using this API key right now? Give it its own key.
- Do you create more than one client for the same key? Share one instance.
- Are you firing private calls with
Promise.all? Run them in sequence. - Are you building your own nonce in seconds? Let the SDK do it.
- Still failing on a quiet key? Create a fresh key and keep the nonce window at 0 unless you have a network reason to change it.
The Kraken API JavaScript tutorial walks through private REST calls, WebSockets and the WebSocket API with the same SDK.
Siebly maintains open-source JavaScript and TypeScript SDKs for major crypto exchanges, with over 4.5 million npm downloads across 10+ SDKs, with more in the works.

