Last active
February 3, 2022 05:48
-
-
Save satheshshiva/b5c87f5c82087eeb2e5e90d9739b1820 to your computer and use it in GitHub Desktop.
Binance API - Postman prerequest script
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
// Binance Futures API - Use this Pre request script in postman to generate the signature and timestamp query string parameters. | |
// The postman collection can be downloaded from https://github.com/binance/binance-api-postman. Please note that this collection requests have signature and timestamp parameters enabled within each request. Disable in the individual request as this script will properly generate these parameters. | |
const secret = postman.getEnvironmentVariable("binance-api-secret"); | |
const timestamp = Date.now(); | |
let [,params]=request.url.split("?") | |
params+= "×tamp="+timestamp.toString() | |
const signHash = CryptoJS.HmacSHA256(params, secret); | |
pm.request.addQueryParams({ | |
key: 'timestamp', | |
value: timestamp.toString() | |
}); | |
pm.request.addQueryParams({ | |
key: 'signature', | |
value: signHash.toString() | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment