I'm trying to access balance of Bitstamp account with API.
#!/bin/bash
# Bitstamp API credentials
API_KEY="name_of_my_API_key"
API_SECRET="private_API_key"
CUSTOMER_ID="ID_number"
# Build the nonce
NONCE=$(date +%s%N)
# Sign the message
echo -e "${NONCE}\t${CUSTOMER_ID}\t${API_KEY}\t${API_SECRET}"
SIGNATURE=$(echo -n "${NONCE}${CUSTOMER_ID}${API_KEY}" | openssl dgst -sha256 -hmac "${API_SECRET}" | sed 's/^.* //')
echo ${SIGNATURE}
RESULT=$(curl -s -X POST https://www.bitstamp.net/api/v2/account_balances/usd/ \
-d "key=${API_KEY}" \
-d "signature=${SIGNATURE}" \
-d "nonce=${NONCE}")
# Check if the order was successful
STATUS=$(echo ${RESULT} | jq -r '.status')
if [ "${STATUS}" != "success" ]; then
echo "Error: Order failed - $(echo ${RESULT} | jq -r '.reason')"
fi
BALANCE_AVAILABLE=$(echo ${RESULT} | jq -r '.available')
echo "${BALANCE_AVAILABLE}"
... but I'm getting error: "Invalid signature"
Is there any mistake in SIGNATURE construction please?