Last Updated: 2024-11-06 (Version 3)
This Forex API library offers a robust solution for integrating forex market data into your applications. With real-time currency rates, historical information, and technical analysis tools, it caters to a wide range of financial data needs.
- Over 2,000 currency pairs supported
- Live updates every 10 seconds
- Comprehensive historical records spanning 25 years
- Built-in tools for technical indicators and moving averages
- Global economic calendar with detailed event tracking
- Python version 3.13.0 or higher
- An active API key from ForexRatesAPI
Download the repository and install the required dependencies using pip
:
git clone https://github.com/forexratesapi619/Forex_Api_Python.git
cd Forex_Api_Python
pip install -r requirements.txt
- Register on the ForexRatesAPI portal to obtain your API key.
- Provide the API key while initializing the
ForexRate
class in your Python code.
from forex_rate import ForexRate
# Configure the API client
forex_api = ForexRate(api_key='YOUR_API_KEY')
# Fetch live currency rates
latest_price = forex_api.get_latest_price("GBP/CHF")
print("Latest price for GBP/CHF:", latest_price)
All responses are returned in JSON format. Below is a sample response for a currency rate query:
{
"status": true,
"code": 200,
"msg": "Request Successful",
"data": [
{
"id": "41",
"open": "1.11997",
"high": "1.12864",
"low": "1.12201",
"close": "1.12425",
"ask": "1.12447",
"bid": "1.12403",
"spread": "4.4",
"change": "+0.00428",
"percent_change": "+0.38%",
"timestamp": "1730874177",
"symbol": "GBP/CHF",
"datetime": "2024-11-06 06:22:57"
}
],
"meta": {
"server_time": "2024-11-06 06:23:41 UTC",
"credits_used": 1
}
}
-
Retrieve Supported Symbols
Obtain a list of available forex and crypto trading pairs:
symbols = forex_api.get_symbols_list()
-
Fetch Latest Rates
Get the current exchange rates for specific pairs:
latest_price = forex_api.get_latest_price(["EUR/USD", "USD/JPY"])
-
Currency Conversion
Perform conversions between currencies:
result = forex_api.get_converter(200, 'EUR', 'USD') print(result)
-
Currency Information
Access detailed information about a currency:
profile = forex_api.get_profile('EUR')
-
Base Currency Quotes
Retrieve all rates relative to a base currency:
base_prices = forex_api.get_base_prices('USD')
-
Historical Data
Access past rates for selected currencies over a specified timeframe:
history = forex_api.get_history({ 'symbol': 'EUR/USD', 'period': '1d', 'from': '2024-10-01', 'to': '2024-10-31' })
-
Technical Analysis Tools
Leverage built-in tools for moving averages, pivot points, and more:
ma = forex_api.get_moving_averages('EUR/USD', '1d')
-
Economic Calendar
Stay updated with upcoming economic events:
events = forex_api.get_economy_calendar(from_date='2024-11-01', to_date='2024-11-05')
-
Search Functionality
Locate forex symbols based on keywords:
search_results = forex_api.get_search_query('BTC')
For real-time streaming and advanced features, check out the WebSocket API options available with this library.
Need help? Reach out via live chat or refer to the documentation provided on the official site.
This project is distributed under the MIT License. See the LICENSE file for further details.