Last active
November 8, 2021 10:48
-
-
Save alpinechough/6ea46f1d09ff46ea3991c3171453ee58 to your computer and use it in GitHub Desktop.
Accessing authenticated Kraken API - bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.