Get the Currency of an Input Country in Python

If your application deals with foreign currency in any capacity, you’ll probably want an easy way to confirm what currency a given country uses. The Cloudmersive Validate API is perfect for that — with the /validate/address/country/get-currency iteration, you can capture a country name as an input & receive the ISO three-letter country code, currency symbol, and English currency name in the blink of an eye. It’s easy to connect with in 13+ programming languages, and in this article, we’ll walk through how to connect in Python.

To begin the process, you can start by copying the below Python SDK Installation command:

pip install cloudmersive-validate-api-clientfrom __future__ import print_function
import time
import cloudmersive_validate_api_client
from import ApiException
from pprint import pprint

After that, you’ll need to authenticate your API key with the below code snippet:

# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'

If you don’t already have a Cloudmersive API key, you can get one easily by making a free account on the Cloudmersive website (which includes 800 api calls per month).

For the last step in the function, you can now copy & paste the remaining code:

# create an instance of the API class
api_instance = cloudmersive_validate_api_client.AddressApi(cloudmersive_validate_api_client.ApiClient(configuration))
input = cloudmersive_validate_api_client.ValidateCountryRequest() # ValidateCountryRequest | Input request
# Get the currency of the input country
api_response = api_instance.address_get_country_currency(input)
except ApiException as e:
print("Exception when calling AddressApi->address_get_country_currency: %s\n" % e)



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