
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: