Skip to content

MrBaconHat/afxapi-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

afxapicom

An unofficial async Python client for currency exchange rates.

Installation

Install from pip:

pip install afxapicom

Install from source:

pip install git+https://github.com/MrBaconHat/afxapi-python.git

Usage

All requests are made using the Client class, initialized with your API key.

import afxapicom
import asyncio

async def main():
    client = afxapicom.Client('YOUR_API_KEY')
    # make calls here

asyncio.run(main())

Check API Status

result = await client.status()
print(result)

Retrieve Currencies

result = await client.currencies(currencies=['EUR', 'USD'])
print(result)

Latest Exchange Rates

result = await client.latest(base_currency='USD', currencies=['EUR', 'GBP'])
print(result)

Historical Exchange Rates

result = await client.historical('2024-01-01', base_currency='USD')
print(result)

Exchange Rates Over a Range

result = await client.range('2024-01-01', '2024-01-07', base_currency='USD')
print(result)

Convert Currencies

result = await client.convert(1000, base_currency='USD', currencies=['EUR', 'GBP'])
print(result)

Error Handling

from afxapicom import Client
from afxapicom.errors import AuthenticationFailed, RateLimited, QuotaExceeded

async def main():
    client = Client('YOUR_API_KEY')
    try:
        result = await client.latest()
        print(result)
    except AuthenticationFailed:
        print("Invalid API key")
    except RateLimited:
        print("Rate limit hit, slow down")
    except QuotaExceeded:
        print("Monthly quota exceeded")

asyncio.run(main())

About

Modern async Python wrapper for FXAPI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%