Skip to main content

Use Postman with our API

Prerequisites

Before you start, make sure that you have:

  • Changelly API keys
  • A Postman account
info

To improve your UX with our API, you can download the Postman collection, extract it, and import it into your Postman account.
The collection already contains all the variables at the collection scope and the pre-request script at the request scope.

Download the Postman collection (.zip)

1. Get jsrsasign library used for signing

  1. Create a new Postman collection or select the imported Changelly API Reference collection.
  2. Create a new GET request.
  3. Set the URL https://raw.githubusercontent.com/kjur/jsrsasign/master/jsrsasign-all-min.js in the URL field.
  4. Go to the Scripts tab, select the Post-response section, and paste the code:
pm.environment.set("jsrsasign-js", responseBody);
  1. Send the request.
info

This step is essential for sending authorized requests to our API. Once completed, the outcome of the GET request is stored in a global variable, which is subsequently employed in the pre-request scripts used for authorization.
Perform this step only once before sending requests.

2. Set up keys

  1. Go to the Variables tab at the collection scope.
  2. Set your private key and API Key in Base64 as variable values.

3. Set sending requests

If you want to set sending requests with the imported Postman collection, follow these steps:

  1. Choose the necessary request from the Postman collection.
  2. Specify the request parameter values in the Body tab.
  3. Send the request.

If you want to set sending requests manually, follow the steps from the below section:

How to set sending requsts manually
  1. Create a new POST request.
  2. Go to the Pre-request Script tab.
  3. 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("privateKey");
const ApiKeyBase64String = pm.variables.get("ApiKeyBase64");

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 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.