Skip to main content

Unofficial Python3 API connector for BingX's HTTP and WebSockets APIs.

Project description

Python-BingX

Python-bingx is a powerful and flexible Python package that allows you to easily interact with the BingX API. The package currently supports the Spot API, Standard API, Perpetual Swap API Reference V1, and Perpetual Swap API Reference V2. With python-bingx, you can retrieve real-time market data, manage your account, place trades, and more...

Installation

To install python-bingx, you can use pip:

pip install python-bingx

Usage

There are multiple ways to use python-bingx, depending on your needs and preferences.

Using BingX

The most straightforward way to use python-bingx is by importing the BingX class and initializing it with your API key and secret key:

from bingX import BingX

bingx_client = BingX(api_key="api_key", secret_key="secret_key")

Once you have initialized the client, you can call any of the available APIs, for example:

# Call the Trade API of Perpetual V2
bingx_client.perpetual_v2.trade.trade_order()

Using PerpetualV2

If you prefer to work with a specific API or version, you can import the relevant class and initialize it with your API key and secret key:

from bingX.perpetual.v2 import PerpetualV2

bingx_client = PerpetualV2(api_key="api_key", secret_key="secret_key")

Once you have initialized the client, you can call any of the available APIs, for example:

# Call the Trade API of Perpetual V2
bingx_client.trade.trade_order()

Handling Responses

Python-bingx uses requests library to communicate with the API and returns the response in JSON format. You can easily handle the response by accessing the relevant key(s) in the dictionary, for example:

# Get the symbol and last price of BTC/USDT
response = bingx_client.perpetual_v2.market.get_ticker("BTC-USDT")
symbol = response["symbol"]
last_price = response["lastPrice"]

Error Handling

In case of errors or exceptions, python-bingx will raise relevant exceptions with error message and error code. You can catch and handle the exceptions accordingly, for example:

from bingX import ClientError, ServerError

try:
    response = bingx_client.perpetual_v2.trade.create_order()
except (ClientError, ServerError) as e:
    error_code = e.error_code
    error_message = e.error_message

Contributing

Python-bingx welcomes contributions from the community! If you'd like to contribute, please fork the repository, create a feature branch, make your changes, and submit a pull request. Before submitting, please ensure that your code follows the PEP 8 style guide and includes appropriate tests.

License

Python-bingx is licensed under the MIT License. See the LICENSE file for more information.

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

python-bingx-1.0.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

python_bingx-1.0.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file python-bingx-1.0.0.tar.gz.

File metadata

  • Download URL: python-bingx-1.0.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for python-bingx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ad9369f2b35213aaafe64aca2ed5c6e6aa010a01e1a31e0aea33e6ed45b3fb72
MD5 e870c99720cf2b6a325aac97ce10e323
BLAKE2b-256 e28ea5ebfe7b107bbb8d2822d3c784e19e1bcbc5c3142f9fdac92b2de095ff49

See more details on using hashes here.

File details

Details for the file python_bingx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: python_bingx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for python_bingx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 592a23ba6de6b6ee06866774523f15372428d7125354d8f197bcdfd8c674ff79
MD5 d1e97971abb5c3cee3ee987fbee4646e
BLAKE2b-256 8dca0fc21d5fd19e3b4235d37ca3453d12e71b55546f6c8f05921fb40a6cbad5

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