Skip to main content

Buda.com API client for REST and WebSocket APIs with sync and async support.

Project description

Buda Client

A typed Python client for the Buda.com REST and WebSocket APIs — sync and async.

CI Coverage License Python 3.12 | 3.13 | 3.14 Alpha


Buda Client is a Python library that wraps the Buda.com API, giving you a clean, fully typed interface for querying markets, managing orders, checking balances, and streaming real-time data — all without having to deal with raw HTTP requests or WebSocket frames yourself. It works great for scripts, bots, data pipelines, or just poking around from a REPL.

[!WARNING] This is not an official Buda.com product. It is an independent, community-driven project with no affiliation to or endorsement by Buda.com.

The library is currently in alpha (v0.1.0). APIs may change, features may be incomplete, and bugs are expected. If you choose to use it in production or with real funds, you do so entirely at your own risk. The authors assume no responsibility for any financial loss, data issues, or other damages that may result from its use.

Features

  • Sync and async REST clientsBudaClient for synchronous code, AsyncBudaClient for asyncio workflows. Both expose the same intuitive API.
  • Real-time WebSocket streaming — Subscribe to order book updates, trades, balances, orders, and deposits via BudaWebSocketClient.
  • HMAC-SHA384 authentication — Secure request signing handled automatically when you provide credentials.
  • Proactive rate limiting — A sliding-window limiter throttles requests before they hit the server, respecting per-second, per-minute (authenticated), and per-minute (unauthenticated) limits.
  • Automatic retries — Failed requests on 429, 500, and 503 are retried with exponential backoff, honoring the server's Retry-After header when present.
  • Pydantic v2 models — Every API response is parsed into a strict, typed Pydantic model. No more guessing what keys a dict has.
  • Flexible credential providers — Pass credentials directly, read them from environment variables, or load them from a .env file.
  • Full type safety — Developed with Pyright in strict mode. Your editor's autocomplete will thank you.

Installation

[!NOTE] Buda Client is not yet published on PyPI. Install it directly from GitHub:

uv add git+https://github.com/mschiaff/buda-client.git

or with pip:

pip install git+https://github.com/mschiaff/buda-client.git

Requirements: Python 3.12+

Quick Start

Fetching public market data

No credentials needed — just create a client and go:

from buda import BudaClient

with BudaClient() as client:
    # List all available markets
    markets = client.public.markets()
    for market in markets.root:
        print(f"{market.id}: {market.base_currency}/{market.quote_currency}")

    # Get the ticker for a specific market
    ticker = client.public.tickers("btc-clp")
    print(f"BTC-CLP last price: {ticker.last_price.value} {ticker.last_price.currency}")

    # Fetch the order book
    book = client.public.order_book("btc-clp")
    print(f"Best bid: {book.bids.max().price}, Best ask: {book.asks.min().price}")

The clients also work fine without a context manager — just remember to close them when you're done:

from buda import BudaClient

client = BudaClient()
markets = client.public.markets()
client.close()

Async usage

Same API, just async:

import asyncio
from buda import AsyncBudaClient

async def main():
    async with AsyncBudaClient() as client:
        ticker = await client.public.tickers("btc-clp")
        print(f"Last price: {ticker.last_price.value}")

asyncio.run(main())

Authentication

Choose the credential provider that fits your setup:

from buda import BudaClient, StaticCredentials, EnvCredentials, DotEnvCredentials

# Option 1: Pass credentials directly
provider = StaticCredentials(api_key="your-key", api_secret="your-secret")

# Option 2: Read from BUDA_API_KEY and BUDA_API_SECRET environment variables
provider = EnvCredentials()

# Option 3: Load from a .env file
provider = DotEnvCredentials()  # looks for .env in the current directory

with BudaClient(provider=provider) as client:
    # Now you can access private endpoints
    balances = client.private.balances()
    for balance in balances.root:
        print(f"{balance.id}: {balance.available_amount.value} available")

    me = client.private.me()
    print(f"Logged in as: {me.email}")

Creating an order

from buda import BudaClient, DotEnvCredentials, OrderCreate

with BudaClient(provider=DotEnvCredentials()) as client:
    order = client.private.create_order(
        "btc-clp",
        payload=OrderCreate(
            type="Bid",
            price_type="limit",
            amount=0.001,
            limit={"price": 50_000_000},
        ),
    )
    print(f"Order {order.id} created — state: {order.state}")

WebSocket streaming

Stream real-time data with an async handler:

import asyncio
from buda import BudaWebSocketClient

async def on_event(data: dict) -> None:
    print(f"Event: {data}")

async def main():
    ws = BudaWebSocketClient()
    await ws.book("btcclp", handler=on_event)

asyncio.run(main())

For private channels (balances, orders, deposits), pass your pubsub_key:

ws = BudaWebSocketClient(pubsub_key="your-pubsub-key")
await ws.orders(handler=on_event)

[!TIP] You can get your pubsub_key from the me() endpoint: client.private.me().pubsub_key.

Configuration

Customize client behavior through BudaSettings:

from buda import BudaClient, BudaSettings

settings = BudaSettings(
    timeout=30.0,                   # Request timeout in seconds (default: 10)
    retry_max_attempts=5,           # Max retry attempts (default: 3)
    rate_limit_per_second=10,       # Per-second request limit (default: 20)
)

with BudaClient(settings=settings) as client:
    ...

See the BudaSettings class for the full list of configurable options, including retry backoff parameters, rate limit windows, and WebSocket timeouts.

Contributing

Contributions are welcome! Whether it's a bug report, feature suggestion, or pull request — every bit helps.

Check out the Contributing Guide to get started.

License

This project is licensed under the Apache License 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

buda_client-0.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

buda_client-0.1.0-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: buda_client-0.1.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for buda_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60b3faaaba8fc03fc56f325e7047bba434cac8c6ea45f0d1681a8eacbc2bd8b6
MD5 1eddb63cbda039f4b510e2814aea1161
BLAKE2b-256 448de4e7e1383b2ffc2d142b0d1e7329bc219c559cbe3d1d39a318ac1f124932

See more details on using hashes here.

Provenance

The following attestation bundles were made for buda_client-0.1.0.tar.gz:

Publisher: release.yml on mschiaff/buda-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: buda_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for buda_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61bc455ce276e1fa512ba38769b974647d8d0311f8c565d3e7999b68a1a59376
MD5 70076772fadfdd0756d7cf417181f8c9
BLAKE2b-256 4400634f11881b6527891f3636a823f95b563c8f1adc7993849f9d9922611523

See more details on using hashes here.

Provenance

The following attestation bundles were made for buda_client-0.1.0-py3-none-any.whl:

Publisher: release.yml on mschiaff/buda-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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