A real-time currency converter that uses the Fixer.io API to fetch current exchange rates and convert between 170+ world currencies. Features an interactive command-line interface with support for all major currencies.
- Real-time exchange rates from Fixer.io API
- Support for 170+ currencies
- Convert between any two supported currencies
- Display exchange rates
- List all available currencies
- Formatted output with thousands separators
- Error handling and validation
- Environment variable support for API key
- Interactive menu system
- Language: Python
- Libraries:
requests==2.28.2
- API: Fixer.io (https://fixer.io/)
- Complexity: Beginner-Intermediate
# Install dependencies
pip install -r requirements.txt
# Run the program
python main.pyThis application requires a free API key from Fixer.io:
- Visit https://fixer.io/
- Sign up for a free account
- Copy your API access key
- Use it when prompted, or set as environment variable:
$env:FIXER_API_KEY="your_api_key_here"export FIXER_API_KEY="your_api_key_here"Add to your system environment variables or .env file.
python main.py==================================================
CURRENCY CONVERTER
==================================================
Enter your Fixer.io API key: your_key_here
Fetching exchange rates...
✓ Exchange rates loaded successfully!
Base currency: EUR
Last updated: 2024-01-15
Available currencies: 170
Options:
1. Convert currency
2. List available currencies
3. Exit
Enter your choice (1-3): 1
------------------------------------------------------------
From currency (e.g., USD): USD
To currency (e.g., EUR): INR
Amount: 100
============================================================
CONVERSION RESULT
============================================================
100.00 USD = 8,350.50 INR
============================================================
Exchange Rate: 1 USD = 83.5050 INR
============================================================
- Fetches latest exchange rates from Fixer.io API
- Base currency is EUR (Euro)
- All rates are relative to EUR
- API endpoint:
http://data.fixer.io/api/latest?access_key={key}
# If converting from non-EUR currency
if from_currency != 'EUR':
amount = amount / rates[from_currency]
# Convert to target currency
if to_currency != 'EUR':
amount = amount * rates[to_currency]{
"success": true,
"base": "EUR",
"date": "2024-01-15",
"rates": {
"USD": 1.18,
"GBP": 0.85,
"INR": 88.5,
"JPY": 130.2,
...
}
}- USD - US Dollar
- EUR - Euro
- GBP - British Pound
- JPY - Japanese Yen
- CNY - Chinese Yuan
- INR - Indian Rupee
- AUD - Australian Dollar
- CAD - Canadian Dollar
- CHF - Swiss Franc
- HKD - Hong Kong Dollar
170+ currencies including:
- All major world currencies
- Cryptocurrencies (on some plans)
- Precious metals (Gold, Silver)
- Special Drawing Rights (SDR)
Use option 2 in the menu to see the complete list.
Main class for currency conversion operations.
__init__(url): Initialize and fetch exchange ratesconvert(from_currency, to_currency, amount): Perform conversiondisplay_conversion(...): Format and display resultslist_currencies(): Show all available currencies
- Checks environment variable
FIXER_API_KEY - Prompts user if not found
- Provides instructions for obtaining API key
- Interactive menu loop
- Handles user input
- Manages conversion workflow
- Network connection errors
- Invalid API key
- Unsupported currencies
- Invalid amount (negative or non-numeric)
- API rate limiting
- Timeout errors
From: USD
To: EUR
Amount: 1000
Result: 1000.00 USD = 847.46 EUR
From: GBP
To: INR
Amount: 50
Result: 50.00 GBP = 5,205.88 INR
From: JPY
To: USD
Amount: 10000
Result: 10,000.00 JPY = 90.70 USD
- 100 requests per month
- Base currency: EUR only
- Monthly data updates
- No HTTPS support
- More requests
- Multiple base currencies
- Real-time updates
- HTTPS support
- Historical data
- Time-series data
url = f"http://data.fixer.io/api/latest?access_key={api_key}&base=USD"url = f"http://data.fixer.io/api/latest?access_key={api_key}&symbols=USD,GBP,JPY"import json
import time
# Save rates to file
with open('rates_cache.json', 'w') as f:
json.dump({'rates': self.rates, 'timestamp': time.time()}, f)
# Load from cache if recent
with open('rates_cache.json', 'r') as f:
cache = json.load(f)
if time.time() - cache['timestamp'] < 3600: # 1 hour
self.rates = cache['rates']- REST API integration
- HTTP requests with
requestslibrary - JSON data parsing
- Error handling and validation
- Class-based design
- User input handling
- Environment variables
- Data formatting and presentation
- GUI version with Tkinter
- Historical exchange rate charts
- Currency rate alerts
- Favorite currency pairs
- Batch conversions
- Export results to CSV/Excel
- Offline mode with cached rates
- Multi-currency calculator
- Currency trend analysis
- Mobile app version
- Check your API key is correct
- Ensure no extra spaces in the key
- Verify your Fixer.io account is active
- Check internet connection
- Try again after a few moments
- Check if Fixer.io is accessible
- Verify currency code is correct (3-letter ISO code)
- Check if currency is available in your plan
- Use option 2 to see available currencies
- Free plan: 100 requests/month
- Wait until next month or upgrade plan
- Implement caching to reduce requests
If Fixer.io doesn't meet your needs, consider:
- ExchangeRate-API (https://exchangerate-api.com/)
- CurrencyAPI (https://currencyapi.com/)
- Open Exchange Rates (https://openexchangerates.org/)
- Currency Layer (https://currencylayer.com/)
This project is open source and available for educational purposes.
Exchange rates are provided by Fixer.io and may not reflect real-time market rates. This tool is for informational purposes only and should not be used for financial decisions without verification.