Skip to main content

Quick Start Guide

This quick guide will help you trade via the API. The guide covers: installing the Webull SDK, obtaining API keys, and how to query account information.

1. Install the Webull Client SDK

Requirements

First, please generate your app key and app secret.

  • For individual users, please see here.
  • For institutional users, please see here.

Python version 3.8 through 3.11 is required.

SDK Installation

Install via pip

pip3 install --upgrade webull-openapi-python-sdk

2. Generate API Keys and Authenticate

Each API call requires authentication based on the App Key and a signature generated using the secret key. The client must provide the App Key and the signature in the HTTP request headers named x-app-key and x-signature respectively.

For rules on how to generate the signature based on the secret key, please refer to Signature.

Note

According to Hong Kong security and compliance requirements, in addition to authentication via App Key and signature, OpenAPI also requires Token verification. For details on Token creation and verification, please refer to Token Creation and Verification.

3. Using the Trading API via SDK

After installing the SDK and obtaining API keys, you can use the Trading API. The following example demonstrates how to retrieve the account list; for more operations, please refer to the Trading API Reference documentation.

3.1 Retrieve Account List

import json

from webull.core.client import ApiClient
from webull.data.common.category import Category
from webull.trade.trade_client import TradeClient

optional_api_endpoint = "<api_endpoint>"
your_app_key = "<your_app_key>"
your_app_secret = "<your_app_secret>"
region_id = "<region_id>"
account_id = "<your_account_id>"
api_client = ApiClient(your_app_key, your_app_secret, region_id)
api_client.add_endpoint(region_id, optional_api_endpoint)

if __name__ == '__main__':
trade_client = TradeClient(api_client)
res = trade_client.account_v2.get_account_list()
if res.status_code == 200:
print("account_list=" + json.dumps(res.json(), indent=4))