Python3 Toobit HTTP/WebSocket API Connector
Project description
tbpy
Official Python3 API connector for Toobit's HTTP and WebSocket APIs.
Installation
tbpy requires Python 3.10 or higher. Install via PyPI:
pip install tbpy
Quick Start
REST API
from tbpy import HTTP
# Public endpoints (no authentication)
client = HTTP(base_url="https://api.toobit.com")
print(client.get_exchange_info())
print(client.get_depth(symbol="BTCUSDT"))
# Authenticated endpoints
client = HTTP(
base_url="https://api.toobit.com",
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
)
print(client.get_account())
WebSocket Market Data
import time
from tbpy import WebSocket
def handle_message(msg):
print(msg)
ws = WebSocket(
url="wss://stream.toobit.com/quote/ws/v1",
on_message=handle_message,
)
ws.connect()
ws.subscribe(symbol="BTCUSDT", topic="realtimes")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
ws.disconnect()
WebSocket Account Data (Spot)
import time
from tbpy import HTTP, WebSocketAccount
http = HTTP(
base_url="https://api.toobit.com",
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
)
ws = WebSocketAccount(
http_client=http,
on_message=lambda msg: print(msg),
)
ws.connect()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
ws.disconnect()
WebSocket Account Data (Futures)
import time
from tbpy import HTTP, WebSocketFuturesAccount
http = HTTP(
base_url="https://api.toobit.com",
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
)
ws = WebSocketFuturesAccount(
http_client=http,
on_message=lambda msg: print(msg),
)
ws.connect()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
ws.disconnect()
Available APIs
Spot
| Category | Class | Description |
|---|---|---|
| Market Data | HTTP |
Exchange info, depth, trades, klines, tickers |
| Wallet | HTTP |
Withdraw, deposit address, deposit/withdraw history |
| Account & Trading | HTTP |
Orders, balances, trades, transfers |
| WS Market Data | WebSocket |
Real-time quotes, trades, klines, depth |
| WS Account Data | WebSocketAccount |
Balance, order, trade push events |
USDT-M Futures
| Category | Class | Description |
|---|---|---|
| Market Data | HTTP |
Futures exchange info, depth, trades, klines, funding rate |
| Account & Trading | HTTP |
Futures orders, positions, leverage, margin |
| WS Market Data | WebSocket |
Real-time futures quotes, mark price, index, depth |
| WS Account Data | WebSocketFuturesAccount |
Position, order, trade, TP/SL push events |
Examples
Check out the examples directory for complete usage examples.
Documentation
Full API documentation is available at https://api-docs.toobit.com.
License
MIT License. See LICENSE for details.
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
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
File details
Details for the file toobit_connector_python-0.1.0.tar.gz.
File metadata
- Download URL: toobit_connector_python-0.1.0.tar.gz
- Upload date:
- Size: 38.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b04c606d0b43d783d4fc33b32de4b8862fbeab7498d153035f7861180aa5e72
|
|
| MD5 |
133585aeea2da898cef3b148395c527c
|
|
| BLAKE2b-256 |
b4ee5a6fbf29340df2ce5502433030e7b7c6574b400d2a8e742105ed7e5d8475
|
File details
Details for the file toobit_connector_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: toobit_connector_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d0e06ad358de047a0c3d48e4c80d5b4f63b6140be13e16b12830a8cc6a27ce2
|
|
| MD5 |
39d7f345254e27e6fa98c35d1579c129
|
|
| BLAKE2b-256 |
7237f1c0514671356462f228942eafb416c89d2e066c9f4e14bb33e66850bb7e
|