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:
- Generated Cripto InterCambio API keys.
- A Postman account.
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:
- Create a new Postman collection.
- If you have imported our Postman collection, select the Cripto InterCambio Exchange API Reference collection.
- Create a new
GETrequest. - Set
https://raw.githubusercontent.com/kjur/jsrsasign/master/jsrsasign-all-min.jsin the URL field. - In the Scripts tab, select the Post-response section and insert the code:
pm.environment.set("jsrsasign-js", responseBody);
- Send the request.
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:
- Go to the Variables tab at the collection scope.
- 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:
- Choose the necessary request from the Postman collection.
- Specify the request parameter values in the Body tab.
- Send the request.
If you have set Postman manually, follow the steps from the below section:
How to set sending requsts manually
- Create a new
POSTrequest. - Go to the Pre-request Script tab.
- 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);
- Set
https://api.criptointercambio.com/v2in the URL field. - Specify the request data in the Body tab using the raw mode.
- Send the request to make sure Postman can proceed requests to Exchange API.