Skip to main content

Send API requests with Postman


This instruction helps you send requests to Exchange API using Postman.


Step 0: Сheck prerequisites

Before Postman setting, ensure you have:


Step 1: Set authorized requests

To set authorized requests, follow these steps:

  1. Create a new GET request.
  2. Copy jsrsasign-all-min.js code to the URL field.
  3. Send the request.
  4. Go to the Tests tab and insert the code:
postman.setGlobalVariable("jsrsasign-js", responseBody);
info

Step 1 is crucial for sending authorized requests to Exchange API. After completion, a global variable stores the GET request outcome. This variable subsequently employes in the pre-request scripts for authorization.


Step 2: Add a pre-request script

After setting authorized requests, follow these steps to add a pre-request script:

  1. Create a new POST request.
  2. Go to the Pre-request Script tab.
  3. Insert the following script with your actual keys instead of the yourPrivateKey and yourPublicApiKeyBase64 placeholders:
const navigator = {}; //fake a navigator object for the lib
const window = {}; //fake a window object for the lib
eval(pm.globals.get("jsrsasign-js"));

const privateKeyString = pm.environment.get("yourPrivateKey");
const publicKeyBase64String = pm.environment.get("yourPublicApiKeyBase64");

const key = new RSAKey();
key.readPKCS8PrvKeyHex(privateKeyString);

const sig = new KJUR.crypto.Signature({"alg": "SHA256withRSA"});
sig.init(key);
const signature = hextob64(sig.signString(pm.request.body.raw));

pm.request.headers.add({
key: 'x-api-key',
value: publicKeyBase64String
});

pm.request.headers.add({
key: 'x-api-signature',
value: signature
});

pm.environment.set('x-api-key', publicKeyBase64String);
pm.environment.set('x-api-signature', signature);
  1. Set the API URL in the URL field.
  2. Specify the body data in the Body tab using the raw mode.
  3. Send the request to make sure Postman can proceed requests to Exchange API.