The Gunbot Python SDK is a newly released wrapper for the Gunbot REST API. It offers a practical way to write Python scripts that automate trading tasks like placing orders, managing strategies, pulling balances - without having to deal directly with raw HTTP requests.
Whether you're scripting quick tasks or building out more structured bots, this SDK saves time and removes friction from common interactions with the Gunbot backend.
TL;DRβ
- Simplifies working with the Gunbot API in Python
- Lets you send trades, check balances, manage config, analyze market data, etc
- No need to handle auth headers or raw requests manually
- Available now as package on PyPI and source code on GitHub
Why This SDK Existsβ
Using the Gunbot REST API directly in Python usually means building every request by hand. That includes forming URLs, setting headers, serializing payloads, and checking for response errors manually. It's tedious and error-prone.
This SDK takes care of the low-level plumbing so you can focus on writing your trading logic.
Without SDK | With gunbot-sdk-python |
---|---|
Manual URL building | Use named methods like config_pair_add() |
Custom headers/auth | Handled automatically |
JSON serialization | Done behind the scenes |
Error handling? | Still on you, but cleaner |
Install in One Stepβ
pip install gunbot-sdk-python
Itβs a lightweight package published to PyPI, with minimal external dependencies.
Setup Exampleβ
from gunbot_sdk_python import ApiClient, GunbotApi
client = ApiClient(
base_path="http://<your-gunbot-host>:3000/api/v1",
token="<your-api-token>"
)
api = GunbotApi(client)
Thatβs enough to start making requests against your running Gunbot instance.
Common Use Casesβ
Total Portfolio Valueβ
result = api.assets_total(body={
"exchange": "binance",
"base": "USDT",
"start": 1719350400000,
"end": 1719436800000
})
print(f"Total USDT: {result['data']['total']}")
Add a Trading Pair to Strategy Configβ
api.config_pair_add(body={
"exchange": "binance",
"pair": "USDT-ETH",
"settings": {}
})
You provide Python dictionaries as input, and the SDK handles formatting and sending the request.
Where It Fitsβ
This SDK is useful in various Python environments:
- CLI scripts: Automate trading tasks or daily reports
- Jupyter notebooks: For testing signals or visualizing asset data
- FastAPI/Flask apps: Build basic web dashboards or control panels
- Airflow or cron jobs: Schedule config updates or balance pulls
- Serverless functions: Trigger alerts or simple trades with minimal code
Thereβs no framework lock-in. The SDK is straightforward to integrate wherever plain Python runs.
Open Source & Contributionsβ
The SDK is licensed under MIT and source code is available on GitHub:
Pull requests, issues and suggestions are welcome.
A Quick Reminder on Securityβ
When automating anything related to real funds:
- Donβt hardcode tokens in scripts
- Use secure environments or secrets managers
- Avoid exposing your Gunbot instance publicly
- Prefer HTTPS whenever not using Gunbot on localhost
What Is Gunbot?β
Gunbot is a self hosted bot for trading automation that connects to major centralized and decentralized exchanges. It supports a range of built-in strategies (grid, DCA, scalping, etc) and includes a full REST API for users who want deeper control or custom workflows.
The Python SDK is just one way to extend Gunbot with your own code.
Getting Startedβ
To recap:
- Install the SDK:
pip install gunbot-sdk-python
- Connect to your Gunbot instance
- Authenticate using your API token
- Call API methods using simple Python
Resources: