Unparalleled suite of productivity-boosting Web APIs & cloud-based micro-service applications for developers and companies of any size.


How To Access Exchange Rates And Currency Conversion With Python

How To Access Exchange Rates And Currency Conversion With Python

As APIs, or application programming interfaces, gain traction in the development world, developers are spoiled for choice. There are literally thousands of public APIs available to choose from and they also cover a wide variety of categories — everything from SERP to currency conversion.

This is especially true in the financial industry. As the need for financial services grows, firms are coming up with innovative strategies to improve their client’s web and mobile application experiences. As a result, financial companies are implementing private and also public APIs to assist with better connectivity.

Financial institutions today use applications and software for virtually everything. In such a developed financial industry, currency converter APIs are indispensable tools that allow financial firms to facilitate their connectivity while also improving service delivery.

What is currencylayer and What Makes it Reliable?


currencylayer is a simple REST API with real-time and historical exchange rates for 168 world currencies. It delivers currency pairs in the universally usable JSON format – compatible with any of your applications.

currencylayer also receives real-time spot exchange rate data from several major forex data providers in real-time. It validates, processes, and delivers information either hourly, every 10 minutes, or even with a 60-second market window.

Because it provides the most up-to-date forex market value available for every API request, the currencylayer API is perfect for currency converters, mobile applications, financial software components, and back-office systems worldwide.

apilayer, an Austrian technology company, built and maintains the currencylayer API. To find out more about us and our variety of reliable programming interfaces and the affordable APIs we make for developers and startups, you can browse all our products here.

This article looks at currencylayer’s diverse API endpoints, options, and integration guides for Python, interactive web-based dashboard (Jupyter Notebook), and desktop applications (Delphi).

Why Should You Use currencylayer to Provide Forex Data?

currencylayer is feature-rich and provides you with real-time FOREX information when and how you need it. Here is a brief rundown of some of its many functions:

Historical Rates

Query the API for Historical Rates back to 1999 by using the historical Endpoint.

Optional Parameters

Request only specific currencies to reduce server load, or query the API for a different Source Currency.

Currency Conversion

Have the API convert one currency to another on your behalf, using real-time or even historical rates.

Time-Frame Queries

Request exchange rates between two specified dates, for timeframes of up to 365 days.

Currency-Change Queries

Request any currency change parameters (margin and percentage) between two specified dates.

Additional Features

JSON Formatting, JSONP Callbacks, HTTP ETags to save bandwidth, Access-Control headers, and more.

What Forex Data Endpoints are Available via the API?

In total, currencylayer API offers 5 API endpoints, each with different powerful functionality. 

  1. Live Data Endpoint: Get the most recent exchange rate data.
  2. Historical Data Endpoint: Get historical rates for a specific day.
  3. Conversion Endpoint: Convert one currency to another. 
  4. Time-Frame Data Endpoint: Request exchange rates for a specific period of time.
  5. Change Data Endpoint: Request any currency’s change parameters (margin, percentage).

How can I Access currencylayer API?

First, get your API Credentials here, and set up your subscription plan.

You can monitor your usage via this dashboard.

API Access Key & Authentication

Next, to check if everything is working properly, simply run this URL in your favorite web browser:

You will get this API response inside your browser:


Here are all available HTTP GET Request Parameters for the Live Data:

Parameter Description
access_key [Required] Your API Access Key.
source [optional] Specify a Source Currency other than the default USD. Supported on the Basic Plan and higher.
currencies [optional] Specify a comma-separated list of currency codes to limit your API response to specific currencies.

And the following are the descriptions of each Response Properties:

Object Description
success Returns true or false depending on whether or not your query succeeds.
terms Returns a link to the currencylayer Terms & Conditions.
privacy Returns a link to the currencylayer Privacy Policy.
timestamp Returns the exact date and time (UNIX) the exchange rates were collected.
source Returns the currency to which all exchange rates are relative (default: USD).
quotes Contains all exchange rate values, consisting of the currency pairs and their respective conversion rates.

Common API errors:

Code Info
404 The user requested a resource that does not exist.
101 The user did not supply an access key or supplied an invalid access key.
102 The user’s account is not active. Users will be prompted to get in touch with Customer Support.
103 The user requested a non-existent API function.
104 The user has reached or exceeded his subscription plan’s monthly API request allowance.
105 The user’s current subscription plan does not support the requested API function.
106 The user’s query did not return any results
201 The user entered an invalid Source Currency.
202 The user entered one or more invalid currency codes.
301 The user did not specify a date [historical].
302 User entered an invalid date [historical, convert].
401 User entered an invalid “from” property [convert].
402 User entered an invalid “to” property [convert].
403 User entered no or an invalid “amount” property [convert].
501 The user did not specify a Time-Frame [timeframe, convert].
502 User entered an invalid “start_date” property [timeframe, convert].
503 User entered an invalid “end_date” property [timeframe, convert].
504 User entered an invalid Time-Frame [timeframe, convert].
505 The Time-Frame specified by the user is too long – exceeding 365 days [timeframe].

How can I Track and Monitor any Forex & Currency Conversion with Python and currencylayer?

Use the following code to make an API request using Python, to get the latest exchange rates for all available currencies:

Here are the API responses inside the Python IDE:


You also can print out each exchange rate individually, or choose any exchange rate you want to know like this:

Here is the API response inside your Python IDE:


How can I Develop a Web-Based Forex & Currency Conversion Tracking and Monitoring System with currencylayer and Jupyter Notebook? 

You can easily build an interactive web-based Forex & Currency Conversion Tracker dashboard using the Python scripts above.  All you need to do is run them inside Jupyter Notebook. If you have never used Jupyter Notebook before, you can visit the installation guide on the official website of Project Jupyter.

Here is the result:

Bonus: API Requests using other Platform

How can I Make an API Request to currencylayer using Delphi REST Debugger?

Download Delphi REST Debugger here:

Choose the GET method, and send the request to the following URL:


You can get pretty output, by automatically extract the nested JSON data with the following steps:


After getting the API responses you need, you can create Desktop apps using Delphi. Please refer to this article to get started:


Are You Ready to Build Your Own Reliable Forex Tracking and Monitoring System?

As you can see, the currencylayer REST API endpoint provides rich currency data you can connect to any platform and any programming language you work with. Here is the basic demo. It shows you how you can access any live currency vs USD by using the currencylayer REST API for scripting, web, and desktop-based applications. 

You can also take advantage of the free tier on currencylayer. We strongly recommend, however, you to upgrade your subscription plan if you need more powerful features. Some of the paid features include Source Currency Switching, Currency Conversion, HTTPS Encryption, and the Time-Frame Endpoint, as well as many more! You can also contact us for a custom solution. We can’t wait to see what you build with our REST API!

Head over and sign up for free to start integrating real-time foreign exchange rates data into your apps today!

Related posts

Location Based Services: Building with Ipstack


How to Use An API with Java


APILayer API Integration with Popular Frameworks


Building a Stock Market Dashboard Using Marketstack

Leave a Reply

Your email address will not be published. Required fields are marked *