Skip to main content

AbstractAPI python-exchange-rates library

Integrate the powerful Exchange Rates API from Abstract in your Python project in a few lines of code.

The Exchange Rate API is an REST API that allows you to:

  • look up the latest exchange rates for 80+ currencies via the live endpoint
  • get historical exchange rates using the historical endpoint
  • convert an arbitrary amount from one currency to another using the convert endpoint

It's very simple to use: you only need to submit your API key and a currency symbol (such as "USD"), and the API will respond with current exchange rate, historical data, or convertion rates.

Documentation

Supported Python Versions

This library supports the Python version 3.6 and higher.

Installation

You can install python-exchange-rates via PyPi or by downloading the source.

Via PyPi:

python-exchange-rates is available on PyPi as the abstract-python-exchange-rates package:

pip install abstract-python-exchange-rates

API key

Get your API key for free and without hassle from the Abstact website.

Quickstart

Get exchange rates

import pprint
from python_exchange_rates import AbstractExchangeRates

EXCHANGE_RATES_API_KEY =  "YYYYYY"; # Get your API Key from https://app.abstractapi.com/api/exchange-rates/documentation

AbstractExchangeRates.configure(EXCHANGE_RATES_API_KEY)

# Get live exchange rates using Abstract's Exchange Rates API and Python
response = AbstractExchangeRates.live("EUR")
pprint(response)

# Get historical exchange rates using Abstract's Exchange Rates API and Python
response = AbstractExchangeRates.historical('EUR', '2021-05-01');
pprint(response)

# Convert currency using Abstract's Exchange Rates API and Python
response = AbstractExchangeRates.convert('EUR', 'USD');
pprint(response)

API response

The API response contains the following fields:

live response parameters

Parameter Type Details
base String The base currency used to get the exchange rates.
last_updated String The Unix timestamp of when the returned data was last updated.
exchange_rates Object A JSON Object containing each of the target currency as the key and its exchange rate versus the base currency as that key's value.

historical response parameters

Parameter Type Details
base String The base currency used to get the exchange rates.
date String The date the currencies were pulled from, per the successful request.
exchange_rates Object A JSON Object containing each of the target currency as the key and its exchange rate versus the base currency as that key's value.

convert response parameters

Parameter Type Details
base String The base currency used to get the exchange rates.
target String The target currency that the base_amount was converted into.
date String The date the currencies were pulled from, per the successful request.
base_amount Float The amount of the base currency from the request.
converted_amount Float The amount of the target currency that the base_amount has been converted into
exchange_rate Float The exchange rate used to convert the base_amount from the base currency to the target currency

Detailed documentation

You will find additional information and request examples in the Abstract help page.

Getting help

If you need help installing or using the library, please contact Abstract's Support.

For bug report and feature suggestion, please use this repository issues page.

Contribution

Contributions are always welcome, as they improve the quality of the libraries we provide to the community.

Please provide your changes covered by the appropriate unit tests, and post them in the pull requests page.

Setup

To install the requirements, run:

python3 setup.py install --user

Once you implementer all your changes and the unit tests, run the following command to run the tests:

EXCHANGE_RATES_API_KEY=YYYYYY python3 tests/test_python_exchange_rates.py

Metadata

Release files for abstract-python-exchange-rates 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for abstract-python-exchange-rates 1.0.1
File Size Uploaded
abstract_python_exchange_rates-1.0.1.tar.gz 4.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for abstract-python-exchange-rates 1.0.1
File Interpreter ABI Platform
abstract_python_exchange_rates-1.0.1-py3.9.egg Legacy Egg format - - Details
abstract_python_exchange_rates-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / abstract_python_exchange_rates-1.0.1.tar.gz

Download URL abstract_python_exchange_rates-1.0.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6f1c3f64804e57744ba83571c1762ea246fb02997413b6c5b63f64f2605441d2
BLAKE2b-256 checksum
How to use checksums
7eca0888ecb1c625a6acdbed57aa608de80c5e4be66bad3d4369a422ff4cd1e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / abstract_python_exchange_rates-1.0.1-py3.9.egg

Download URL abstract_python_exchange_rates-1.0.1-py3.9.egg
Size 5.9 kB
Tags Egg
SHA-256 checksum
How to use checksums
1dbed8fb29ab78e7da6031d7792763f387fe8b627de2225823e031a55d6afac3
BLAKE2b-256 checksum
How to use checksums
b308c00fead0bd3c5b7b208a5dba23f47dae2a314a0c5a6e0c2c88411159f3b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / abstract_python_exchange_rates-1.0.1-py3-none-any.whl

Download URL abstract_python_exchange_rates-1.0.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b63d64334ec56d44939105cf4266de980144ee25e7b9776462caf87f357c2e8
BLAKE2b-256 checksum
How to use checksums
ad8e420fa87c002024eb352e194660556ce8b386e6bb2fa84d576dc5d51cb84f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.0.1 This release

3 release files

1.0.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page