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:

Feel free to download our Postman collection. Extract and import it into your Postman account. This can help you improve your UX with Exchange API.
Pay attention that our collection already contains all the scripts and variables at the collection scope.

Download Exchange API Postman collection (.zip)


Step 1: Set authorized requests

To set authorized requests, follow these steps:

  1. Create a new Postman collection.
    1. If you have imported our Postman collection, select the Cripto InterCambio Exchange API Reference collection.
  2. Create a new GET request.
  3. Set https://raw.githubusercontent.com/kjur/jsrsasign/master/jsrsasign-all-min.js in the URL field.
  4. In the Scripts tab, select the Post-response section and insert the code:
pm.environment.set("jsrsasign-js", responseBody);
  1. Send the request.
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.
You need to get the jsrsasign library only once before sending requests.


Step 2: Set up keys

To set up API keys, follow these steps:

  1. Go to the Variables tab at the collection scope.
  2. Set your private key and public API Key in Base64 as variable values.

Step 3: Set sending requests

After setting authorized requests and the variables, set sending requests. The flow depends on how you work with Postman.

If you have imported our Postman collection, follow these steps:

  1. Choose the necessary request from the Postman collection.
  2. Specify the request parameter values in the Body tab.
  3. Send the request.

If you have set Postman manually, follow the steps from the below section:

How to set sending requsts manually
  1. Create a new POST request.
  2. Go to the Pre-request Script tab.
  3. Insert the following script:
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.variables.get("yourPrivateKey");
const publicKeyBase64String = pm.variables.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 https://api.criptointercambio.com/v2 in the URL field.
  2. Specify the request data in the Body tab using the raw mode.
  3. Send the request to make sure Postman can proceed requests to Exchange API.