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.0.tar.gz (22.5 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.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agavadex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d7c8518c575b8d69dd2560933c70d067bcb499c0525d953a9573fc446574131
MD5 19c96ae3c165ede3942590cc4b753c28
BLAKE2b-256 ef8a8b675f0f9b4053b6c507957fd91175fe69d502040711ebd1fd0fb9fdb4f4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for agavadex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ef9cabcf3cade482727f5515d1ffcab132956bcb9022f0ac32d4f1194b76963
MD5 d24544cfa16e1adae1cc360ba0272f7a
BLAKE2b-256 bab59794cf25ead3122cb1619a0e7e3093c004fc33bb100ae41cdef4cab65ad4

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