Use Postman with Fiat API
Prerequisites
Before you start, ensure 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.
Use 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 Authentication folder.
- Send once the Set jsrsasign library for signed requests request.
- Go to the Variables tab at the collection scope.
- Insert your actual public and private key as the
publicKeyandprivateKeyvalues respectively. - Choose the necessary request from the Postman collection.
- Specify the request parameter values in the Body tab.
- Send the request.
Use Postman with manual setup
- 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.globals.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
publicKeyandprivateKeywith your actual public and private key respectively:
const navigator = {}; // fake a navigator object for the lib
const window = {}; // fake a window object for the lib
eval(pm.variables.get("jsrsasign-js"));
const API_PUBLIC_KEY = 'publicKey'; // replace the 'publicKey' placeholder with your public key
const API_PRIVATE_KEY = 'privateKey'; // replace the 'privateKey' placeholder with your private key
const URL = pm.request.url.toString();
const message = pm.request.body.raw ? JSON.parse(pm.request.body.raw) : {};
const payload = URL + JSON.stringify(message);
const privateKeyString = Buffer.from(API_PRIVATE_KEY, 'base64').toString('binary');
const private_key_object = KEYUTIL.getKey(privateKeyString);
const sig = new KJUR.crypto.Signature({"alg": "SHA256withRSA"});
sig.init(private_key_object);
const signature = hextob64(sig.signString(payload));
pm.request.headers.add({
key: 'X-Api-Key',
value: API_PUBLIC_KEY
});
pm.request.headers.add({
key: 'X-Api-Signature',
value: signature
});
- Set the API URL
https://fiat-api.changelly.com/in the URL field. - Specify the body data of the necessary API method in the Body tab using the raw mode.
- Send the request to ensure Postman is ready for sending requests to Fiat API.