How to Get a List of Available Currencies & Corresponding Countries using Java

Looking for metadata about common currencies? Our Currency API offers a quick and easy solution. Running our List Available Currencies API requires zero inputs and returns a detailed list of common global currencies such as EUR, USD, JPY, and much more. It provides each currencies’ symbol & name (in English), the country they are associated with, the country’s three letter & ISO two letter codes, and more. Below, I’ve included an example response model for your reference (including information about Japanese Yen):

    {
"ISOCurrencyCode": "JPY",
"CurrencySymbol": "¥",
"CurrencyEnglishName": "Japanese Yen",
"CountryName": "Japan",
"CountryThreeLetterCode": "JPN",
"CountryISOTwoLetterCode": "JP",
"IsEuropeanUnionMember": false
},

You can easily take advantage of this API by simply copying & pasting the ready-to-run Java code examples provided below to structure your API call. In addition, you’ll just need a Cloudmersive API key, which you can get for free by registering a free account on our website (free accounts provide a limit of 800 API calls per month & zero additional commitments).

Our first step is to install the API client. Let’s first add a reference to the repository in pom.xml:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

And then let’s add a reference to the dependency in pom.xml:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

With installation complete, our next step is to add the imports to the top of our file:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.CurrencyExchangeApi;

And after that, we can call the function, suppling our Cloudmersive API key in the field indicated by the code comments:

ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");
CurrencyExchangeApi apiInstance = new CurrencyExchangeApi();
try {
AvailableCurrencyResponse result = apiInstance.currencyExchangeGetAvailableCurrencies();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CurrencyExchangeApi#currencyExchangeGetAvailableCurrencies");
e.printStackTrace();
}

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

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
Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.