Binance api python documentation

Getting StartedВ¶

InstallationВ¶

python-binance is available on PYPI. Install with pip :

Register on BinanceВ¶

Generate an API KeyВ¶

To use signed account methods you are required to create an API Key.

Initialise the clientВ¶

Pass your API Key and Secret

or for Asynchronous client

Using the Spot, Futures or Vanilla Options TestnetВ¶

Binance offers a Spot, Futures and Vanilla Options Testnet, to test interacting with the exchange.

To enable this set the testnet parameter passed to the Client to True.

The testnet parameter will also be used by any websocket streams when the client is passed to the BinanceSocketManager.

or for Asynchronous client

Using a different TLDВ¶

If you are interacting with a regional version of Binance which has a different TLD such as .us or ` .jp’ then you will need to pass this when creating the client, see examples below.

This tld will also be used by any websocket streams when the client is passed to the BinanceSocketManager.

or for Asynchronous client

Making API CallsВ¶

Every method supports the passing of arbitrary parameters via keyword matching those in the Binance API documentation. These keyword arguments will be sent directly to the relevant endpoint.

Each API method returns a dictionary of the JSON response as per the Binance API documentation. The docstring of each method in the code references the endpoint it implements.

The Binance API documentation references a timestamp parameter, this is generated for you where required.

Some methods have a recvWindow parameter for timing security, see Binance documentation.

API Endpoints are rate limited by Binance at 20 requests per second, ask them if you require more.

Async API CallsВ¶

aiohttp is used to handle asyncio REST requests.

Each function available in the normal client is available in the AsyncClient class.

The only difference is to run within an asyncio event loop and await the function like below.

Read Async basics for Binance for more information about asynchronous patterns.

Читайте также:  Как определить внутреннюю норму доходности для данного проекта

API Rate LimitВ¶

Check the get_exchange_info() call for up to date rate limits.

At the current time Binance rate limits are:

  • 1200 requests per minute
  • 10 orders per second
  • 100,000 orders per 24hrs

Some calls have a higher weight than others especially if a call returns information about all symbols. Read the official Binance documentation for specific information.

On each request Binance returns X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter) and X-MBX-ORDER-COUNT-(intervalNum) headers.

Источник

Binance api python documentation

Official Documentation for the Binance APIs and Streams.

  • Official Announcements regarding changes, downtime, etc. to the API and Streams will be reported here: https://t.me/binance_api_announcements
  • Streams, endpoints, parameters, payloads, etc. described in the documents in this repository are considered official and supported.
  • The use of any other streams, endpoints, parameters, or payloads, etc. is not supported; use them at your own risk and with no guarantees.
Name Description
rest-api.md Details on the Rest API (/api)
errors.md Descriptions of possible error messages from the Rest API
web-socket-streams.md Details on available streams and payloads
user-data-stream.md Details on the dedicated account stream
Wallet, Sub-account Details on Wallet and sub-accounts endpoints(/sapi, /wapi)
Margin, BLVT Details on Margin and BLVT endpoints(/sapi, /wapi)
Mining Details on Mining endpoints(/sapi, /wapi)
BSwap, Savings Details on BSwap and Savings endpoints(/sapi, /wapi)
USDT-M Futures Details on USDT-M Futures API (/fapi)
COIN-M Futures Details on COIN-M Futures API (/dapi)
  • Binance API Telegram Group
    • For any questions regarding sudden drop in performance with the API and/or Websockets.
    • For any general questions about the API not covered in the documentation.
  • Binance Developers
    • For any questions/help regarding code implementation with API and/or Websockets.
  • Binance Customer Support
    • For cases such as missing funds, help with 2FA, etc.

About

Official Documentation for the Binance Spot APIs and Streams

Источник

Binance api python documentation

Python client for the Binance API.

Requires python 3.6 or greater.

First, enter your API key and secret into config.yaml. Then run the command below:

python setup.py test

Any log messages are written to tests/test.log .

To enter a pdb shell on a test failure, run

See the pytest docs for more information.

Enabling all tests

By default, tests that would change your account in any way, such as placing an order or withdrawing funds, are disabled. To enable them, edit pytest.ini by changing

then follow the instructions in tests/test_actions.py.

Enabling these tests means that your account balances will be changed if the tests are successful. Follow the configuration instructions very carefully. Failing to do so could result in the tests altering your account in a negative way.

Most client methods described below return objects that can be found in binance/storage.py. These objects convert values into their natives types, including:

  • decimal strings to float
  • timestamps to datetime.datetime

Each object accepts a raw API version of the object in its constructor. These objects also have a to_json() method that returns the object as a JSON-dumpable dictionary.

Methods with names ending with _async are asynchronous coroutines that perform the same action as their synchronous counterpart. (Read more about Python’s asynchronous features here.)

Источник

Binance api python documentation

Welcome to python-binance v1.0.12

Updated 11th May 2021

This is an unofficial Python wrapper for the Binance exchange REST API v3. I am in no way affiliated with Binance, use at your own risk.

If you came here looking for the Binance exchange to purchase cryptocurrencies, then go here. If you want to automate interactions with Binance stick around.

If you’re interested in Binance’s new DEX Binance Chain see my python-binance-chain library

Make sure you update often and check the Changelog for new features and bug fixes.

  • Implementation of all General, Market Data and Account endpoints.
  • Asyncio implementation
  • Testnet support for Spot, Futures and Vanilla Options
  • Simple handling of authentication
  • No need to generate timestamps yourself, the wrapper does it for you
  • Response exception handling
  • Websocket handling with reconnection and multiplexed connections
  • Symbol Depth Cache
  • Historical Kline/Candle fetching function
  • Withdraw functionality
  • Deposit addresses
  • Margin Trading
  • Futures Trading
  • Vanilla Options
  • Support other domains (.us, .jp, etc)

Upgrading to v1.0.0+

The breaking changes include the migration from wapi to sapi endpoints which related to the wallet endpoints detailed in the Binance Docs

The other breaking change is for websocket streams and the Depth Cache Manager which have been converted to use Asynchronous Context Managers. See examples in the Async section below or view the websockets and depth cache docs.

Generate an API Key and assign relevant permissions.

If you are using an exchange from the US, Japan or other TLD then make sure pass tld=’us’ when creating the client.

To use the Spot or Vanilla Options Testnet, pass testnet=True when creating the client.

Read Async basics for Binance for more information.

If this library helped you out feel free to donate.

  • ETH: 0xD7a7fDdCfA687073d7cC93E9E51829a727f9fE70
  • LTC: LPC5vw9ajR1YndE1hYVeo3kJ9LdHjcRCUZ
  • NEO: AVJB4ZgN7VgSUtArCt94y7ZYT6d5NDfpBo
  • BTC: 1Dknp6L6oRZrHDECRedihPzx2sSfmvEBys

If you use Binance Chain check out my python-binance-chain library.

If you use Kucoin check out my python-kucoin library.

If you use IDEX check out my python-idex library.

About

Binance Exchange API python implementation for automated trading

Источник

Welcome to python-binance v1.0.12¶

Updated 11th May 2021

This is an unofficial Python wrapper for the Binance exchange REST API v3. I am in no way affiliated with Binance, use at your own risk.

If you came here looking for the Binance exchange to purchase cryptocurrencies, then go here. If you want to automate interactions with Binance stick around.

If you’re interested in Binance’s new DEX Binance Chain see my python-binance-chain library

Make sure you update often and check the Changelog for new features and bug fixes.

Features¶

  • Implementation of all General, Market Data and Account endpoints.
  • Asyncio implementation
  • Testnet support for Spot, Futures and Vanilla Options
  • Simple handling of authentication
  • No need to generate timestamps yourself, the wrapper does it for you
  • Response exception handling
  • Websocket handling with reconnection and multiplexed connections
  • Symbol Depth Cache
  • Historical Kline/Candle fetching function
  • Withdraw functionality
  • Deposit addresses
  • Margin Trading
  • Futures Trading
  • Vanilla Options
  • Support other domains (.us, .jp, etc)

Upgrading to v1.0.0+¶

The breaking changes include the migration from wapi to sapi endpoints which related to the wallet endpoints detailed in the Binance Docs

The other breaking change is for websocket streams and the Depth Cache Manager which have been converted to use Asynchronous Context Managers. See examples in the Async section below or view the websockets and depth cache docs.

Quick Start¶

Generate an API Key and assign relevant permissions.

If you are using an exchange from the US, Japan or other TLD then make sure pass tld=’us’ when creating the client.

To use the Spot or Vanilla Options Testnet, pass testnet=True when creating the client.

Источник

Читайте также:  Добыча цифровой криптовалюты это
Оцените статью