Skip to content

Instantly share code, notes, and snippets.

@satheshshiva
Last active February 3, 2022 05:48
Show Gist options
  • Save satheshshiva/b5c87f5c82087eeb2e5e90d9739b1820 to your computer and use it in GitHub Desktop.
Save satheshshiva/b5c87f5c82087eeb2e5e90d9739b1820 to your computer and use it in GitHub Desktop.
Binance API - Postman prerequest script
// 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+= "&timestamp="+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