Skip to main content

Async Python client for currency exchange rates

Project description

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/yourusername/afxapicom.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())

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

afxapicom-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

afxapicom-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file afxapicom-0.1.0.tar.gz.

File metadata

  • Download URL: afxapicom-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for afxapicom-0.1.0.tar.gz
Algorithm Hash digest
SHA256 560f9faf2bd0dec42376d34d1ce12e76d556503ff925e556c54cb96d7a39eb19
MD5 b2a67b0d105862f04d5da56a8bf77c1b
BLAKE2b-256 93b40b9aae661c670256ac9ce0353307e3d0b66de2db626700bd1e067b987c65

See more details on using hashes here.

File details

Details for the file afxapicom-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: afxapicom-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for afxapicom-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36145bb1f67ea5fd3c3a464c8713e549d234a93206fa4f56191be5366b8e3fbc
MD5 a76993edab8c0d27bca677180382c50f
BLAKE2b-256 cc126e09ea2f31ae5de35e18e861924d8b9b0c24a54294c1f41ee5a9a75803c9

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