Skip to content

Instantly share code, notes, and snippets.

@samthomson
Last active September 27, 2020 14:10
Show Gist options
  • Save samthomson/54260096b7e8887ea619d2de5cad1bfe to your computer and use it in GitHub Desktop.
Save samthomson/54260096b7e8887ea619d2de5cad1bfe to your computer and use it in GitHub Desktop.
Bittrex API V3 Postman Pre request script

Assumes a BITTREX_API_KEY and BITTREX_API_SECRET is set on the collections variables.

// set up vars
let timestamp = new Date().getTime()
let url = request['url']
let method = request['method']
let contentHash = CryptoJS.SHA512(request['data']).toString(CryptoJS.enc.Hex);

var preSign = [timestamp, url, method, contentHash, ''].join('');
var signature = CryptoJS.HmacSHA512(preSign, pm.collectionVariables.get("BITTREX_API_SECRET")).toString(CryptoJS.enc.Hex);


// Api-Key
pm.request.headers.add({
    key: 'Api-Key',
    value: pm.collectionVariables.get("BITTREX_API_KEY")
});

// Api-Timestamp
pm.request.headers.add({
    key: 'Api-Timestamp',
    value: timestamp
});

// Api-Content-Hash
pm.request.headers.add({
    key: 'Api-Content-Hash',
    value: contentHash
});

// Api-Signature
pm.request.headers.add({
    key: 'Api-Signature',
    value: signature
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment