forex-python (version 1.9.2) is an active Python library providing free foreign exchange rates and currency conversion functionalities. It supports listing all currency rates, retrieving Bitcoin prices, converting amounts between currencies, and accessing historical rates since 1999. The library's core data comes from theratesapi.com (sourced from the European Central Bank) for currency rates and CoinDesk for Bitcoin prices. It is regularly updated, though with an irregular release cadence, and is compatible with Python versions >=2.7 and <4, excluding 3.0-3.2.
Install & Compatibility
Where this runs
tested against v1.9.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.602s · 22.1MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.3s · import 0.542s · 23MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from forex_python.converter import CurrencyRates
from forex_python.bitcoin import BtcConverter
from forex_python.converter import CurrencyCodes
This quickstart demonstrates how to fetch current exchange rates, convert amounts, get Bitcoin prices, and retrieve currency symbols using the `forex-python` library. It emphasizes using `force_decimal=True` for accurate financial calculations.
from decimal import Decimal
from forex_python.converter import CurrencyRates, CurrencyCodes
from forex_python.bitcoin import BtcConverter
# Initialize CurrencyRates with force_decimal for precision
c = CurrencyRates(force_decimal=True)
# Get conversion rate from USD to INR
usd_to_inr_rate = c.get_rate('USD', 'INR')
print(f"1 USD = {usd_to_inr_rate} INR")
# Convert an amount
amount_usd = Decimal('100.50')
converted_amount_inr = c.convert('USD', 'INR', amount_usd)
print(f"{amount_usd} USD = {converted_amount_inr} INR")
# Get all latest rates for a base currency
all_usd_rates = c.get_rates('USD')
# print(f"All USD rates: {all_usd_rates}") # Uncomment to see all rates
# Get Bitcoin price
b = BtcConverter(force_decimal=True)
btc_usd_price = b.get_latest_price('USD')
print(f"1 BTC = {btc_usd_price} USD")
# Get currency symbol
codes = CurrencyCodes()
gbp_symbol = codes.get_symbol('GBP')
print(f"GBP symbol: {gbp_symbol}")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.