Skip to main content

Async Python client for WhiteBit API

Project description

aiowhitebit

Async Python client for WhiteBit API

Features

  • Private http V4 API
  • Public WS API
    • Enhanced WebSocket events with event_time and update_id metadata
    • BookTicker WebSocket stream for real-time best bid/ask prices
    • Market depth subscriptions with enhanced metadata support
  • Public http v1
  • Public http v2
  • Public http v4
    • Funding history endpoint for futures markets
  • Webhook support with examples
  • Rate limiting
  • Type hints
  • Pydantic models
  • Async/await support

Installation

pip install aiowhitebit

Quick Start

import asyncio
from aiowhitebit.clients.public import PublicV4Client

async def main():
    client = PublicV4Client()

    # Get market info
    markets = await client.get_market_info()
    print(f"Number of markets: {len(markets)}")

    # Get market activity
    activity = await client.get_market_activity()
    print(f"BTC_USDT last price: {activity.get('BTC_USDT').last_price}")

asyncio.run(main())

New Features in v0.3.0

BookTicker WebSocket Stream

import asyncio
from aiowhitebit.clients.websocket import PublicWebSocketClient, SubscribeRequest

async def bookticker_example():
    client = PublicWebSocketClient()

    # Subscribe to BookTicker stream
    response = await client.bookticker_subscribe("BTC_USDT")
    print(f"Subscribed: {response}")

    # Unsubscribe from BookTicker stream
    response = await client.bookticker_unsubscribe("BTC_USDT")
    print(f"Unsubscribed: {response}")

    await client.close()

asyncio.run(bookticker_example())

Funding History for Futures Markets

import asyncio
from aiowhitebit.clients.public import PublicV4Client

async def funding_history_example():
    client = PublicV4Client()

    # Get funding rate history for BTC_USDT futures
    history = await client.get_funding_history("BTC_USDT")

    for item in history.result:
        print(f"Time: {item.timestamp}, Rate: {item.funding_rate}")

asyncio.run(funding_history_example())

Enhanced WebSocket Events with Metadata

All WebSocket events now include optional event_time and update_id fields for better tracking and synchronization:

# WebSocket responses now include metadata
{
    "method": "depth_update",
    "params": {...},
    "event_time": 1640995200000,  # Event timestamp
    "update_id": 12345           # Unique update identifier
}

Documentation

For detailed documentation and examples, visit our GitHub repository.

Development

# Clone the repository
git clone https://github.com/doubledare704/aiowhitebit.git
cd aiowhitebit

# Install development dependencies
pip install -r requirements-dev.txt

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

License

MIT License - see LICENSE file for details

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

aiowhitebit-0.3.0.tar.gz (45.3 kB view details)

Uploaded Source

Built Distribution

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

aiowhitebit-0.3.0-py3-none-any.whl (48.4 kB view details)

Uploaded Python 3

File details

Details for the file aiowhitebit-0.3.0.tar.gz.

File metadata

  • Download URL: aiowhitebit-0.3.0.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for aiowhitebit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a03ce6453bcad4fd06edbda752de51e31045ce0e9c6b5874f14e92fe45a6cbc6
MD5 9e77a4d16ca416b38a96b888b15b907b
BLAKE2b-256 6c0475297c71edc95183b00dcebc016f421bba31d02eb7147dd348f95e8d8190

See more details on using hashes here.

File details

Details for the file aiowhitebit-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: aiowhitebit-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 48.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for aiowhitebit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5dd51010e0fecc8b08639271675d1ab00419ea09287adb073b6154a6792e5164
MD5 9b165cd0c2a45c9bee78758b42872a07
BLAKE2b-256 2fd39e20e8791d91231ca8eafb2be22d40356fd8419d1752fa2255fd23b6bea1

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