Free Python Exchange Rate API

Welcome to the UnirateAPI Python documentation! Our free exchange rate API provides real-time currency conversion capabilities that you can easily integrate into your Python applications. Whether you're building a financial application, data analysis tool, or any other system that needs currency conversion, our API has you covered.

UnirateAPI is designed to be developer-friendly and reliable, with a focus on simplicity and performance. We provide both direct API access using standard Python libraries and an official Python client library for even easier integration.

With UnirateAPI, you get:

  • Real-time exchange rates from reliable sources
  • Simple RESTful API endpoints
  • Support for 590+ currencies
  • Completely free with no credit card required
  • 99.9% uptime guarantee
  • Fast response times (avg. 50ms)
  • Automatic currency updates every hour

Our Python solutions are designed to be:

  • Easy to integrate with minimal code changes
  • Compatible with Python 3.6 and above
  • Error-resistant with proper exception handling
  • Available as a PyPI package for easy installation
  • Open-source client library on GitHub

For more detailed information about our API endpoints, rate limits, and advanced features, please check our main API documentation.

Below you'll find examples showing how to use our API with Python, both directly and using our official client library.

Getting Started with Python

You can use our API in Python either by making direct HTTP requests or by using our official client library. We'll show you both approaches below.


# Option 1: Using the requests library directly

import requests

def convert_currency(api_key, from_currency, to_currency, amount):
    """
    Convert currency using the UnirateAPI
    """
    base_url = "https://api.unirateapi.com/api"
    url = f"{base_url}/convert"
    
    params = {
        "api_key": api_key,
        "from": from_currency,
        "to": to_currency,
        "amount": amount
    }
    
    response = requests.get(url, params=params)
    
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"API request failed: {response.text}")

# Example usage
try:
    api_key = "YOUR_API_KEY"
    result = convert_currency(api_key, "USD", "EUR", 100)
    print(f"Converted amount: {result['result']} {result['to']}")
except Exception as e:
    print(f"Error: {e}")


# Option 2: Using the official UnirateAPI Python client library
# First, install the library: pip install unirate-api

from unirate import UnirateClient

# Initialize the client
client = UnirateClient(api_key="YOUR_API_KEY")

# Get current exchange rate
rate = client.get_rate("USD", "EUR")
print(f"Current USD to EUR rate: {rate}")

# Convert amount
converted = client.convert(amount=100, from_currency="USD", to_currency="EUR")
print(f"100 USD = {converted} EUR")

# Get supported currencies
currencies = client.get_supported_currencies()
print(f"Supported currencies: {currencies[:5]}...") # Show first 5

Response Example


# Direct API Response:
{
    "from": "USD",
    "to": "EUR",
    "amount": 100,
    "result": 92.45
}

# Client Library Outputs:
Current USD to EUR rate: 0.9245
100 USD = 92.45 EUR
Supported currencies: ['USD', 'EUR', 'GBP', 'JPY', 'AUD']...

Important Notes

  • Replace 'YOUR_API_KEY' with your actual API key
  • Install the client library with: pip install unirate-api
  • The client library automatically handles errors and retries
  • Make sure to handle API errors appropriately in production
  • Use the client library for the simplest integration experience
  • Check our GitHub repository for the latest client library updates
  • Store your API key securely using environment variables

Ready to Get Started?

Sign up now to get your API key and start converting currencies in your Python applications.

Get Your API Key