For information on changes for our US clients, please visit our Support Center article.

Due to increased demand, account verification may be delayed. Please avoid submitting multiple requests, and for best results, review our document requirements beforehand.
Example REST API request using bash


Implementing a Kraken REST API interface using the Bourne Again shell (bash) and some associated commands (openssl, base64, xxd, etc.) can be a convenient and efficient solution for interacting with Kraken's markets (although it would not be the fastest implementation compared to compiled code).
Bash and the required commands are readily available (pre-installed) on most UNIX, Linux, and macOS systems, and can be easily installed on Windows and other systems, so all of the required software is available without using any additional third party API tools or libraries.
Using a plain text editor (even an old school editor such as vi) and a few lines of code, it is possible to access both public market data and private account data, and also to place/cancel orders on Kraken's markets.

Example Code

The following shows a bash code implementation for calling the REST API Balance endpoint (with syntax highlighting for ease of understanding):
while the following provides the same code as plain text for copying/pasting:
#!/usr/bin/env bash

# API public/private keys copied from account management web site


# API variables (URL, endpoint, nonce, etc.)

api_nonce=`date +%s`

# Authentication algorithm (SHA256 and HMAC SHA512)

api_private_hex=`echo -n $api_private | base64 -d | xxd -p | tr -d "\n"`
echo -n $api_endpoint > kapi_bash.bin
echo -n $api_nonce$api_post | openssl dgst -sha256 -binary >> kapi_bash.bin
api_sign=`cat kapi_bash.bin | openssl dgst -binary -sha512 -mac HMAC -macopt hexkey:$api_private_hex | base64`

# HTTP request (POST)

curl --header "API-Key: $api_key" --header "API-Sign: $api_sign" --data $api_post $api_host$api_endpoint
and the matching code can also be downloaded (as a file).

Further Use/Development

To retrieve your own account balances, the example API key should be replaced with an API key from your own Kraken account, and additional API endpoints can be enabled simply by modifying the api_endpoint variable and the api_post variable (if needed).