Skip to content

Asyncronous, lightweight Binance API connector with rate-limit management

License

Notifications You must be signed in to change notification settings

dvdctn/aiobinance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Async Binance API connector with rate-limit management

Description

aiobinance is an asynchronous lightweight Python client designed to interact with Binance's RESTful API. It provides Smart Date Range and API Rate Limit Management. This library is still in development and support for more endpoints will be implemented.

Key Features

  • Async Support: Designed for high-performance asynchronous operations using asyncio.
  • API Rate Limit Management: Manage API rate limits specifically for every single endpoint by automatically tracking and controlling the rate at which requests are sent to the API. This ensures that your application stays within the allowed rate limits, preventing request rejections and potential service disruptions.
  • Smart Date Range Management: This library simplifies working with large date ranges that may exceed the API's bounds by automatically splitting requests as needed. When a date range for a request is too large, the library breaks it into smaller, rate-limit-compliant requests and reassembles the results. This allows you to request broad date ranges in a single call, without worrying about rate limits or handling partial results.

Installation

The module requires Python 3.10+ and an asynchronous environment to handle async functions. Necessary dependencies:

Getting Started

To initialize the BinanceAsync client, you need:

  • API Key (optional)
  • API Secret (optional)
from binance import BinanceAsync
import asyncio

async def main():
    client = BinanceAsync(key="your-api-key", secret="your-secret-key")
    market_info = await client.marketInfo(symbol="BTCUSDT")
    print(market_info)

asyncio.run(main())

Available Methods

Public API

  • marketInfo

    Retrieve exchange information with optional filters.

    await client.marketInfo(symbol="BNBBTC")
  • klines

    Retrieve kline/candlestick bars for a symbol.

    await client.klines(
      symbol="BTCUSDT", # Can also be 'BTC/USDT' or 'BTC-USDT'
      interval='1h',
      since=datetime(2020, 1, 1),
      until=datetime(2023, 1, 1)
    )

Signed API

  • userAsset

    Retrieve user assets, optionally including BTC valuation.

    assets = await client.userAsset(asset="BTC", needBtcValuation=True)
  • spotTrades

    Retrieve spot trades for a specific symbol.

    assets = await client.spotTrades(
        symbol="BTCUSDT",
        since=datetime(2023, 1, 1),
    )
  • fiat_deposit_withdrawal

    Fetch fiat deposit/withdrawal records within a date range.

    from datetime import datetime
    
    transactions = await client.fiat_deposit_withdrawal(
        transactionType=FiatTransactionType.DEPOSIT,
        since=datetime(2023, 1, 1),
        until=datetime(2023, 2, 1)
    )

Notes

  • Error Handling: Currently, basic error handling is implemented. Future improvements will address handling more specific error cases.

License

This module is released under the MIT License.

Contributing

Contributions are welcome! Please open issues for any bugs or feature requests and feel free to submit pull requests.

Disclaimer

This project is in development and more methods will be added.


About

Asyncronous, lightweight Binance API connector with rate-limit management

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages