Skip to main content

Python SDK for the AgavaDEX exchange API (REST + WebSocket)

Project description

AgavaDEX Python SDK

Python client for the AgavaDEX exchange API — a thin, typed wrapper over the public REST + WebSocket interface.

Install

pip install agavadex

Requires Python 3.9+.

Quick start

Public market data — no key needed

from agavadex import Client

with Client() as client:
    for sym in client.get_symbols():
        print(sym.symbol, sym.tick_size)

    book = client.get_order_book("AGAVAUSDT")
    print(book.bids[0].price, book.asks[0].price)

Private account & trading

API keys are created in the AgavaDEX web app (Account → API keys). Pass them to the client — never hard-code them; read them from the environment.

import os
from agavadex import Client

with Client(api_key=os.environ["AGAVADEX_API_KEY"],
            api_secret=os.environ["AGAVADEX_API_SECRET"]) as client:
    for balance in client.get_balances():
        print(balance.asset, balance.available)

    result = client.place_order(
        "AGAVAUSDT", side="buy", type="limit", price="100.00", qty="1",
    )
    print(result.order.id, result.order.status)

WebSocket streams

import asyncio
from agavadex import MarketDataStream

async def main():
    async with MarketDataStream(channels=["trades@AGAVAUSDT"]) as stream:
        async for msg in stream:
            print(msg.channel, msg.type, msg.data)

asyncio.run(main())

The public MarketDataStream needs no auth; the private UserStream takes api_key / api_secret and authenticates in-band. Both auto-reconnect and re-subscribe on a dropped socket.

The decimal contract

Every monetary value — price, qty, volume, fee amounts — is a decimal.Decimal, never a float. The API sends and receives these as JSON strings; this SDK parses them losslessly. When placing orders, price / qty accept a Decimal, str or int.

Errors

Non-2xx responses raise a typed exception — BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, RateLimitError, ServerError — all subclasses of APIError. Each carries status_code and the API's request_id; RateLimitError adds retry_after. Pass max_retries= to Client to auto-retry 429s.

What this SDK does not do

Withdrawals are not part of the AgavaDEX API and not in this SDK — they require a wallet signature and happen only in the web app.

Development

pip install -e ".[dev]"
pytest            # offline tests run with no credentials
ruff check .

Integration tests run only when AGAVADEX_API_KEY / AGAVADEX_API_SECRET are set, and are read-only — they never place orders.

Links

License

Apache-2.0

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

agavadex-0.1.1.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

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

agavadex-0.1.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agavadex-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b3bcf5f12276b8fcce6f36a72122c871e6cc2dd736831b5830be62fef7c7b755
MD5 08f451606465fc68eaf8e971b48b9692
BLAKE2b-256 d8e015d197f5a177ecfd3f6e12a23db2bbf06d3d64b7146d26906ce1e11a6f5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agavadex-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for agavadex-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f1af2f9961cd96d97160b956968a97d9a7a7578d22eb22d83e85f8ea4e8fd32
MD5 25ffb885d0a205003b09e52d11289516
BLAKE2b-256 4af597bad890b5a92c5702baac8235f1ed1cc7195529f717f6149605e36e4adc

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