Skip to main content

Send API requests with Postman


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


Check prerequisites

Before Postman setting, ensure you have:

Feel free to download our Postman collection or to set up Postman manually.

info

To send authorized requests to the Exchange API, you need to get the jsrsasign library in both setup flows. 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.


Send API requests with the collection

Our collection already contains all the scripts and the variables at the collection scope. It can help you improve your UX with the Exchange API.

Download the collection (.zip)

To send API requests with the collection, follow these steps:

  1. Download, extract, and import the collection into your Postman account.
  2. Select the Set authorized requests folder.
  3. Send the Set jsrsasign-js request only once.
  4. Go to the Variables tab at the collection scope.
  5. Insert your private key and public API Key in Base64 as the yourPrivateKey and yourApiKeyBase64 values respectively.
  6. Choose the necessary request from the Postman collection.
  7. Specify the request parameter values in the Body tab.
  8. Send the request.

Send API requests with manual setup

To send API requests with manual setup, follow these steps:

  1. Create a new GET request.
  2. Set https://raw.githubusercontent.com/kjur/jsrsasign/master/jsrsasign-all-min.js in the URL field.
  3. In the Scripts tab, select the Post-response section and insert the code:
pm.globals.set("jsrsasign-js", responseBody);
  1. Send the request only once.
  2. Create a new POST request.
  3. Go to the Pre-request Script tab.
  4. Insert the following script and replace the placeholders yourPrivateKey and yourPublicApiKeyBase64 with your private key and API key in Base64 respectively:
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 = "yourPrivateKey"; // replace with your private key
const publicKeyBase64String = "yourPublicApiKeyBase64"; // replace with your API key in Base64

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 with the raw mode.
  3. Send the request to make sure Postman can proceed requests to the Exchange API.