Created
August 6, 2020 12:02
-
-
Save CanKattwinkel/edf274031d4c46e82df43ad1a13ff825 to your computer and use it in GitHub Desktop.
Kucoin: Pre-Request Script for Postman
This file contains 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
// Use this to sign postman http requests to the KuCoin API | |
// dont forget to set KC-API-KEY as well as KC-API-PASSPHRASE as headers and to replace the secret used below. | |
const timestamp = Date.now(); | |
const body = request.body ? request.body : ''; | |
const method = request.method; | |
const [, endpoint] = request.url.split('https://api.kucoin.com'); | |
const signature = timestamp + method + endpoint + body; | |
const hash = CryptoJS.HmacSHA256(signature,"YOUR-SECRET"); | |
pm.request.headers.add({ | |
key: 'KC-API-SIGN', | |
value: hash.toString(CryptoJS.enc.Base64) | |
}); | |
pm.request.headers.add({ | |
key: 'KC-API-TIMESTAMP', | |
value: timestamp | |
}); |
POST https://api.kucoin.com/api/v1/accounts
{
"code": "400005",
"msg": "Invalid KC-API-SIGN"
}
Replace the KC-API-SIGN value with;
CryptoJS.enc.Base64.stringify(hash)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
POST https://api.kucoin.com/api/v1/accounts
{
"code": "400005",
"msg": "Invalid KC-API-SIGN"
}