### Install Jupyter Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Install Jupyter Notebook or JupyterLab to run example notebooks. These notebooks provide interactive tutorials for using the Hummingbot API client. ```bash pip install jupyter notebook ``` ```bash # or pip install jupyterlab ``` -------------------------------- ### Example Workflow: Quote and Execute Swap Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Demonstrates a complete workflow for executing a token swap. It first gets a price quote, checks if the price is acceptable against a maximum price, and then, if acceptable, proceeds to execute the swap. The execution step is commented out by default. ```python # 1. Get quote print("Step 1: Getting quote...") quote = await client.gateway_swap.get_swap_quote( connector='jupiter', network='solana-mainnet-beta', trading_pair='SOL-USDC', side='BUY', amount=Decimal('1'), slippage_pct=Decimal('1.0') ) print(f"Quote received:") print(f" Price: ${quote['price']}") print(f" You will pay: {quote['amount_in']} USDC") print(f" You will receive: {quote['amount_out']} SOL") # 2. Check if price is acceptable max_price = Decimal('200') # Maximum price you're willing to pay quote_price = Decimal(str(quote['price'])) print(f"\nStep 2: Checking price...") if quote_price <= max_price: print(f"✅ Price ${quote_price} is acceptable (max: ${max_price})") print("\nStep 3: Ready to execute swap (uncomment below to execute)") # 3. Execute swap (uncomment to run) # result = await client.gateway_swap.execute_swap( # connector='jupiter', # network='solana-mainnet-beta', # trading_pair='SOL-USDC', # side='BUY', # amount=Decimal('1'), # slippage_pct=Decimal('1.0') # ) # print(f"\n✅ Swap executed!") # print(f"Transaction: {result['transaction_hash']}") else: print(f"❌ Price ${quote_price} is too high (max: ${max_price})") print("Swap cancelled") ``` -------------------------------- ### Install hummingbot-api-client Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Install the library using pip. This is the first step to using the client. ```bash pip install hummingbot-api-client ``` -------------------------------- ### Complete CLMM Position Workflow Example Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_clmm_example.ipynb Demonstrates a full workflow for managing a CLMM position, including getting pool info, calculating price ranges, and placeholders for opening, monitoring, and adjusting positions. Requires uncommenting and providing pool and token details. ```python # 1. Get pool info and check current price print("Step 1: Checking pool information...") pool_info = await client.gateway_clmm.get_pool_info( connector='meteora', network='solana-mainnet-beta', pool_address=pool_address ) current_price = Decimal(str(pool_info['current_price'])) print(f"Current Price: {current_price}") # 2. Calculate price range (±10% from current) print("\nStep 2: Calculating price range...") lower_price = current_price * Decimal('0.9') # -10% upper_price = current_price * Decimal('1.1') # +10% print(f"Price Range: {lower_price} - {upper_price}") # 3. Open position (uncomment to execute) print("\nStep 3: Ready to open position (uncomment to execute)") # result = await client.gateway_clmm.open_position( # connector='meteora', # network='solana-mainnet-beta', # pool_address=pool_address, # lower_price=lower_price, # upper_price=upper_price, # base_token_amount=Decimal('0.1'), # quote_token_amount=Decimal('10'), # slippage_pct=Decimal('1.0'), # extra_params={"strategyType": 0} # ) # # position_address = result['position_address'] # print(f"\n✅ Position opened!") # print(f"Position Address: {position_address}") # print(f"Transaction: {result['transaction_hash']}") # 4. Monitor position print("\nStep 4: Monitor position status with search_positions()") # 5. Collect fees periodically print("Step 5: Collect fees periodically with collect_fees()") # 6. Adjust or close when needed print("Step 6: Adjust liquidity or close position when needed") ``` -------------------------------- ### Build and Install Hummingbot Package Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Commands to install build dependencies, build the Hummingbot package, and install it in development mode using pip and build tools. ```bash # Install build dependencies uv pip install build # Build the package python -m build # Install in development mode pip install -e . ``` -------------------------------- ### Get Swap Quote on Ethereum using 0x Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Example of how to get a swap quote on the Ethereum network using the 0x DEX connector. This is commented out by default. ```python # Example: Get quote on Ethereum using 0x # quote_eth = await client.gateway_swap.get_swap_quote( # connector='0x', # network='ethereum-mainnet', # trading_pair='ETH-USDC', # side='BUY', # amount=Decimal('1'), # slippage_pct=Decimal('1.0') # ) # quote_eth ``` -------------------------------- ### Start Gateway Container Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Starts the Gateway Docker container with specified configuration. Ensure the 'image', 'port', and 'passphrase' are correctly set for your environment. ```python # Start Gateway container (configure as needed) config = { "image": "hummingbot/gateway:latest", "port": 15888, "passphrase": "a", "environment": {} } result = await client.gateway.start(config) result ``` -------------------------------- ### Container Management Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Manage the Gateway Docker container, including getting its status, starting, stopping, and retrieving logs. ```APIDOC ## Get Gateway Container Status ### Description Retrieves the current status of the Gateway container. ### Method GET ### Endpoint /gateway/status ### Response #### Success Response (200) - **running** (boolean) - Indicates if the container is running. - **container_id** (string) - The ID of the container. - **image** (string) - The Docker image used for the container. - **created_at** (string) - The timestamp when the container was created. - **port** (integer) - The port the container is exposed on. ### Response Example ```json { "running": true, "container_id": "aa479985457937dfa73d0a527e9b16ae87382152adc864971089ab3afb9c993e", "image": "hummingbot/gateway:latest", "created_at": "2025-10-17T14:16:20.740872044Z", "port": 15888 } ``` ``` ```APIDOC ## Start Gateway Container ### Description Starts the Gateway container with the specified configuration. ### Method POST ### Endpoint /gateway/start ### Parameters #### Request Body - **config** (object) - Required - Configuration for starting the Gateway container. - **image** (string) - Required - The Docker image to use. - **port** (integer) - Required - The port to expose the container on. - **passphrase** (string) - Required - The passphrase for the Gateway. - **environment** (object) - Optional - Environment variables for the container. ### Request Example ```json { "config": { "image": "hummingbot/gateway:latest", "port": 15888, "passphrase": "a", "environment": {} } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **message** (string) - A message describing the result. - **container_id** (string) - The ID of the started container. - **port** (integer) - The port the container is running on. ### Response Example ```json { "success": true, "message": "Gateway started successfully", "container_id": "dc3041ce9b0e5bb55081d047b41a178d15745b9ff683d120ddcc285ebb9f8d98", "port": 15888 } ``` ``` ```APIDOC ## Get Gateway Logs ### Description Retrieves the logs from the Gateway container. ### Method GET ### Endpoint /gateway/logs ### Parameters #### Query Parameters - **tail** (integer) - Optional - The number of lines to return from the end of the logs. ### Response #### Success Response (200) - **logs** (string) - The log output from the Gateway container. ### Response Example ```json { "logs": "2025-10-17T14:37:51.939461836Z \"error\": {}, 2025-10-17T14:37:51.939477003Z \"rejection\": true, ... } ``` ``` ```APIDOC ## Stop Gateway Container ### Description Stops the running Gateway container. ### Method POST ### Endpoint /gateway/stop ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **message** (string) - A message describing the result. ### Response Example ```json { "success": true, "message": "Gateway stopped successfully" } ``` ``` -------------------------------- ### Get All Network Tokens Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Fetches all available tokens for a specified network. Use this to get a comprehensive list of tokens supported on a blockchain. ```python tokens = await client.gateway.get_network_tokens('solana-mainnet-beta') tokens ``` -------------------------------- ### Get Positions Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Retrieves all open positions across all accounts and connectors. ```APIDOC ## Get Positions ### Description Retrieves all open positions across all accounts and connectors. ### Method `client.trading.get_positions` ``` -------------------------------- ### Get Controller Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Retrieves details for a specific controller. ```APIDOC ## Get Controller ### Description Retrieves details about a specific controller, identified by its type and name. ### Method GET ### Endpoint /controllers/{controller_type}/{controller_name} ### Parameters #### Path Parameters - **controller_type** (string) - Required - The type of the controller (e.g., "generic"). - **controller_name** (string) - Required - The name of the controller (e.g., "grid_strike"). ### Response #### Success Response (200) - **controller_details** (dict) - Details of the specified controller. ``` -------------------------------- ### Get Controller Configuration Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Retrieves a specific controller configuration by name. ```APIDOC ## Get Controller Configuration ### Description Retrieves the configuration for a specific controller identified by its name. ### Method GET ### Endpoint /controllers/configs/{config_name} ### Parameters #### Path Parameters - **config_name** (string) - Required - The name of the controller configuration to retrieve. ### Response #### Success Response (200) - **config** (dict) - The configuration details for the specified controller. ``` -------------------------------- ### Get network configuration Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Fetches the configuration settings for a specific blockchain network. ```APIDOC ## Get Network Configuration ### Description Retrieves the configuration details for a specified blockchain network. ### Method GET ### Endpoint /gateway/networks/{network_id}/config ### Parameters #### Path Parameters - **network_id** (string) - Required - The unique identifier of the network (format: 'chain-network', e.g., 'solana-mainnet-beta'). ### Response #### Success Response (200) - **(object)** - An object containing the network's configuration parameters. Example fields may include `node_url`, `native_currency_symbol`, `default_compute_units`, etc. ### Response Example ```json { "node_url": "https://mainnet.helius-rpc.com/?api-key=a43dcfb5-df0c-45e6-b3d8-6091d0d846dd", "native_currency_symbol": "SOL", "default_compute_units": 250000, "confirm_retry_interval": 0.5, "confirm_retry_count": 15, "base_priority_fee_pct": 90, "min_priority_fee_per_cu": 0.1 } ``` ``` -------------------------------- ### Get connector configuration Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Fetches the current configuration settings for a specific DEX connector. ```APIDOC ## Get Connector Configuration ### Description Retrieves the configuration for a specified DEX connector. ### Method GET ### Endpoint /gateway/connectors/{connector_name}/config ### Parameters #### Path Parameters - **connector_name** (string) - Required - The name of the connector to retrieve configuration for. ### Response #### Success Response (200) - **(object)** - An object containing the configuration parameters for the connector. Example fields may include `slippage_pct` and `strategy_type`. ### Response Example ```json { "slippage_pct": 1, "strategy_type": 0 } ``` ``` -------------------------------- ### Quick Start Hummingbot API Client Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Demonstrates basic usage of the Hummingbot API client, including connecting, fetching portfolio data, listing connectors, and checking Docker status. Uses the recommended context manager for client management. ```python import asyncio from hummingbot_api_client import HummingbotAPIClient async def main(): # Using context manager (recommended) async with HummingbotAPIClient("http://localhost:8000", "admin", "admin") as client: # Get portfolio state portfolio = await client.portfolio.get_state() print(f"Portfolio value: ${sum(b['value'] for a in portfolio.values() for c in a.values() for b in c):.2f}") # List available connectors connectors = await client.connectors.list_connectors() print(f"Available connectors: {len(connectors)}") # Check Docker status docker_status = await client.docker.is_running() print(f"Docker running: {docker_status['is_docker_running']}") asyncio.run(main()) ``` -------------------------------- ### Get Portfolio State Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Retrieves the current state of the portfolio. ```APIDOC ## Get Portfolio State ### Description Retrieves the current state of the portfolio. ### Method GET (assumed, based on client method name) ### Endpoint /portfolio/state ### Parameters None ### Request Example ```python await client.portfolio.get_state() ``` ### Response #### Success Response (200) - **data** (object) - Portfolio state details ``` -------------------------------- ### Get Database Controllers Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Fetches controller data from a specific archived bot database. ```APIDOC ## get_database_controllers ### Description Fetches controller data from a specific archived bot database. ### Method `client.archived_bots.get_database_controllers(database_id)` ### Parameters #### Path Parameters - **database_id** (str) - Required - The identifier of the database to retrieve controllers from. ``` -------------------------------- ### Get Prices Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Retrieves the current prices for a list of trading pairs. ```APIDOC ## GET /market_data/prices ### Description Retrieves the current market prices for a list of specified trading pairs from a given connector. ### Method GET ### Endpoint /market_data/prices ### Parameters #### Query Parameters - **connector** (string) - Required - The name of the exchange connector. - **trading_pairs** (list of strings) - Required - A list of trading pairs (e.g., ['BTC-USDT', 'ETH-USDT']). ### Response #### Success Response (200) - **...** (object) - A dictionary containing the current prices for each requested trading pair. ``` -------------------------------- ### Get Swap Summary for Solana Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Fetches and prints a summary of all swaps on the Solana network. Includes total swaps, volume, success rate, and average trade size. Optionally displays total fees if available. ```python summary = await client.gateway_swap.get_swaps_summary( network='solana-mainnet-beta' ) print(f"Swap Summary for Solana:") print(f" Total Swaps: {summary.get('total_swaps', 0)}") print(f" Total Volume: ${summary.get('total_volume', 0):.2f}") print(f" Success Rate: {summary.get('success_rate', 0):.1f}%") print(f" Average Trade Size: ${summary.get('avg_trade_size', 0):.2f}") if 'total_fees' in summary: print(f" Total Fees: ${summary['total_fees']:.2f}") ``` -------------------------------- ### Get Open Positions Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Retrieve a list of all currently open positions across your accounts and connectors. Useful for monitoring active trades. ```python await client.trading.get_positions() ``` -------------------------------- ### Get Portfolio Distribution Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Retrieves the distribution of assets within the portfolio. ```APIDOC ## Get Portfolio Distribution ### Description Retrieves the distribution of assets within the portfolio. ### Method GET (assumed, based on client method name) ### Endpoint /portfolio/distribution ### Parameters None ### Request Example ```python await client.portfolio.get_distribution() ``` ### Response #### Success Response (200) - **data** (object) - Portfolio asset distribution details ``` -------------------------------- ### Get Configuration for a Specific DEX Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Fetches the current configuration parameters for a specified DEX connector, such as 'meteora'. Use this to inspect current settings before making changes. ```python # Get configuration for a specific connector (e.g., Meteora) config = await client.gateway.get_connector_config('meteora') config ``` -------------------------------- ### Get Swap Summary for a Specific Wallet Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Fetches swap statistics for a specific wallet address on the Solana network. This is commented out by default and requires a wallet address to be provided. ```python # Get summary for a specific wallet # wallet_summary = await client.gateway_swap.get_swaps_summary( # wallet_address='YOUR_WALLET_ADDRESS', # network='solana-mainnet-beta' # ) # # print(f"Your Trading Stats:") # print(f" Total Trades: {wallet_summary['total_swaps']}") # print(f" Volume: ${wallet_summary['total_volume']:.2f}") # print(f" Success Rate: {wallet_summary['success_rate']:.1f}%") ``` -------------------------------- ### Get Accounts Distribution Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Retrieves the distribution of assets across all accounts. ```APIDOC ## Get Accounts Distribution ### Description Retrieves the distribution of assets across all accounts. ### Method GET (assumed, based on client method name) ### Endpoint /portfolio/accounts_distribution ### Parameters None ### Request Example ```python await client.portfolio.get_accounts_distribution() ``` ### Response #### Success Response (200) - **data** (object) - Distribution of assets across all accounts ``` -------------------------------- ### Get Available Hummingbot Docker Images Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/docker_example.ipynb Retrieve a list of available Docker images for Hummingbot. You can filter by image name. ```python await client.docker.get_available_images(image_name="hummingbot") ``` -------------------------------- ### Get Funding Info Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Retrieves funding rate information for a perpetual futures trading pair. ```APIDOC ## GET /market_data/funding_info ### Description Retrieves the current funding rate information for a specified perpetual futures trading pair. ### Method GET ### Endpoint /market_data/funding_info ### Parameters #### Query Parameters - **connector** (string) - Required - The name of the exchange connector (e.g., 'binance_perpetual'). - **trading_pair** (string) - Required - The trading pair (e.g., 'BTC-USDT'). ### Response #### Success Response (200) - **...** (object) - Funding rate information for the specified trading pair. ``` -------------------------------- ### Get Gateway Container Logs Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Fetches the logs from the Gateway container. The 'tail' parameter limits the number of log lines returned, useful for debugging. ```python # Get Gateway logs (last 50 lines) logs = await client.gateway.get_logs(tail=50) print(logs.get('logs', '')) ``` -------------------------------- ### Get Database Performance Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Retrieves performance metrics for a specified archived bot database. ```APIDOC ## get_database_performance ### Description Retrieves performance metrics for a specified archived bot database. ### Method `client.archived_bots.get_database_performance(database_id)` ### Parameters #### Path Parameters - **database_id** (str) - Required - The identifier of the database to get performance metrics for. ``` -------------------------------- ### Get Swap Quote (Sell) Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Retrieves a price quote for selling a specified amount of a base asset for a quote asset. ```python # Get quote for selling 1 SOL for USDC quote_sell = await client.gateway_swap.get_swap_quote( connector='jupiter', network='solana-mainnet-beta', trading_pair='SOL-USDC', side='SELL', amount=Decimal('1'), slippage_pct=Decimal('1.0') ) print(f"Selling 1 SOL:") print(f"You will receive: ~{quote_sell['amount_out']} USDC") print(f"Price: ${quote_sell['price']} per SOL") ``` -------------------------------- ### Get Database Orders Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Retrieves order data from a specific archived bot database. ```APIDOC ## get_database_orders ### Description Retrieves order data from a specific archived bot database. ### Method `client.archived_bots.get_database_orders(database_id)` ### Parameters #### Path Parameters - **database_id** (str) - Required - The identifier of the database to retrieve orders from. ``` -------------------------------- ### Get Database Positions Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Retrieves position data from a specific archived bot database. ```APIDOC ## get_database_positions ### Description Retrieves position data from a specific archived bot database. ### Method `client.archived_bots.get_database_positions(database_id)` ### Parameters #### Path Parameters - **database_id** (str) - Required - The identifier of the database to retrieve positions from. ``` -------------------------------- ### Get Portfolio Distribution Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Obtain the distribution details of the portfolio. This provides insights into how assets are allocated. ```python await client.portfolio.get_distribution() ``` -------------------------------- ### Get active Docker containers Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/docker_example.ipynb Lists all currently active (running) Docker containers. ```APIDOC ## get_active_containers ### Description Retrieves a list of all currently running Docker containers managed by Hummingbot. ### Method `client.docker.get_active_containers()` ### Parameters None ### Response Example ```json [ { "id": "...", "name": "hummingbot_container_1", "image": "hummingbot:latest", "status": "running" } ] ``` ``` -------------------------------- ### Get Specific Controller Configuration Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Retrieves the configuration details for a controller identified by its name. The returned configuration can be modified and reapplied. ```python config = await client.controllers.get_controller_config("sol_tole") print(config) ``` -------------------------------- ### Get Portfolio State Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Retrieves the current state of the portfolio for specified accounts and connectors. ```APIDOC ## Get Portfolio State ### Description Retrieves the current state of the portfolio for specified accounts and connectors. ### Method `client.portfolio.get_state` ### Parameters #### Query Parameters - **account_names** (list[str]) - Required - List of account names to query. - **connector_names** (list[str]) - Required - List of connector names to query. ``` -------------------------------- ### Get Portfolio State Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Retrieve the current state of the portfolio. This is useful for a quick overview of the portfolio's status. ```python await client.portfolio.get_state() ``` -------------------------------- ### Get Specific Controller Details Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Retrieves detailed information about a specific controller, identified by its type and name. ```python await client.controllers.get_controller(controller_type="generic", controller_name="grid_strike") ``` -------------------------------- ### Get Trading Rules for a Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Fetches the trading rules and limitations for a specific exchange connector. ```APIDOC ## Get Trading Rules ### Description Retrieves the trading rules and limitations for a specified exchange connector. ### Method `GET` ### Endpoint `/connectors/{connector_name}/trading_rules` ### Parameters #### Path Parameters - **connector_name** (string) - Required - The name of the exchange connector (e.g., "binance"). ### Response #### Success Response (200) - **trading_rules** (object) - An object containing various trading rule details such as minimum order sizes, price precision, etc. ### Response Example ```json { "trading_rules": { "min_order_size": { "BTC-USDT": "0.0001" }, "price_precision": { "BTC-USDT": "2" } } } ``` ``` -------------------------------- ### Get Swap Quote for Custom Tokens Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Obtains a price quote for swapping custom tokens, such as BONK, against stablecoins like USDC. Ensure the custom token is added to the gateway first. ```python # Get quote for buying custom token with USDC # Note: Make sure you added the token first using the gateway router quote_custom = await client.gateway_swap.get_swap_quote( connector='jupiter', network='solana-mainnet-beta', trading_pair='BONK-USDC', side='BUY', amount=Decimal('1000000'), # Buy 1M BONK slippage_pct=Decimal('2.0') # 2% slippage for smaller tokens ) print(f"Buying 1M BONK:") print(f"You will pay: ~{quote_custom['amount_in']} USDC") print(f"Price: ${quote_custom['price']} per BONK") ``` -------------------------------- ### Get Funding Information Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Fetches funding rate information for a perpetual futures trading pair. Requires specifying the connector and trading pair. ```python await client.market_data.get_funding_info( connector="binance_perpetual", trading_pair="BTC-USDT", ) ``` -------------------------------- ### Get Trading Rules for a Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Fetch the trading rules for a specific exchange connector. This includes information like minimum order sizes, price precision, and other exchange-specific constraints. ```python await client.connectors.get_trading_rules("binance") ``` -------------------------------- ### Get available Docker images Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/docker_example.ipynb Retrieves a list of available Docker images, optionally filtered by name. ```APIDOC ## get_available_images ### Description Fetches a list of Docker images available on the system. You can filter by image name. ### Method `client.docker.get_available_images(image_name: str = None)` ### Parameters #### Query Parameters - **image_name** (string) - Optional - The name of the image to filter by. ### Response Example ```json [ { "id": "sha256:...". "tags": ["hummingbot:latest"] } ] ``` ``` -------------------------------- ### Get Prices for Multiple Trading Pairs Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Fetches the current prices for a list of specified trading pairs from a connector. Efficient for checking multiple assets simultaneously. ```python await client.market_data.get_prices(connector="binance_perpetual", trading_pairs=["BTC-USDT", "ETH-USDT", "SOL-USDT"]) ``` -------------------------------- ### Get Supported Order Types for a Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Fetches the types of orders supported by a specific exchange connector. ```APIDOC ## Get Supported Order Types ### Description Retrieves a list of order types that are supported by the specified exchange connector. ### Method `GET` ### Endpoint `/connectors/{connector_name}/order_types` ### Parameters #### Path Parameters - **connector_name** (string) - Required - The name of the exchange connector (e.g., "binance"). ### Response #### Success Response (200) - **order_types** (list) - A list of strings, where each string represents a supported order type (e.g., "LIMIT", "MARKET"). ### Response Example ```json { "order_types": [ "LIMIT", "MARKET", "STOP_LOSS", "TAKE_PROFIT" ] } ``` ``` -------------------------------- ### Get Position Mode Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Query the current position mode for a given account and connector. Verifies the active trading strategy. ```python await client.trading.get_position_mode(account_name="master_account", connector_name="binance_perpetual") ``` -------------------------------- ### Get Network Configuration Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Retrieves the configuration details for a specific blockchain network, identified by a 'chain-network' format (e.g., 'solana-mainnet-beta'). Includes details like RPC endpoint and fee parameters. ```python # Get network configuration (format: chain-network) config = await client.gateway.get_network_config('solana-mainnet-beta') config ``` -------------------------------- ### Get Active Hummingbot Docker Containers Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/docker_example.ipynb List all currently running Hummingbot Docker containers. This helps in managing active instances. ```python await client.docker.get_active_containers() ``` -------------------------------- ### Get Configuration Map for a Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Retrieves the configuration map for a specific exchange connector, detailing all settable parameters. ```APIDOC ## Get Config Map ### Description Retrieves the configuration map for a specified exchange connector, outlining all available parameters and their types. ### Method `GET` ### Endpoint `/connectors/{connector_name}/config_map` ### Parameters #### Path Parameters - **connector_name** (string) - Required - The name of the exchange connector (e.g., "binance"). ### Response #### Success Response (200) - **config_map** (object) - An object detailing the configuration parameters for the connector, including their types, default values, and descriptions. ### Response Example ```json { "config_map": { "api_key": { "type": "str", "required": true, "description": "Your API key." }, "api_secret": { "type": "str", "required": true, "description": "Your API secret." } } } ``` ``` -------------------------------- ### Get Accounts Distribution Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Retrieve the distribution across all accounts within the portfolio. This offers a consolidated view of asset allocation. ```python await client.portfolio.get_accounts_distribution() ``` -------------------------------- ### Get Historical Candles with Time Range Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Fetches historical candle data within a specific start and end time. Requires datetime objects converted to timestamps. ```python import datetime await client.market_data.get_historical_candles( connector="binance_perpetual", trading_pair="BTC-USDT", interval="1m", start_time=datetime.datetime(2024, 6, 1).timestamp(), end_time=datetime.datetime(2024, 8, 1).timestamp(), ) ``` -------------------------------- ### Controllers Router Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Manage V2 strategy controllers, including listing types, creating/updating/deleting controllers, managing configurations, and getting templates. ```APIDOC ## Controllers Router (`client.controllers`) ### Description Manage V2 strategy controllers. ### Methods - `list_controllers()` - List all controllers by type - `get_controller(type, name)` - Get controller content - `create_or_update_controller(type, name, data)` - Create/update controller - `list_controller_configs()` - List all configurations - `get_bot_controller_configs(bot)` - Get bot's controller configs ``` -------------------------------- ### Docker Router Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Manage Hummingbot Docker instances, including checking status, listing, starting, stopping, and removing containers, as well as pulling Docker images. ```APIDOC ## Docker Router (`client.docker`) Container and image management for Hummingbot Docker instances. ### Key features: - Check Docker daemon status - List/start/stop/remove containers - Pull Docker images with progress monitoring - Clean up exited containers - Filter containers by name ### Common methods: - `is_running()` - Check if Docker is running - `get_active_containers()` - List all running containers - `start_container(name)` - Start a stopped container - `stop_container(name)` - Stop a running container - `pull_image(name, tag)` - Pull a Docker image ``` -------------------------------- ### Get Portfolio State Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Retrieve the current state of your portfolio for specified accounts and connectors. Useful for checking balances and holdings. ```python await client.portfolio.get_state(account_names=["master_account"], connector_names=["binance_perpetual"]) ``` -------------------------------- ### Get Order Book Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Retrieves the current order book for a given trading pair. Shows bid and ask prices and volumes. ```python await client.market_data.get_order_book(connector="binance_perpetual", trading_pair="BTC-USDT") ``` -------------------------------- ### Get Supported Order Types for a Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Determine the order types supported by a specific exchange connector. This helps in understanding which order strategies can be employed with the connector. ```python await client.connectors.get_supported_order_types("binance") ``` -------------------------------- ### List Controller Configurations Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Retrieves all controller configurations. ```APIDOC ## List Controller Configurations ### Description Retrieves all stored configurations for controllers. ### Method GET ### Endpoint /controllers/configs ### Response #### Success Response (200) - **configs** (dict) - A dictionary where keys are configuration names and values are controller configurations. ``` -------------------------------- ### Get Configuration Map for a Connector Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Obtain the configuration map for a given exchange connector. This details all configurable parameters for the connector, including their types and default values. ```python await client.connectors.get_config_map("binance") ``` -------------------------------- ### Initialize Hummingbot API Client Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/bot_orchestration_example.ipynb Instantiate and initialize the Hummingbot API client. Ensure the Hummingbot API is running at the specified base URL. ```python from hummingbot_api_client import HummingbotAPIClient client = HummingbotAPIClient(base_url='http://localhost:8000') await client.init() ``` -------------------------------- ### Get Portfolio History Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Fetch the historical data for a specific account. You can filter by account names to get targeted history. ```python await client.portfolio.get_history(account_names=["master_account"]) ``` -------------------------------- ### Get Archived Bot Database Performance Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Retrieves performance metrics for a specified archived bot database. This helps in analyzing bot efficiency. ```python await client.archived_bots.get_database_performance(dbs[1]) ``` -------------------------------- ### Search Open Positions on Solana Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_clmm_example.ipynb Fetches all open CLMM positions on the Solana network for a specific connector. Use 'refresh=True' to get the latest data from the Gateway. ```python positions = await client.gateway_clmm.search_positions( network='solana-mainnet-beta', connector='meteora', status='OPEN', limit=10, refresh=True # Refresh data from Gateway ) print(f"Found {len(positions['data'])} open positions\n") for pos in positions['data']: print(f"Position: {pos['position_address'][:16]}...") print(f" Pool: {pos['trading_pair']}") print(f" Range: {pos['lower_price']} - {pos['upper_price']}") print(f" In Range: {pos['in_range']}") print(f" Base: {pos['base_token_amount']}") print(f" Quote: {pos['quote_token_amount']}") print() ``` -------------------------------- ### List All Controller Configurations Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Fetches a list of all saved controller configurations. This is useful for an overview before managing specific configurations. ```python await client.controllers.list_controller_configs() ``` -------------------------------- ### Get Active Market Data Feeds Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Retrieves a list of all currently active market data feeds. Useful for checking what data is available. ```python await client.market_data.get_active_feeds() ``` -------------------------------- ### Get Market Candles Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Fetches historical candle data for a specified trading pair and interval. Supports limiting the number of records returned. ```python candles = await client.market_data.get_candles( connector_name="binance_perpetual", trading_pair="ERA-USDT", interval="1m", max_records=60, ) ``` -------------------------------- ### Get Swap Quote (Buy) Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Retrieves a price quote for a swap without executing the transaction. Specify the connector, network, trading pair, side, amount, and slippage. ```python # Get quote for buying 1 SOL with USDC on Jupiter quote = await client.gateway_swap.get_swap_quote( connector='jupiter', network='solana-mainnet-beta', trading_pair='SOL-USDC', side='BUY', amount=Decimal('1'), slippage_pct=Decimal('1.0') # 1% slippage ) quote ``` -------------------------------- ### Place Market Order (Open Position) Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Execute a market order to open a new position. Specify the trading pair, side, amount, and position action. ```python await client.trading.place_order( account_name="master_account", connector_name="binance_perpetual", trading_pair="ETH-USDT", side="BUY", order_type="MARKET", amount=0.1, position_action="OPEN", ) ``` -------------------------------- ### Get Archived Bot Database Controllers Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Fetches details about controllers associated with an archived bot database. This helps in understanding the control mechanisms of the bot. ```python await client.archived_bots.get_database_controllers(dbs[1] ) ``` -------------------------------- ### Place Limit Order (Open Position) Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Submit a limit order to open a position at a specific price. This allows for more precise entry points compared to market orders. ```python await client.trading.place_order( account_name="master_account", connector_name="binance_perpetual", trading_pair="ETH-USDT", side="BUY", order_type="LIMIT", price=2550, amount=0.1, position_action="OPEN", ) ``` -------------------------------- ### Get Active Orders Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Retrieves a list of all currently active orders. ```APIDOC ## Get Active Orders ### Description Retrieves a list of all currently active orders. ### Method `client.trading.get_active_orders` ``` -------------------------------- ### Get Archived Bot Database Executors Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Fetches information about executors within an archived bot database. This can provide insights into bot execution components. ```python await client.archived_bots.get_database_executors(dbs[1]) ``` -------------------------------- ### Initialize Hummingbot API Client Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_swap_example.ipynb Initializes the Hummingbot API client. Ensure the client is connected to the Hummingbot Gateway. ```python from hummingbot_api_client import HummingbotAPIClient from decimal import Decimal client = HummingbotAPIClient(base_url='http://localhost:8000') await client.init() ``` -------------------------------- ### Create Hummingbot Client with Custom Timeout Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Shows how to instantiate the HummingbotClient with a custom timeout configuration using aiohttp.ClientTimeout. This allows for setting a specific duration for API requests. ```python import aiohttp # Create client with custom timeout timeout = aiohttp.ClientTimeout(total=60) # 60 seconds client = HummingbotClient( "http://localhost:8000", "admin", "admin", timeout=timeout ) ``` -------------------------------- ### Backtesting Router Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/README.md Run strategy backtests, configuring time periods, resolution, trading costs, and other custom options. ```APIDOC ## Backtesting Router (`client.backtesting`) ### Description Run strategy backtests. ### Methods - `run_backtesting(start_time, end_time, resolution, trade_cost, config)` - Run backtest ``` -------------------------------- ### Get Candles for Last N Days Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Fetches candle data for a specified trading pair and interval over a given number of past days. Simplifies fetching recent historical data. ```python await client.market_data.get_candles_last_days(connector="binance_perpetual", trading_pair="BTC-USDT", interval="1m", days=10) ``` -------------------------------- ### Create or Update Controller Configuration Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Creates a new controller configuration or updates an existing one with the provided name and configuration data. Use this to save or modify controller settings. ```python await client.controllers.create_or_update_controller_config("sol_tole_2", config) ``` -------------------------------- ### Get Portfolio History Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/portfolio_example.ipynb Retrieves the historical data for specified accounts. ```APIDOC ## Get Portfolio History ### Description Retrieves the historical data for specified accounts. ### Method GET (assumed, based on client method name) ### Endpoint /portfolio/history ### Parameters #### Query Parameters - **account_names** (list[str]) - Required - A list of account names to retrieve history for. ``` -------------------------------- ### Deploy Bot v2 Controller Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/bot_orchestration_example.ipynb Deploy a new Hummingbot bot instance using the v2 controller configuration. Specify instance name, credentials profile, controller configuration file, and the Docker image to use. ```python await client.bot_orchestration.deploy_v2_controllers( instance_name="test", credentials_profile="master_account", controllers_config=["sol_tole.yml"], image="dardonacci/hummingbot" ) ``` -------------------------------- ### List Controllers Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Retrieves a list of available controllers. ```APIDOC ## List Controllers ### Description Retrieves a list of all available controllers. ### Method GET ### Endpoint /controllers ### Response #### Success Response (200) - **controllers** (list) - A list of controller names. ``` -------------------------------- ### Get Order Book Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Retrieves the current order book for a trading pair. ```APIDOC ## GET /market_data/order_book ### Description Retrieves the current order book (bids and asks) for a specified trading pair from a given connector. ### Method GET ### Endpoint /market_data/order_book ### Parameters #### Query Parameters - **connector** (string) - Required - The name of the exchange connector. - **trading_pair** (string) - Required - The trading pair (e.g., 'BTC-USDT'). ### Response #### Success Response (200) - **...** (object) - The order book data, including bids and asks. ``` -------------------------------- ### Get Database Status Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Fetches the status of a specific archived bot database. ```APIDOC ## get_database_status ### Description Fetches the status of a specific archived bot database. ### Method `client.archived_bots.get_database_status(database_id)` ### Parameters #### Path Parameters - **database_id** (str) - Required - The identifier of the database to get the status for. ``` -------------------------------- ### List Available DEX Connectors Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/gateway_example.ipynb Retrieves a list of all available DEX connectors supported by the Gateway. This is useful for understanding which trading platforms can be integrated. ```python connectors = await client.gateway.list_connectors() connectors ``` -------------------------------- ### Deploy Bot v2 Controller Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/bot_orchestration_example.ipynb Deploys a new Hummingbot bot instance using the v2 controller configuration. ```APIDOC ## Deploy Bot v2 Controller ### Description Deploys a new Hummingbot bot instance using the v2 controller configuration. ### Method POST ### Endpoint /bot_orchestration/deploy_v2_controllers ### Parameters #### Request Body - **instance_name** (string) - Required - The name for the bot instance. - **credentials_profile** (string) - Required - The credentials profile to use for the bot. - **controllers_config** (list of strings) - Required - A list of controller configuration files (e.g., YAML). - **image** (string) - Required - The Docker image to use for the bot. ``` -------------------------------- ### Place Market Order (Close Position) Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Execute a market order to close an existing position. The `position_action` should be set to 'CLOSE'. ```python await client.trading.place_order( account_name="master_account", connector_name="binance_perpetual", trading_pair="ETH-USDT", side="SELL", order_type="MARKET", amount=0.1, position_action="CLOSE", ) ``` -------------------------------- ### Create or Update Controller Configuration Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/controllers_example.ipynb Creates a new controller configuration or updates an existing one. ```APIDOC ## Create or Update Controller Configuration ### Description Creates a new controller configuration or updates an existing one with the provided details. ### Method POST ### Endpoint /controllers/configs/{config_name} ### Parameters #### Path Parameters - **config_name** (string) - Required - The name for the new or existing controller configuration. #### Request Body - **config_data** (dict) - Required - The configuration data for the controller. ``` -------------------------------- ### Get Database Executors Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Fetches executor data from a specific archived bot database. ```APIDOC ## get_database_executors ### Description Fetches executor data from a specific archived bot database. ### Method `client.archived_bots.get_database_executors(database_id)` ### Parameters #### Path Parameters - **database_id** (str) - Required - The identifier of the database to retrieve executors from. ``` -------------------------------- ### List Available Connectors Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Retrieve a list of all available exchange connectors configured in Hummingbot. This is useful for discovering which trading pairs can be accessed. ```python await client.connectors.list_connectors() ``` -------------------------------- ### Get Position Mode Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/trading_example.ipynb Retrieves the current position mode for a specific account and connector. ```APIDOC ## Get Position Mode ### Description Retrieves the current position mode for a specific account and connector. ### Method `client.trading.get_position_mode` ### Parameters #### Path Parameters - **account_name** (str) - Required - The name of the account. - **connector_name** (str) - Required - The name of the connector. ``` -------------------------------- ### Get Database Trades Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/archived_bots_example.ipynb Fetches trade data from a specific archived bot database. ```APIDOC ## get_database_trades ### Description Fetches trade data from a specific archived bot database. ### Method `client.archived_bots.get_database_trades(database_id)` ### Parameters #### Path Parameters - **database_id** (str) - Required - The identifier of the database to retrieve trades from. ``` -------------------------------- ### List Available Connectors Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/connectors_example.ipynb Retrieves a list of all available exchange connectors configured in Hummingbot. ```APIDOC ## List Connectors ### Description Retrieves a list of all available exchange connectors. ### Method `GET` ### Endpoint `/connectors` ### Parameters None ### Response #### Success Response (200) - **connectors** (list) - A list of strings, where each string is the name of an available connector. ### Response Example ```json { "connectors": [ "binance", "kucoin", "dydx" ] } ``` ``` -------------------------------- ### Get Active Feeds Source: https://github.com/hummingbot/hummingbot-api-client/blob/main/examples/market_data_example.ipynb Retrieves information about currently active market data feeds. ```APIDOC ## GET /market_data/active_feeds ### Description Retrieves a list of all currently active market data feeds being tracked by the API. ### Method GET ### Endpoint /market_data/active_feeds ### Response #### Success Response (200) - **...** (object) - A dictionary where keys represent active feeds and values contain details about each feed, such as type, access time, and expiration. ```