This is a lightweight library that works as a connector to BingX public API.
Project description
BingX API Connector Python (Bixpy)
This is a lightweight library that works as a connector to BingX public API
Installation
pip install Bixpy
Supported functionality
Account & Wallet API
- Spot account
- Sub-account
- Wallet deposits and withdrawals
- Agant
Spot API
- Market Interface
- Trade interface
- Websocket Market Data
- Websocket Account Data
Perpetual Futures API
- Market Interface
- Account Interface
- Trade Interface
- Websocket Market Data
- Websocket Account Data
Standard Contract API
- Standard Contract Interface
Copy Trading API
- Copy Trading Interface
Importing
def on_message(ws, data: dict) -> None:
"""
Event handler for SpotWebsocket messages
"""
print(data)
proxies ={ 'https': 'http://127.0.0.1:10809' }
api_key="YOUR API KEY"
secret_key="YOUR API SECRET"
# ACCOUNT AND WALLET
from Bixpy import Account
account=Account(api_key=api_key,api_secret= secret_key, proxies=proxies)
get_listen_key=account.generate_listen_Key()
listen_key=get_listen_key["listenKey"]
# SPOT
from Bixpy import Spot
from Bixpy import SpotAcccountWebsocket
from Bixpy import SpotMarketWebsocket
from Bixpy import SpotOrder
spot=Spot(api_key=api_key,api_secret= secret_key, proxies=proxies)
ws_spot_account=SpotAcccountWebsocket(listen_key=listen_key, on_message=on_message, proxies=proxies)
ws_spot_market=SpotMarketWebsocket( on_message=on_message, proxies=proxies)
# PERPETUAL FUTURES
from Bixpy import Perpetual
from Bixpy import PerpetualMarketWebsocket
from Bixpy import PerpetualAccountWebsocket
from Bixpy import PerpetualOrder,PerpetualOrderReplace
perpetual=Perpetual(api_key=api_key,api_secret= secret_key, proxies=proxies)
ws_perpetual_market=PerpetualMarketWebsocket(on_message=on_message, proxies=proxies)
ws_perpetual_account=PerpetualAccountWebsocket(listen_key=listen_key, on_message=on_message, proxies=proxies)
# STANDARD FUTURES
from Bixpy import Standard
standard=Standard(api_key=api_key,api_secret= secret_key, proxies=proxies)
# COPY TRADING
from Bixpy import CopyTrading
copy_trading=CopyTrading(api_key=api_key,api_secret= secret_key, proxies=proxies)
Spot
Usage examples:
from Bixpy import Spot,SpotOrder
spot=Spot()
# Get server timestamp
print(spot.server_time())
# Get klines of BTCUSDT at 1m interval
print(spot.kline("BTC-USDT", "1m"))
# Get last 10 klines of BNBUSDT at 1h interval
print(spot.kline("BNB-USDT", "1h", limit=10))
# API key/secret are required for trade endpoints
spot = Spot(api_key='<api_key>', api_secret='<api_secret>')
order=SpotOrder(symbol="BTC-USDT",side="BUY",order_type="LIMIT",quantity=0.002,price=9500,time_in_force="GTC")
print(spot.new_order(order))
Proxy
Proxy is supported.
from Bixpy import Spot
proxies ={ 'https': 'http://127.0.0.1:10809' }
client= Spot(proxies=proxies)
Account & Wallet
from Bixpy import Account
proxies ={ 'https': 'http://127.0.0.1:10809' }
api_key="YOUR API KEY"
secret_key="YOUR API SECRET"
account=Account(api_key=api_key,api_secret= secret_key, proxies=proxies)
balance=account.balance()
print(f'Asset{"":<10}Available{"":<20}Locked')
print("_"*50)
for coin in balance["data"]["balances"]:
print(f'{coin["asset"]:<15}{coin["free"]:<30}{coin["locked"]}')
"""
Asset Available Locked
__________________________________________________
USDT 2.2821580243871558 0
ZAT 3 0
TONCOIN 0.0006540539999999999 0
SUI 0 0
GOAT 0 0
BNB 0 0
DOGS 0 0
MAJOR 0 0
SSE 0 0
ICE 0 0
MEMEFI 0 0
VST 100008.04091207 0
AIDOGE 0 0
HMSTR 0 0
XRP 0 0
NOT 0 0
TRX 0 0
RAY 0 0
"""
Websocket
from Bixpy import SpotMarketWebsocket
from time import sleep
proxies ={ 'https': 'http://127.0.0.1:10809' }
def on_message(ws, data: dict) -> None:
"""
Event handler for SpotWebsocket messages
"""
print(data)
ws=SpotMarketWebsocket( on_message=on_message,proxies=proxies )
ws.kline("BTC-USDT","1min")
sleep(30)
ws.stop()
Donate
TonCoin and other tokens of the TON network:
Wallet: abbas-bachari.ton
If you are planning to send another token, please contact me.
Sponsor
Alternatively, sponsor me on Github using Github Sponsors.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bixpy-1.0.2.tar.gz
(30.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
bixpy-1.0.2-py3-none-any.whl
(40.3 kB
view details)
File details
Details for the file bixpy-1.0.2.tar.gz.
File metadata
- Download URL: bixpy-1.0.2.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56b4e186cbf9a0815a98a80e1ceca0b8c63612df2d5461242bbbcc45ac6a5510
|
|
| MD5 |
13d2c4ba7414232bae47fa55053bbaff
|
|
| BLAKE2b-256 |
c21f9b27d4b9385a790ec37cd39828e33f48d8efc05efe46ee1c5ef05c8b9093
|
File details
Details for the file bixpy-1.0.2-py3-none-any.whl.
File metadata
- Download URL: bixpy-1.0.2-py3-none-any.whl
- Upload date:
- Size: 40.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35b595fde13051f7c087d5b0e93a84e7cea7627efcd346509be5b9011e2e77f8
|
|
| MD5 |
9965a939ff856da3a3f6eaa91d119169
|
|
| BLAKE2b-256 |
af77534aef6fbff1c26699a89762f248b918d5dc953494318a890542b4a1ef37
|