Use Postman with our API
Prerequisites
Before you start, make sure that you have:
- Changelly API keys
- A Postman account
You can set Postman with the Postman collection or manually.
info
To send authorized requests to our API, you must get the jsrsasign library in both setup flows. After completion, you can find the outcome of the GET request as a global variable. This variable is subsequently necessary in the pre-request scripts for authorization.
Perform this step only once before sending requests.
Set up Postman with the collection
The collection helps improve your UX with our API. It already contains all the necessary scripts and the variables at the collection scope.
Download the Postman collection (.zip)
- Extract the Postman collection (.zip) and import it into your Postman account.
- Select the Authorization folder.
- Send once the Authorization Request.
- Go to the Variables tab at the collection scope.
- Insert your actual private key and API Key in Base64 as the
privateKeyandapiKeyBase64values respectively. - Choose the necessary request from the Postman collection.
- Specify the request parameter values in the Body tab.
- Send the request.
Set up Postman manually
- Create a new
GETrequest. - Set the URL
https://raw.githubusercontent.com/kjur/jsrsasign/master/jsrsasign-all-min.jsin the URL field. - Go to the Scripts tab, select the Post-response section, and paste the code:
pm.environment.set("jsrsasign-js", responseBody);
- Send the request.
- Create a new
POSTrequest. - Go to the Pre-request Script tab.
- Insert the following script and replace the placeholders
privateKeyandapiKeyBase64with your actual 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 = 'privateKey'; // replace the 'privateKey' placeholder with your private key
const ApiKeyBase64String = 'apiKeyBase64'; // replace the 'apiKeyBase64' placeholder 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: ApiKeyBase64String
});
pm.request.headers.add({
key: 'x-api-signature',
value: signature
});
pm.environment.set('x-api-key', ApiKeyBase64String);
pm.environment.set('x-api-signature', signature);
- Set the API URL
https://api.changelly.com/v2in the URL field. - Specify the body data of the necessary API method in the Body tab using the raw mode.
- Send the request to make sure that Postman is now able to send requests to our API.