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/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())

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.1.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.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for afxapicom-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a2239233209b58adeada1355fbcafb1e74e73767ab723a4b43f5d51c9c1e091f
MD5 47c00ad51ba63422d9eff9d97023dc35
BLAKE2b-256 f508e5f1c4f003ecb0560d4907c3badb50e1dc6a7a991b352486d7464e92249b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: afxapicom-0.1.1-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.11

File hashes

Hashes for afxapicom-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d2a73c922611e2107d35786d204b4454e0091779d15d04af4b735ff9cb1e7f6
MD5 ac3bce1e436b2fc2f9af1ffe5af1a1de
BLAKE2b-256 68292bde104431d946d5eabc29eeae84c5ae418949a4ce096b1f08adbbee6b7f

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