Currency API: How to Convert Prices (with up-to-date exchange rates) with JavaScript

Currency conversion services are key features for any international commerce business. Including our Currency Conversion API into your application will make it easy to automatically convert prices from one common currency to another using the latest available exchange rate. After including both the source and destination currencies (and the source price for conversion), you’ll receive the converted price, ISO currency code, currency symbol, and more.

With installation instructions & ready-to-run code examples provided below in JavaScript, you can connect to and utilize this API with ease.

First things first, let’s install the jQuery library. To do so, run the following command:

bower install jquery

Then, just one more step, and you’re all done. Include the below function, and provide your Cloudmersive API key where indicated:

var settings = {
"url": "https://api.cloudmersive.com/currency/exchange-rates/convert/<string>/to/<string>",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": JSON.stringify("<double>"),
};
$.ajax(settings).done(function (response) {
console.log(response);
});

To get a Cloudmersive API key, all you need to do is head to our website (Home — Cloudmersive APIs) and register for a free account. With your free account, you’ll be provisioned a monthly limit of 800 API calls, and you’ll have access to dozens of other Cloudmersive APIs available on our API console page.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store