Skip to main content

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)

  1. Extract the Postman collection (.zip) and import it into your Postman account.
  2. Select the Authorization folder.
  3. Send once the Authorization Request.
  4. Go to the Variables tab at the collection scope.
  5. Insert your actual private key and API Key in Base64 as the privateKey and apiKeyBase64 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.

Set up Postman manually

  1. Create a new GET request.
  2. Set the URL https://raw.githubusercontent.com/kjur/jsrsasign/master/jsrsasign-all-min.js in the URL field.
  3. Go to the Scripts tab, select the Post-response section, and paste the code:
pm.environment.set("jsrsasign-js", responseBody);
  1. Send the request.
  2. Create a new POST request.
  3. Go to the Pre-request Script tab.
  4. Insert the following script and replace the placeholders privateKey and apiKeyBase64 with 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);
  1. Set the API URL https://api.changelly.com/v2 in the URL field.
  2. Specify the body data of the necessary API method in the Body tab using the raw mode.
  3. Send the request to make sure that Postman is now able to send requests to our API.