Fetch live and historical exchange rates in Python. Install our SDK with pip or call the REST API directly with requests.
Install the official Python SDK and fetch your first exchange rate in under a minute.
pip install exchangerateapi
from exchange_rateapi import ExchangeRateAPI
client = ExchangeRateAPI(api_key="era_live_YOUR_API_KEY")
# Get the latest USD to EUR rate
rate = client.get_rate("USD", "EUR")
print(f"1 USD = {rate['rate']} EUR")
# Output: 1 USD = 0.9215 EUR
era_live_. The free plan includes 300 requests per month.
The exchange-rateapi Python package wraps every API endpoint and handles authentication, retries, and response parsing for you.
from exchange_rateapi import ExchangeRateAPI
client = ExchangeRateAPI(api_key="era_live_YOUR_API_KEY")
# Single currency pair
rate = client.get_rate("USD", "EUR")
print(f"1 USD = {rate['rate']} EUR")
# Convert 1000 USD to EUR
result = client.convert("USD", "EUR", 1000)
print(f"$1,000 = {result['result']} EUR")
# Get 30-day historical data
history = client.get_historical_rates("USD", "EUR", "30d")
for point in history["data"]:
print(f"{point['date']}: {point['rate']}")
# Get all supported currency codes
symbols = client.get_symbols()
for currency in symbols["currencies"]:
print(f"{currency['code']}: {currency['name']}")
If you prefer to call the API directly without the SDK, use Python's requests library.
import requests
response = requests.get(
"https://exchange-rateapi.com/api/v1/rates",
params={"source": "USD", "target": "EUR"},
headers={"Authorization": "Bearer era_live_YOUR_API_KEY"}
)
data = response.json()
print(f"1 USD = {data[0]['rate']} EUR")
# Output: 1 USD = 0.9215 EUR
import requests
response = requests.get(
"https://exchange-rateapi.com/api/v1/rates",
params={"source": "USD", "target": "EUR,GBP,JPY"},
headers={"Authorization": "Bearer era_live_YOUR_API_KEY"}
)
for rate in response.json():
print(f"1 USD = {rate['rate']} {rate['target']}")
# Output:
# 1 USD = 0.9215 EUR
# 1 USD = 0.7891 GBP
# 1 USD = 151.42 JPY
import requests
try:
response = requests.get(
"https://exchange-rateapi.com/api/v1/rates",
params={"source": "USD", "target": "EUR"},
headers={"Authorization": "Bearer era_live_YOUR_API_KEY"},
timeout=10
)
response.raise_for_status()
data = response.json()
print(f"Rate: {data[0]['rate']}")
except requests.exceptions.HTTPError as e:
if e.response.status_code == 401:
print("Invalid API key. Check your Authorization header.")
elif e.response.status_code == 429:
print("Rate limit exceeded. Try again later.")
else:
print(f"HTTP error: {e}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
[
{
"rate": 0.9215,
"source": "USD",
"target": "EUR",
"time": "2026-05-15T12:00:00Z"
}
]
[
{ "rate": 0.9215, "source": "USD", "target": "EUR", "time": "2026-05-15T12:00:00Z" },
{ "rate": 0.7891, "source": "USD", "target": "GBP", "time": "2026-05-15T12:00:00Z" },
{ "rate": 151.42, "source": "USD", "target": "JPY", "time": "2026-05-15T12:00:00Z" }
]
/api/v1/symbols endpoint.
Get your free API key and start fetching exchange rates in Python in under a minute.
Get Free API Key →