How to Get a Country’s Currency Information in Python
If you do a lot of online business with international clients or users, converting the currency manually can make payments a challenging interaction. However, we have an API that can automate the currency identification process for you, creating a better experience for both you and your customers. Using the following process, you can retrieve a country’s national currency, ISO code, and currency symbol.
To initiate the transaction, run this command to install the SDK:
pip install cloudmersive-validate-api-client
Next, you will be instancing the API and calling the function with the following code:
from __future__ import print_function
import time
import cloudmersive_validate_api_client
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# 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 requesttry:
# Get the currency of the input country
api_response = api_instance.address_get_country_currency(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling AddressApi->address_get_country_currency: %s\n" % e)
Once complete, you will have the necessary information to simplify your international monetary transactions. Interested in other currency-related APIs? Check out the Cloudmersive website to retrieve your free API key and gain access to 800 monthly calls across our library of APIs.