Hummingbot API¶
Repository Update
The backend-api
has been renamed to hummingbot-api
, marking a major revamp of the codebase with improvements in architecture, modularity, and developer experience.
Overview¶
Hummingbot API is a comprehensive RESTful API framework designed for managing trading operations across multiple exchanges. It allows individual traders and teams to deploy custom, private servers for trade execution, portfolio management, and data collection, bot deployment, and other use cases.
GitHub Repository: github.com/hummingbot/hummingbot-api
Key Features¶
- โ๏ธ Standardized and production-ready API for managing bots, executing trades, and monitoring multi-exchange portfolios
- ๐ Expanded capabilities including direct trading, portfolio rebalancing, and account management โ all via API
- ๐ Real-time monitoring of portfolio performance across multiple exchanges
- ๐ฏ Market data collection for real-time and historical price feeds
- ๐ง Comprehensive bot orchestration for managing multiple trading instances
Architecture¶
graph TB
subgraph "Clients"
direction LR
CUSTOM[Custom Apps]
DASH[Hummingbot<br/>Dashboard]
AI[AI Agents]
end
subgraph "Hummingbot API"
direction LR
API["FastAPI<br/>Server<br/>"]
PG[(PostgreSQL<br/>Database)]
MQTT[EMQX<br/>Message Broker]
end
subgraph "Bots"
BOTS[Hummingbot<br/>Instances]
end
subgraph "Exchanges"
EX[Binance, OKX,<br/>Hyperliquid, etc.]
end
%% Client connections using API Client
DASH -->|Hummingbot API Client| API
%% Bot connections
BOTS <-->|Commands & Updates| MQTT
%% Exchange connections
BOTS <-->|Trade & Data| EX
API <-->|Trade & Data| EX
%% Apply theme colors
classDef clientStyle stroke:#5FFFD7,stroke-width:3px
classDef apiStyle stroke:#00B1BB,stroke-width:3px
classDef botsStyle stroke:#E549FF,stroke-width:3px
class DASH clientStyle
class API,PG,MQTT apiStyle
class BOTS botsStyle
Key Components¶
- Server Infrastructure:
- FastAPI server providing RESTful API with HTTP Basic Authentication
- PostgreSQL database for storing trading data, account info, and historical performance
- EMQX message broker for real-time communication with bot instances
- Exchange Connectors: Built-in connectors for major CEXs and DEXs - trading and data fetching is accessible directly through the Hummingbot API or via bots that it deploys
- Bot Instances: Individual Hummingbot containers connected to different exchanges
- Docker Management: Orchestrates multiple Hummingbot container instances
Use Cases¶
The Hummingbot API enables various trading applications:
- Custom OEMS: Build your own trading order execution management system spanning multiple exchanges
- Trading Dashboards: Build custom chat, web, and mobile interfaces for controlling bots
- AI-Powered Trading: Integrate with LLMs for agentic trading workflows
- Risk Management Tools: Build systems for monitoring and managing trading operations
- Market Data Feeds: Create real-time price and historical candles feeds for use with different applications
Getting Started¶
- Installation Guide - Complete installation instructions for Docker and source installation
- Quickstart Guide - Learn how to:
- Add exchange credentials
- View portfolio balances
- Place your first market order
The guides include Docker setup and Python API client examples to get you trading in minutes.
API Routers¶
The Hummingbot API provides the following key routers:
๐ณ Docker Management¶
Manage Docker containers and instances running Hummingbot
GET /docker/running
- Check if Docker daemon is runningGET /docker/available-images
- List available Docker imagesGET /docker/active-containers
- Get all running containersPOST /docker/pull-image
- Pull new Docker imagesPOST /docker/start-container/{name}
- Start a containerPOST /docker/stop-container/{name}
- Stop a containerPOST /docker/remove-container/{name}
- Remove container and archive data
๐ผ Account Management¶
Handle exchange account credentials and configurations
GET /accounts
- List all trading accountsPOST /accounts
- Create new trading accountPUT /accounts/{id}
- Update account credentialsDELETE /accounts/{id}
- Delete trading accountGET /accounts/{id}/balances
- Get account balances
๐ Connector Discovery¶
Discover and manage available exchange connectors
GET /connectors
- List all available connectorsGET /connectors/{name}
- Get connector detailsGET /connectors/{name}/trading-rules
- Get trading rules and limitsGET /connectors/{name}/markets
- List supported trading pairs
๐ Portfolio Management¶
Monitor and analyze portfolio performance across exchanges
GET /portfolio/balances
- Get aggregated portfolio balancesGET /portfolio/performance
- Get portfolio performance metricsGET /portfolio/distribution
- Get token distribution analysisGET /portfolio/history
- Get historical portfolio data
๐ฑ Trading Operations¶
Execute trades, manage orders, and monitor positions
POST /trading/orders
- Place new orderGET /trading/orders
- List active ordersDELETE /trading/orders/{id}
- Cancel orderGET /trading/positions
- Get open positionsGET /trading/history
- Get trade historyPOST /trading/close-position
- Close a position
๐ Strategy Management¶
Configure and deploy trading strategies with real-time updates
GET /controllers
- List available strategy controllersPOST /controllers/{name}/deploy
- Deploy strategy controllerPUT /controllers/{id}/config
- Update strategy parametersGET /scripts
- List available trading scriptsPOST /scripts/run
- Execute trading script
๐ Market Data¶
Access real-time and historical market data
GET /market-data/ticker/{pair}
- Get current ticker dataGET /market-data/orderbook/{pair}
- Get order book snapshotGET /market-data/candles/{pair}
- Get historical candlesGET /market-data/trades/{pair}
- Get recent tradesWS /market-data/stream
- Real-time market data stream
๐ค Bot Orchestration¶
Deploy, configure, and manage multiple bot instances
GET /bot-orchestration/bots
- List all bot instancesPOST /bot-orchestration/deploy
- Deploy new botPUT /bot-orchestration/bots/{id}/config
- Update bot configurationPOST /bot-orchestration/bots/{id}/start
- Start botPOST /bot-orchestration/bots/{id}/stop
- Stop botGET /bot-orchestration/bots/{id}/status
- Get bot status
๐งช Backtesting¶
Run strategy backtests with historical data
POST /backtesting/run
- Start new backtestGET /backtesting/results/{id}
- Get backtest resultsGET /backtesting/metrics/{id}
- Get performance metricsPOST /backtesting/optimize
- Run parameter optimization
Authentication¶
The API uses HTTP Basic Authentication:
- Configure username and password during setup
- Include credentials in the Authorization header for all requests
- Example:
Authorization: Basic <base64-encoded-credentials>
API Client¶
A modern, asynchronous Python client is available for interacting with the Hummingbot API. This client is used by the Hummingbot Dashboard as the interface layer for all API communications.
- GitHub: hummingbot-api-client
- PyPI: pypi.org/project/hummingbot-api-client
Installation¶
Usage Example¶
from hummingbot_api_client import HummingbotAPIClient
# Initialize client
client = HummingbotAPIClient(
base_url="http://localhost:8000",
username="your-username",
password="your-password"
)
# Get portfolio data
portfolio = await client.get_portfolio()
# Execute a trade
order = await client.create_order(
connector="binance",
trading_pair="BTC-USDT",
order_type="limit",
side="buy",
amount=0.001,
price=50000
)
Related Resources¶
- Hummingbot Dashboard - Web-based interface built on top of Hummingbot API
- API Client Documentation - Python client library
- Hummingbot Client - Core trading engine