Skip to content

Instantly share code, notes, and snippets.

@alpinechough
Last active November 8, 2021 10:48
Show Gist options
  • Save alpinechough/6ea46f1d09ff46ea3991c3171453ee58 to your computer and use it in GitHub Desktop.
Save alpinechough/6ea46f1d09ff46ea3991c3171453ee58 to your computer and use it in GitHub Desktop.
Accessing authenticated Kraken API - bash
#/bin/bash
# API Key:
APIKEY="<your API key>"
# Private Key:
PRIVATEKEY="<your private key>"
# URL
URLHOST="https://api.kraken.com"
URLPATH="/0/private/Balance"
NONCE=$(date +%s%N)
echo -n "${URLPATH}" > tmp.bin
echo -n "${NONCE}nonce=${NONCE}" | openssl sha256 -binary >> tmp.bin
PRIVATEKEYHEX=$(echo -n "${PRIVATEKEY}" | base64 -d | hexdump -v -e '/1 "%02X"');
cat tmp.bin | openssl sha512 -binary -mac HMAC -macopt hexkey:${PRIVATEKEYHEX} > sign.bin
APISIGN=$(cat sign.bin | base64 -w 0)
curl -X POST -H "Accept: application/json" -H "API-Key: ${APIKEY}" -H "API-Sign: ${APISIGN}" -d "nonce=$NONCE" ${URLHOST}${URLPATH}
echo
@lupo-ch
Copy link

lupo-ch commented Jun 25, 2018

Hi, thank you for the bash script it's working perfect. Is it possible to post a example of a private call to the API with some parameters.
For example to make a new order and etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment