Python

Python Exchange Rate API

Fetch live and historical exchange rates in Python. Install our SDK with pip or call the REST API directly with requests.

Quick Start

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
Get your free API keySign up here to get an API key that starts with era_live_. The free plan includes 300 requests per month.

Using the SDK

The exchange-rateapi Python package wraps every API endpoint and handles authentication, retries, and response parsing for you.

Get Exchange Rate

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 an Amount

# Convert 1000 USD to EUR
result = client.convert("USD", "EUR", 1000)
print(f"$1,000 = {result['result']} EUR")

Historical Rates

# Get 30-day historical data
history = client.get_historical_rates("USD", "EUR", "30d")
for point in history["data"]:
    print(f"{point['date']}: {point['rate']}")

List Supported Currencies

# Get all supported currency codes
symbols = client.get_symbols()
for currency in symbols["currencies"]:
    print(f"{currency['code']}: {currency['name']}")

Without SDK (Using requests)

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

Multiple Targets

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

Error Handling

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}")

Response Format

Single Target Response

[
  {
    "rate": 0.9215,
    "source": "USD",
    "target": "EUR",
    "time": "2026-05-15T12:00:00Z"
  }
]

Multiple Targets Response

[
  { "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" }
]
160+ currencies supported — including USD, EUR, GBP, JPY, AUD, CAD, CHF, CNY, INR, BRL, and many more. See the full list via the /api/v1/symbols endpoint.

Start building with Python

Get your free API key and start fetching exchange rates in Python in under a minute.

Get Free API Key →