Skip to content

Latest commit

 

History

History
151 lines (126 loc) · 3.46 KB

Binance.md

File metadata and controls

151 lines (126 loc) · 3.46 KB
Binance

Binance API Wrapper

Python 3.7+

PEP8

Async support (without cache)

Handles configurable requests cache, retries and general request errors.

Supports the latest API versions: https://github.com/binance-exchange/binance-official-api-docs


Installation:

pip install xnr-cryptowrapper

Functions:

Build around raw API commands, each endpoint is made directly available.
Currently supported endpoints, functions:

  • Public
    • /api/v1
      • exchange_information_GET
      • klines_GET
      • orderbook_GET
      • ping_GET
      • time_GET
      • trades_GET
      • trades_aggregate
      • ticker_24h_GET
    • /api/v3
      • price_GET
      • ticker_book_GET
      • ticker_price_GET
    • /wapi/v3
      • system_status_GET
  • Private
    • /api/v1
      • trades_history_GET
      • user_data_stream_DELETE
      • user_data_stream_POST
      • user_data_stream_PUT
    • /api/v3
      • account_GET
      • account_trades_GET
      • order_GET
      • order_POST
      • order_cancel_DELETE
      • order_test_POST
      • orders_all_GET
      • orders_open_GET
      • order_OCO_POST
      • order_OCO_cancel_DELETE
      • order_OCO_GET
      • order_OCO_all_GET
      • order_OCO_open_GET
    • /wapi/v3
      • sub_account_list_GET
      • sub_account_transfer_POST
      • sub_account_transfer_history_GET
      • user_account_API_trading_status_GET
      • user_account_status_GET
      • user_asset_detail_GET
      • user_dustlog_GET
      • user_trade_fee_GET
      • user_wallet_deposit_address_GET
      • user_wallet_deposit_history_GET
      • user_wallet_withdraw_POST
      • user_wallet_withdrawal_history_GET

Examples:

If unspecified, result will not be cached.
Retries avoided for errors (400, 401, 403, 404, 429, 500).
The method exchange_information_GET() will return rate limit infos.

Binance.ping_GET() (+ cache example)

>>> from cryptowrapper import Binance
>>> binance = Binance()
>>> binance.ping_GET()
{
    'cached': False
}
>>> binance.ping_GET()
{
    'cached': True
}

Binance.price_GET()

>>> from cryptowrapper import Binance
>>> api_key = "Declare you API key"
>>> api_secret = "Declare you API secret"
>>> binance = Binance(api_key=api_key, api_secret=api_secret)
>>> binance.price_GET(symbol="LTCBTC")
{
    'mins': 5,
    'price': '0.01098744',
    'cached': False
}

Binance.order_test_POST()

>>> import time
>>> from cryptowrapper import Binance
>>> api_key = "Declare you API key"
>>> api_secret = "Declare you API secret"
>>> binance = Binance(api_key=api_key, api_secret=api_secret)
>>> binance.order_test_POST(
        symbol="LTCBTC",
        side="BUY",
        type="LIMIT",
        timeInForce="GTC",
        quantity=10,
        price=0.009,
        recvWindow=5000,
        timestamp=int(time() * 1000)
    )
{
    'cached': False
}

For a quick combined example see: example.py
For the async version see: async_example.py


Feedback:

Constructive feedback & bug reports are welcome.
Contact informations: