Before you start
- A verified Kraken account (Intermediate verification for trading)
- Two-factor authentication enabled
- Optional: the IP address of the machine running the bot
Create your Kraken API key
- 1
Open API settings
Sign in to Kraken (Kraken Pro), open the account menu and go to Settings → API (
pro.kraken.com/app/settings/api). - 2
Create a key
Click Create API key and give it a descriptive name such as
algogp-btc-bot. - 3
Choose permissions
Under Funds tick Query; under Orders and trades tick Query open orders & trades, Query closed orders & trades, Create & modify orders and Cancel & close orders. Leave Deposit and Withdraw unchecked.
- 4
Optional hardening
Add an IP allowlist, set a nonce window of a few seconds if you run several processes, and an expiry date for short experiments.
- 5
Save and copy both keys
Click Generate key. Copy the API key and Private key now: the private key is shown only once.
Test the key
Before wiring the key into a strategy, make one request by hand. It separates “the key is wrong” from “my code is wrong”.
import base64, hashlib, hmac, os, time, urllib.parse, urllib.request
path = "/0/private/Balance"
nonce = str(int(time.time() * 1000))
body = urllib.parse.urlencode({"nonce": nonce})
digest = hashlib.sha256((nonce + body).encode()).digest()
sig = hmac.new(base64.b64decode(os.environ["KRAKEN_API_SECRET"]), path.encode() + digest, hashlib.sha512)
req = urllib.request.Request("https://api.kraken.com" + path, body.encode(), {
"API-Key": os.environ["KRAKEN_API_KEY"], "API-Sign": base64.b64encode(sig.digest()).decode()})
print(urllib.request.urlopen(req).read().decode()){"error":[],"result":{…}} with your balances means the key works. EAPI:Invalid key or EGeneral:Permission denied point to the key or its permissions.Add the key to your AlgoGP project
- 1
Open your project’s APIs & keys tab
Open the strategy project, select APIs & keys, and under Platforms choose Kraken (Pro).
- 2
Paste each value
Paste the values into
KRAKEN_API_KEYandKRAKEN_API_SECRETand click Save. Values are encrypted at rest, never shown again and never written into code or exports. - 3
Run locally with the same names
Exported projects read the same names from
.env(copy.env.example). Keep.envout of version control.
KRAKEN_API_KEY=paste-your-value-here
KRAKEN_API_SECRET=paste-your-value-hereCommon Kraken API errors
EAPI:Invalid key- Wrong public key, or the key was deleted.
EAPI:Invalid signature- The private key is wrong or not base64-decoded before signing, or the body signed differs from the body sent.
EAPI:Invalid nonce- A nonce not larger than the previous one, usually two processes sharing a key.
EGeneral:Permission denied- The key lacks the permission for that endpoint.
EOrder:Insufficient funds- Not enough quote currency (or base, on a sell).
Frequently asked questions
Can I see my Kraken private key again?
No. It is shown once. Delete the key and create a new one if it is lost.
Should I enable withdrawals on a Kraken bot key?
No. A trading bot never needs to withdraw, and that permission is what makes a leaked key costly.
Build a Kraken trading bot in minutes
Describe the strategy in plain English, backtest it on years of data, then export Python that already talks to Kraken: paper, sandbox and live modes, keys handled for you.
- Generated adapter for Kraken orders and balances
- Backtests with costs, slippage and walk-forward checks
- Paper first; live trading only after you opt in
Free plan, no card required. Kraken is included with Pro.
AlgoGP is not affiliated with Kraken. Menus get renamed from time to time; if a label differs, the official documentation has the current path.