fxrateapi
Official Python SDK for fxrateapi.com — exchange rates, currency conversion, and time series data from ECB, FRED, and OXR.
Installation
pip install fxrateapi
Quick start
from fxrateapi import FxRateApiClient
client = FxRateApiClient(api_key="fxr_your_key_here")
# Latest rates
rates = client.latest(base="USD", symbols=["EUR", "GBP", "JPY"])
print(rates.rates["EUR"]) # 0.847
# Convert 1000 USD → EUR
result = client.convert(from_currency="USD", to="EUR", amount=1000)
print(result.result) # 847.4
# Historical (immutable, cache forever)
hist = client.historical("2020-03-16", base="USD")
# Time series (max 366 days)
ts = client.timeseries(start="2024-01-01", end="2024-03-31", symbols=["EUR"])
for date, day_rates in ts.rates.items():
print(date, day_rates.get("EUR"))
Async usage
import asyncio
from fxrateapi import AsyncFxRateApiClient
async def main():
async with AsyncFxRateApiClient(api_key="fxr_your_key_here") as client:
# Fetch concurrently
latest, usage = await asyncio.gather(
client.latest(base="USD", symbols=["EUR", "GBP"]),
client.usage(),
)
print(latest.rates["EUR"])
print(f"{usage.requests.used}/{usage.requests.limit} requests used")
asyncio.run(main())
Error handling
from fxrateapi import FxRateApiClient
from fxrateapi.exceptions import FxRateApiResponseError, FxRateApiTimeoutError
client = FxRateApiClient(api_key="fxr_your_key_here")
try:
client.latest(base="INVALID")
except FxRateApiResponseError as e:
print(e.status) # 422
print(e.code) # "fx_invalid_symbol"
print(e.why) # human-readable reason
print(e.how_to_fix) # suggestion
except FxRateApiTimeoutError as e:
print(f"Timed out after {e.timeout}s")
API reference
See docs.fxrateapi.com for full API documentation.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fxrateapi-0.1.0.tar.gz
(8.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
fxrateapi-0.1.0-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file fxrateapi-0.1.0.tar.gz.
File metadata
- Download URL: fxrateapi-0.1.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
944f8e960098ef69793e240b4d9d900cf2972ea110b0e3895f4e5105109e62d1
|
|
| MD5 |
119273d4b56de9ff0536e5b46955a93c
|
|
| BLAKE2b-256 |
5ecbda6d2452c8292e61ce0f8b1a980243be207a1fe2d66bbc2f71be10ecbd70
|
File details
Details for the file fxrateapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fxrateapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76b86bb7237ea678ab9d606499034093ddbc86b7b0bf98a6a23da3c44b09e8ae
|
|
| MD5 |
5679c31c916821ffd6f042ca0626c8b7
|
|
| BLAKE2b-256 |
0179af523ce6f1edc59635d593f4f9dc05d2f500500ab2c2c8ddd8fdd0a73fd0
|