pybotters
An advanced API client for python botters. This project is in Japanese.
📌 Description
pybotters is a Python library for 仮想通貨 botter (crypto bot traders).
This library is an HTTP and WebSocket API client. It has the following features, making it useful for developing a trading bot.
🚀 Features
- ✨ HTTP / WebSocket Client
- Automatic authentication for private APIs.
- WebSocket automatic reconnection and automatic heartbeat.
- A client based on
aiohttp.
- ✨ DataStore
- WebSocket message data handler.
- Processing of differential data such as order book updates
- High-speed data processing and querying
- ✨ Other Experiences
- Support for type hints.
- Asynchronous programming using
asyncio. - Discord community.
🏦 Exchanges
| Name | API auth | DataStore | Exchange API docs |
|---|---|---|---|
| bitFlyer | ✅ | ✅ | Link |
| GMO Coin | ✅ | ✅ | Link |
| bitbank | ✅ | ✅ | Link |
| Coincheck | ✅ | ✅ | Link |
| OKJ | ✅ | Not yet | Link |
| BitTrade | ✅ | Not yet | Link |
| Bybit | ✅ | ✅ | Link |
| Binance | ✅ | ✅ | Link |
| OKX | ✅ | ✅ | Link |
| Phemex | ✅ | ✅ | Link |
| Bitget | ✅ | ✅ | Link |
| MEXC | ✅ | No support | Link |
| KuCoin | ✅ | ✅ | Link |
| BitMEX | ✅ | ✅ | Link |
| Hyperliquid | ✅ | ✅ | Link |
🐍 Requires
Python 3.10+
🔧 Installation
From PyPI (stable version):
pip install pybotters
From GitHub (latest version):
pip install git+https://github.com/pybotters/pybotters.git
⚠️ Compatibility warning
pybotters is planning a completely new code base v2. It is recommended to specify version less than 2.0 (pybotters<2.0) when specifying it as a dependency.
📝 Usage
Example of bitFlyer API:
HTTP API
New interface from version 1.0: Fetch API.
More simple request/response.
import asyncio
import pybotters
apis = {
"bitflyer": ["YOUER_BITFLYER_API_KEY", "YOUER_BITFLYER_API_SECRET"],
}
async def main():
async with pybotters.Client(
apis=apis, base_url="https://api.bitflyer.com"
) as client:
# Fetch balance
r = await client.fetch("GET", "/v1/me/getbalance")
print(r.response.status, r.response.reason, r.response.url)
print(r.data)
# Create order
CREATE_ORDER = False # Set to `True` if you are trying to create an order.
if CREATE_ORDER:
r = await client.fetch(
"POST",
"/v1/me/sendchildorder",
data={
"product_code": "BTC_JPY",
"child_order_type": "MARKET",
"side": "BUY",
"size": 0.001,
},
)
print(r.response.status, r.response.reason, r.response.url)
print(r.data)
asyncio.run(main())
aiohttp-based API.
import asyncio
import pybotters
apis = {
"bitflyer": ["YOUER_BITFLYER_API_KEY", "YOUER_BITFLYER_API_SECRET"],
}
async def main():
async with pybotters.Client(
apis=apis, base_url="https://api.bitflyer.com"
) as client:
# Fetch balance
async with client.get("/v1/me/getbalance") as resp:
data = await resp.json()
print(resp.status, resp.reason)
print(data)
# Create order
CREATE_ORDER = False # Set to `True` if you are trying to create an order.
if CREATE_ORDER:
async with client.post(
"/v1/me/sendchildorder",
data={
"product_code": "BTC_JPY",
"child_order_type": "MARKET",
"side": "BUY",
"size": 0.001,
},
) as resp:
data = await resp.json()
print(data)
asyncio.run(main())
WebSocket API
import asyncio
import pybotters
async def main():
async with pybotters.Client() as client:
# Create a Queue
wsqueue = pybotters.WebSocketQueue()
# Connect to WebSocket and subscribe to Ticker
await client.ws_connect(
"wss://ws.lightstream.bitflyer.com/json-rpc",
send_json={
"method": "subscribe",
"params": {"channel": "lightning_ticker_BTC_JPY"},
},
hdlr_json=wsqueue.onmessage,
)
# Iterate message (Ctrl+C to break)
async for msg in wsqueue:
print(msg)
try:
asyncio.run(main())
except KeyboardInterrupt:
pass
DataStore
import asyncio
import pybotters
async def main():
async with pybotters.Client() as client:
# Create DataStore
store = pybotters.bitFlyerDataStore()
# Connect to WebSocket and subscribe to Board
await client.ws_connect(
"wss://ws.lightstream.bitflyer.com/json-rpc",
send_json=[
{
"method": "subscribe",
"params": {"channel": "lightning_board_snapshot_BTC_JPY"},
},
{
"method": "subscribe",
"params": {"channel": "lightning_board_BTC_JPY"},
},
],
hdlr_json=store.onmessage,
)
# Watch for the best prices on Board. (Ctrl+C to break)
with store.board.watch() as stream:
async for change in stream:
board = store.board.sorted(limit=2)
print(board)
try:
asyncio.run(main())
except KeyboardInterrupt:
pass
📖 Documentation
🔗 https://pybotters.readthedocs.io/ja/stable/ (Japanese)
🗽 License
MIT
💖 Author
Please sponsor me!:
X:
Discord:
Metadata
Release files for pybotters 1.11.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pybotters-1.11.2.tar.gz | 567.7 kB | Without provenance | Details for pybotters-1.11.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pybotters-1.11.2-py3-none-any.whl | Python 3 | none | any | Details for pybotters-1.11.2-py3-none-any.whl |
Total release size: 1.1 MB
Release files / pybotters-1.11.2.tar.gz
| Download URL | pybotters-1.11.2.tar.gz |
|---|---|
| Size | 567.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2924312fc6ff0e8f03a9acf9493f024b812369309aa961eff5e5875fff0aa4e6
|
|
BLAKE2b-256 checksum How to use checksums |
c592a6defbec7b4a15c6dbf39b46163c9032ac60a5c0c34a3a215e336d8ff050
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pybotters-1.11.2-py3-none-any.whl
| Download URL | pybotters-1.11.2-py3-none-any.whl |
|---|---|
| Size | 522.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e56dd61ba575c4349925c914f96183d91a6dda76da3b91c6749b460bfdf5d92
|
|
BLAKE2b-256 checksum How to use checksums |
b10c9e908e31bbf96d94712f029c9323aa8a2b16ce9e9d152feb3be73fe1ab12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pybotters 1.11.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.