Skip to main content

A lightweight Python package for retrieving and using foreign exchange rates and convert currencies

Project description

Python Currency Exchange Library

Currency Exchange Rate Library is a lightweight Python package for retrieving and using foreign exchange rates. It leverages the Exchange API by Fawaz Ahmed to provide up-to-date and historical exchange rates in a simple, developer-friendly manner.

Features:

  • Real-Time Exchange Rates: Fetch the latest exchange rates for any supported currency pair.
  • Historical Data: Retrieve exchange rates for any given date.
  • Easy Integration: Simple and intuitive API for seamless integration.
  • Case-insensitive currency codes support
  • Developed with Asynchronous approach with AsyncIO and AIOHTTP
  • High Accuracy: Powered by the reliable Exchange API.
  • Open Source: Licensed under MIT for community contributions and customizations.

Installation

pip3 install pyxrate

Dependencies

  • Python 3.7+
  • AIOHTTP and AsyncIO library for API communication
  • poetry
  • GNU/BSD make

Quick Start

from currency_exchange import converter

# Initialize the library
currency_client = converter.CurrencyConverter()

# Get the supported currency rates
all_currencies = currency_client.currencies()
print(f"All supported currencies: {all_currencies}")

# Check support of specific currency rate
# NOTE: currency codes are case-insensitive
currency = currency_client.currencies('uah')
print(f"Currency name: {currency}")

currency = currency_client.currencies('UAH')  
print(f"Currency name: {currency}")

# Get exchange rate between two currencies
# NOTE: currency codes are case-insensitive
rate = currency_client.get_exchange_rate('USD', 'UAH')
print(f"USD to UAH rate: {rate}")

rate = currency_client.get_exchange_rate('usd', 'uah')
print(f"USD to UAH rate: {rate}")

# Get historical exchange rate between two currencies for particular date
# NOTE: currency codes are case-insensitive
currency_client.currency_date = '2024-11-20'
historical_rate = currency_client.get_exchange_rate('USD', 'UAH')
print(f"USD to UAH rate at {currency_client.currency_date}: {historical_rate}")

# Convert currencies based on latest rates
# NOTE: currency codes are case-insensitive
currency_convert = currency_client.convert(2400, 'usd', 'uah')
print(f"Convert USD to UAH: {currency_convert}")

# Convert currencies by rates based on historical data
# NOTE: currency codes are case-insensitive
currency_client.currency_date = '2024-11-20'
currency_convert = currency_client.convert(2400, 'usd', 'uah')
print(f"Converting USD to UAH at {currency_client.currency_date} date: {currency_convert}")

Debug mode

from currency_exchange import converter

# Initialize the library
currency_client = converter.CurrencyConverter()

# Set log level to debug
currency_client.log_level = "DEBUG"

# Convert currencies by rates based on historical data
currency_client.currency_date = '2024-11-20'
currency_convert = currency_client.convert(2400, 'usd', 'uah')
print(f"Converting USD to UAH at {currency_client.currency_date} date: {currency_convert}")

Known Issues and Limitations

  • Historical Data Availability: The Exchange API provides historical exchange rate data only up to March 2, 2024. Any requests for dates beyond this range may result in throwing exceptions expected. So, within that, please be notified that all exchange operations by using this lib in terms of historical data limited by date of March 2, 2024

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxrate-0.1.10.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyxrate-0.1.10-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyxrate-0.1.10.tar.gz.

File metadata

  • Download URL: pyxrate-0.1.10.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.9.19 Darwin/23.6.0

File hashes

Hashes for pyxrate-0.1.10.tar.gz
Algorithm Hash digest
SHA256 461a736cf2b64f260a898970600f7dd07235753e688ea331ae8df80e27401f4d
MD5 679ed5dba50daf4bb886213fd88bb2ba
BLAKE2b-256 4a85602920ed120ba789b0af3357195dadc5ed4ffe0a94034d8bca3a189891d3

See more details on using hashes here.

File details

Details for the file pyxrate-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: pyxrate-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.9.19 Darwin/23.6.0

File hashes

Hashes for pyxrate-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 b12227a1309af4c65d0ebee86486ab670fbe49490fb2883f6c1da5d7331988e8
MD5 8e3a24d668fbec0181a311bb21bc001b
BLAKE2b-256 55970e05a5123dec5dcc339e77f0e4cf2f566d18ca44eddd8f00dc10520bf3b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page