Skip to main content

An advanced API client for python botters.

Project description

PyPI PyPI - Python Version PyPI - License Downloads

pytest publish Code style: black Documentation Status

GitHub Repo stars GitHub forks Discord

[Preview] pybotters

An advanced API client for python botters.

📌 Description

pybotters仮想通貨 botter 向けの Python ライブラリです。

複数取引所に対応した非同期 I/O の API クライアントであり、bot 開発により素晴らしい DX を提供します。

🚧 In development

pybotters は現在 ** Previewバージョン ** です。 一部機能は開発中です。

開発状況については こちら(Issues) を参照してください。

🚀 Features

  • ✨ HTTP / WebSocket Client
    • 複数取引所のプライベート API を自動認証
    • aiohttp ライブラリを基盤とした非同期通信
    • WebSocket の自動再接続、自動ハートビート
  • ✨ DataStore
    • WebSocket 用のデータ保管クラス
    • ピュア Python データモデルによる高速なデータ参照
    • 取引所別モデルの実装
  • ✨ Developer Experience
    • asyncio ライブラリを利用した非同期プログラミング
    • 型ヒントのサポート

🏦 Exchanges

Name API auth DataStore API docs
Bybit ✅ (Futures v2) Official v5 / Futures v2
Binance Official
OKX Official
Phemex Official
Bitget Official
MEXC WIP Official / v3
KuCoin Official
BitMEX Official
bitFlyer Official
GMO Coin Official
bitbank Official
Coincheck Official

🐍 Requires

Python 3.7+

🔧 Installation

pip install pybotters

🌏 Quickstart

Single exchange

import asyncio
import pybotters

apis = {
    "bybit": ["BYBIT_API_KEY", "BYBIT_API_SECRET"],
}

async def main():
    async with pybotters.Client(apis=apis, base_url="https://api.bybit.com") as client:
        # REST API
        resp = await client.get("/v2/private/position/list", params={"symbol": "BTCUSD"})
        data = await resp.json()
        print(data)

        # WebSocket API (with defautl print handler)
        ws = await client.ws_connect(
            url="wss://stream.bybit.com/realtime",
            send_json={"op": "subscribe", "args": ["trade.BTCUSD", "order", "position"]},
        )
        await ws # Ctrl+C to break

try:
    asyncio.run(main())
except KeyboardInterrupt:
    pass

Multiple exchanges

apis = {
    "bybit": ["BYBIT_API_KEY", "BYBIT_API_SECRET"],
    "binance": ["BINANCE_API_KEY", "BINANCE_API_SECRET"],
}

async def main():
    async with pybotters.Client(apis=apis) as client:
        await client.post("https://api.bybit.com/v2/private/order/create", data={"symbol": "BTCUSD", ...: ...})
        ...
        await client.post("https://dapi.binance.com/dapi/v1/order", data={"symbol": "BTCUSD_PERP", ...: ...})
        ...

📖 Wiki

詳しい利用方法は 👉 GitHub Wiki

現在こちらに移行中です 👉 Read the Docs

🗽 License

MIT

💖 Author

Twitter:

Twitter Follow

Discord:

Discord Widget

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

pybotters-0.16.0.tar.gz (44.2 kB view hashes)

Uploaded Source

Built Distribution

pybotters-0.16.0-py3-none-any.whl (57.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page