Name | pybotters JSON |
Version |
1.7.1
JSON |
| download |
home_page | None |
Summary | An advanced API client for python crypto bot traders |
upload_time | 2025-01-02 15:12:47 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
aiohttp
crypto
exchange
trading
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[
![PyPI](https://img.shields.io/pypi/v/pybotters)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pybotters)
![PyPI - License](https://img.shields.io/pypi/l/pybotters)
](https://pypi.org/project/pybotters/)
[![Downloads](https://static.pepy.tech/badge/pybotters)](https://pepy.tech/project/pybotters)
[![CI](https://github.com/pybotters/pybotters/actions/workflows/ci.yml/badge.svg)](https://github.com/pybotters/pybotters/actions/workflows/ci.yml)
[![publish](https://github.com/pybotters/pybotters/actions/workflows/publish.yml/badge.svg)](https://github.com/pybotters/pybotters/actions/workflows/publish.yml)
[![Documentation Status](https://readthedocs.org/projects/pybotters/badge/?version=latest)](https://pybotters.readthedocs.io/ja/latest/?badge=latest)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![GitHub Repo stars](https://img.shields.io/github/stars/pybotters/pybotters?style=social)](https://github.com/pybotters/pybotters/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/pybotters/pybotters?style=social)](https://github.com/pybotters/pybotters/network/members)
[![Discord](https://img.shields.io/discord/832651305155297331?label=Discord&logo=discord&style=social)](https://discord.com/invite/CxuWSX9U69)
[![GitHub Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=181717&&style=flat-square&labelColor=white)](https://github.com/sponsors/MtkN1)
# pybotters
![pybotters logo](https://raw.githubusercontent.com/pybotters/pybotters/main/docs/logo_150.png)
An advanced API client for python botters. This project is in Japanese.
## ๐ Description
`pybotters` is a Python library for [ไปฎๆณ้่ฒจ botter (crypto bot traders)](https://medium.com/perpdex/botter-the-crypto-bot-trader-in-japan-2f5f2a65856f).
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`](https://docs.aiohttp.org/).
- โจ 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`](https://docs.python.org/ja/3/library/asyncio.html).
- Discord community.
## ๐ฆ Exchanges
| Name | API auth | DataStore | Exchange API docs |
| --- | --- | --- | --- |
| bitFlyer | โ
| โ
| [Link](https://lightning.bitflyer.com/docs) |
| GMO Coin | โ
| โ
| [Link](https://api.coin.z.com/docs/) |
| bitbank | โ
| โ
| [Link](https://github.com/bitbankinc/bitbank-api-docs) |
| Coincheck | โ
| โ
| [Link](https://coincheck.com/ja/documents/exchange/api) |
| OKJ | โ
| Not yet | [Link](https://dev.okcoin.jp/en/) |
| BitTrade | โ
| Not yet | [Link](https://api-doc.bittrade.co.jp/) |
| Bybit | โ
| โ
| [Link](https://bybit-exchange.github.io/docs/v5/intro) |
| Binance | โ
| โ
| [Link](https://developers.binance.com/docs/binance-spot-api-docs/CHANGELOG) |
| OKX | โ
| โ
| [Link](https://www.okx.com/docs-v5/en/) |
| Phemex | โ
| โ
| [Link](https://phemex-docs.github.io/) |
| Bitget | โ
| โ
| [Link](https://www.bitget.com/api-doc/common/intro) |
| MEXC | โ
| No support | [Link](https://mexcdevelop.github.io/apidocs/spot_v3_en/) |
| KuCoin | โ
| โ
| [Link](https://www.kucoin.com/docs/beginners/introduction) |
| BitMEX | โ
| โ
| [Link](https://www.bitmex.com/app/apiOverview) |
| Hyperliquid | โ
| Partially | [Link](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api) |
## ๐ Requires
Python 3.9+
## ๐ง Installation
From [PyPI](https://pypi.org/project/pybotters/) (stable version):
```sh
pip install pybotters
```
From [GitHub](https://github.com/pybotters/pybotters) (latest version):
```sh
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.
> [!IMPORTANT]
> The roadmap is here: [pybotters/pybotters#248](https://github.com/pybotters/pybotters/issues/248)
## ๐ Usage
Example of bitFlyer API:
### HTTP API
New interface from version 1.0: **Fetch API**.
More simple request/response.
```py
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.
```python
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
```python
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
```py
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!:
[![GitHub Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=181717&&style=flat-square&labelColor=white)](https://github.com/sponsors/MtkN1)
X:
[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/MtkN1XBt)](https://twitter.com/MtkN1XBt)
Discord:
[![Discord Widget](https://discord.com/api/guilds/832651305155297331/widget.png?style=banner3)](https://discord.com/invite/CxuWSX9U69)
Raw data
{
"_id": null,
"home_page": null,
"name": "pybotters",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "aiohttp, crypto, exchange, trading",
"author": null,
"author_email": "MtkN1 <51289448+MtkN1@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/58/99/36215a3fff0e77cc0bd1e144cc3d09a78f65e523f865a067a4346c2ddd4b/pybotters-1.7.1.tar.gz",
"platform": null,
"description": "[\n ![PyPI](https://img.shields.io/pypi/v/pybotters)\n ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pybotters)\n ![PyPI - License](https://img.shields.io/pypi/l/pybotters)\n](https://pypi.org/project/pybotters/)\n[![Downloads](https://static.pepy.tech/badge/pybotters)](https://pepy.tech/project/pybotters)\n\n[![CI](https://github.com/pybotters/pybotters/actions/workflows/ci.yml/badge.svg)](https://github.com/pybotters/pybotters/actions/workflows/ci.yml)\n[![publish](https://github.com/pybotters/pybotters/actions/workflows/publish.yml/badge.svg)](https://github.com/pybotters/pybotters/actions/workflows/publish.yml)\n[![Documentation Status](https://readthedocs.org/projects/pybotters/badge/?version=latest)](https://pybotters.readthedocs.io/ja/latest/?badge=latest)\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n[![GitHub Repo stars](https://img.shields.io/github/stars/pybotters/pybotters?style=social)](https://github.com/pybotters/pybotters/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/pybotters/pybotters?style=social)](https://github.com/pybotters/pybotters/network/members)\n[![Discord](https://img.shields.io/discord/832651305155297331?label=Discord&logo=discord&style=social)](https://discord.com/invite/CxuWSX9U69)\n[![GitHub Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=181717&&style=flat-square&labelColor=white)](https://github.com/sponsors/MtkN1)\n\n\n# pybotters\n\n![pybotters logo](https://raw.githubusercontent.com/pybotters/pybotters/main/docs/logo_150.png)\n\nAn advanced API client for python botters. This project is in Japanese.\n\n## \ud83d\udccc Description\n\n`pybotters` is a Python library for [\u4eee\u60f3\u901a\u8ca8 botter (crypto bot traders)](https://medium.com/perpdex/botter-the-crypto-bot-trader-in-japan-2f5f2a65856f).\n\nThis library is an **HTTP and WebSocket API client**.\nIt has the following features, making it useful for developing a trading bot.\n\n## \ud83d\ude80 Features\n\n- \u2728 HTTP / WebSocket Client\n - **Automatic authentication** for private APIs.\n - WebSocket **automatic reconnection** and **automatic heartbeat**.\n - A client based on [`aiohttp`](https://docs.aiohttp.org/).\n- \u2728 DataStore\n - WebSocket message data handler.\n - **Processing of differential data** such as order book updates\n - **High-speed data processing** and querying\n- \u2728 Other Experiences\n - Support for type hints.\n - Asynchronous programming using [`asyncio`](https://docs.python.org/ja/3/library/asyncio.html).\n - Discord community.\n\n## \ud83c\udfe6 Exchanges\n\n| Name | API auth | DataStore | Exchange API docs |\n| --- | --- | --- | --- |\n| bitFlyer | \u2705 | \u2705 | [Link](https://lightning.bitflyer.com/docs) |\n| GMO Coin | \u2705 | \u2705 | [Link](https://api.coin.z.com/docs/) |\n| bitbank | \u2705 | \u2705 | [Link](https://github.com/bitbankinc/bitbank-api-docs) |\n| Coincheck | \u2705 | \u2705 | [Link](https://coincheck.com/ja/documents/exchange/api) |\n| OKJ | \u2705 | Not yet | [Link](https://dev.okcoin.jp/en/) |\n| BitTrade | \u2705 | Not yet | [Link](https://api-doc.bittrade.co.jp/) |\n| Bybit | \u2705 | \u2705 | [Link](https://bybit-exchange.github.io/docs/v5/intro) |\n| Binance | \u2705 | \u2705 | [Link](https://developers.binance.com/docs/binance-spot-api-docs/CHANGELOG) |\n| OKX | \u2705 | \u2705 | [Link](https://www.okx.com/docs-v5/en/) |\n| Phemex | \u2705 | \u2705 | [Link](https://phemex-docs.github.io/) |\n| Bitget | \u2705 | \u2705 | [Link](https://www.bitget.com/api-doc/common/intro) |\n| MEXC | \u2705 | No support | [Link](https://mexcdevelop.github.io/apidocs/spot_v3_en/) |\n| KuCoin | \u2705 | \u2705 | [Link](https://www.kucoin.com/docs/beginners/introduction) |\n| BitMEX | \u2705 | \u2705 | [Link](https://www.bitmex.com/app/apiOverview) |\n| Hyperliquid | \u2705 | Partially | [Link](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api) |\n\n## \ud83d\udc0d Requires\n\nPython 3.9+\n\n## \ud83d\udd27 Installation\n\nFrom [PyPI](https://pypi.org/project/pybotters/) (stable version):\n\n```sh\npip install pybotters\n```\n\nFrom [GitHub](https://github.com/pybotters/pybotters) (latest version):\n\n```sh\npip install git+https://github.com/pybotters/pybotters.git\n```\n\n## \u26a0\ufe0f Compatibility warning\n\npybotters 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.\n\n> [!IMPORTANT]\n> The roadmap is here: [pybotters/pybotters#248](https://github.com/pybotters/pybotters/issues/248)\n\n\n## \ud83d\udcdd Usage\n\nExample of bitFlyer API:\n\n### HTTP API\n\nNew interface from version 1.0: **Fetch API**.\n\nMore simple request/response.\n\n```py\nimport asyncio\n\nimport pybotters\n\napis = {\n \"bitflyer\": [\"YOUER_BITFLYER_API_KEY\", \"YOUER_BITFLYER_API_SECRET\"],\n}\n\n\nasync def main():\n async with pybotters.Client(\n apis=apis, base_url=\"https://api.bitflyer.com\"\n ) as client:\n # Fetch balance\n r = await client.fetch(\"GET\", \"/v1/me/getbalance\")\n\n print(r.response.status, r.response.reason, r.response.url)\n print(r.data)\n\n # Create order\n CREATE_ORDER = False # Set to `True` if you are trying to create an order.\n if CREATE_ORDER:\n r = await client.fetch(\n \"POST\",\n \"/v1/me/sendchildorder\",\n data={\n \"product_code\": \"BTC_JPY\",\n \"child_order_type\": \"MARKET\",\n \"side\": \"BUY\",\n \"size\": 0.001,\n },\n )\n\n print(r.response.status, r.response.reason, r.response.url)\n print(r.data)\n\n\nasyncio.run(main())\n```\n\naiohttp-based API.\n\n```python\nimport asyncio\n\nimport pybotters\n\napis = {\n \"bitflyer\": [\"YOUER_BITFLYER_API_KEY\", \"YOUER_BITFLYER_API_SECRET\"],\n}\n\n\nasync def main():\n async with pybotters.Client(\n apis=apis, base_url=\"https://api.bitflyer.com\"\n ) as client:\n # Fetch balance\n async with client.get(\"/v1/me/getbalance\") as resp:\n data = await resp.json()\n\n print(resp.status, resp.reason)\n print(data)\n\n # Create order\n CREATE_ORDER = False # Set to `True` if you are trying to create an order.\n if CREATE_ORDER:\n async with client.post(\n \"/v1/me/sendchildorder\",\n data={\n \"product_code\": \"BTC_JPY\",\n \"child_order_type\": \"MARKET\",\n \"side\": \"BUY\",\n \"size\": 0.001,\n },\n ) as resp:\n data = await resp.json()\n\n print(data)\n\n\nasyncio.run(main())\n```\n\n### WebSocket API\n\n```python\nimport asyncio\n\nimport pybotters\n\n\nasync def main():\n async with pybotters.Client() as client:\n # Create a Queue\n wsqueue = pybotters.WebSocketQueue()\n\n # Connect to WebSocket and subscribe to Ticker\n await client.ws_connect(\n \"wss://ws.lightstream.bitflyer.com/json-rpc\",\n send_json={\n \"method\": \"subscribe\",\n \"params\": {\"channel\": \"lightning_ticker_BTC_JPY\"},\n },\n hdlr_json=wsqueue.onmessage,\n )\n\n # Iterate message (Ctrl+C to break)\n async for msg in wsqueue:\n print(msg)\n\n\ntry:\n asyncio.run(main())\nexcept KeyboardInterrupt:\n pass\n```\n\n### DataStore\n\n```py\nimport asyncio\n\nimport pybotters\n\n\nasync def main():\n async with pybotters.Client() as client:\n # Create DataStore\n store = pybotters.bitFlyerDataStore()\n\n # Connect to WebSocket and subscribe to Board\n await client.ws_connect(\n \"wss://ws.lightstream.bitflyer.com/json-rpc\",\n send_json=[\n {\n \"method\": \"subscribe\",\n \"params\": {\"channel\": \"lightning_board_snapshot_BTC_JPY\"},\n },\n {\n \"method\": \"subscribe\",\n \"params\": {\"channel\": \"lightning_board_BTC_JPY\"},\n },\n ],\n hdlr_json=store.onmessage,\n )\n\n # Watch for the best prices on Board. (Ctrl+C to break)\n with store.board.watch() as stream:\n async for change in stream:\n board = store.board.sorted(limit=2)\n print(board)\n\n\ntry:\n asyncio.run(main())\nexcept KeyboardInterrupt:\n pass\n```\n\n## \ud83d\udcd6 Documentation\n\n\ud83d\udd17 https://pybotters.readthedocs.io/ja/stable/ (Japanese)\n\n## \ud83d\uddfd License\n\nMIT\n\n## \ud83d\udc96 Author\n\nPlease sponsor me!:\n\n[![GitHub Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=181717&&style=flat-square&labelColor=white)](https://github.com/sponsors/MtkN1)\n\nX:\n\n[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/MtkN1XBt)](https://twitter.com/MtkN1XBt)\n\nDiscord:\n\n[![Discord Widget](https://discord.com/api/guilds/832651305155297331/widget.png?style=banner3)](https://discord.com/invite/CxuWSX9U69)\n",
"bugtrack_url": null,
"license": null,
"summary": "An advanced API client for python crypto bot traders",
"version": "1.7.1",
"project_urls": {
"Documentation": "https://pybotters.readthedocs.io/ja/stable/",
"Repository": "https://github.com/pybotters/pybotters"
},
"split_keywords": [
"aiohttp",
" crypto",
" exchange",
" trading"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "dbfee06f30fb75565153f4a0cbf0d543c162d70c3eb590e7c7486948134ebae1",
"md5": "f3a619007a38883f6a1cabefb03fea29",
"sha256": "d5509feceb9b5b18e7f230a2afe6bfccf75c901867417d73c79a495a01d2d968"
},
"downloads": -1,
"filename": "pybotters-1.7.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f3a619007a38883f6a1cabefb03fea29",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 512629,
"upload_time": "2025-01-02T15:12:44",
"upload_time_iso_8601": "2025-01-02T15:12:44.972504Z",
"url": "https://files.pythonhosted.org/packages/db/fe/e06f30fb75565153f4a0cbf0d543c162d70c3eb590e7c7486948134ebae1/pybotters-1.7.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "589936215a3fff0e77cc0bd1e144cc3d09a78f65e523f865a067a4346c2ddd4b",
"md5": "2c566aaaa6da2922d8908a60d3f716d1",
"sha256": "3f8dc4f1b7470e9bbd26fb47d78e16045d4dbf82f0e9af68c50d6a1a470a6ec6"
},
"downloads": -1,
"filename": "pybotters-1.7.1.tar.gz",
"has_sig": false,
"md5_digest": "2c566aaaa6da2922d8908a60d3f716d1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 541507,
"upload_time": "2025-01-02T15:12:47",
"upload_time_iso_8601": "2025-01-02T15:12:47.454864Z",
"url": "https://files.pythonhosted.org/packages/58/99/36215a3fff0e77cc0bd1e144cc3d09a78f65e523f865a067a4346c2ddd4b/pybotters-1.7.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-02 15:12:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pybotters",
"github_project": "pybotters",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pybotters"
}