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:
- Generated Cripto InterCambio API keys.
- A Postman account.
Feel free to download our Postman collection or to set up Postman manually.
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:
- Download, extract, and import the collection into your Postman account.
- Select the Set authorized requests folder.
- Send the Set jsrsasign-js request only once.
- Go to the Variables tab at the collection scope.
- Insert your private key and public API Key in Base64 as the
yourPrivateKeyandyourApiKeyBase64values respectively. - Choose the necessary request from the Postman collection.
- Specify the request parameter values in the Body tab.
- Send the request.
Send API requests with manual setup
To send API requests with manual setup, follow these steps:
- 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.globals.set("jsrsasign-js", responseBody);
- Send the request only once.
- Create a new
POSTrequest. - Go to the Pre-request Script tab.
- Insert the following script and replace the placeholders
yourPrivateKeyandyourPublicApiKeyBase64with 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);
- Set
https://api.criptointercambio.com/v2in the URL field. - Specify the request data in the Body tab with the raw mode.
- Send the request to make sure Postman can proceed requests to the Exchange API.