# Webull CLI

> Command-line trading tool for AI Agents, quant developers, and institutional clients. Covers US stocks/ETFs, options, futures, crypto, and event contracts, plus fundamentals, news, screeners, watchlists, and community.

Source code: [webull-inc/webull-openapi-cli](https://github.com/webull-inc/webull-openapi-cli)

---

## What is Webull CLI

Webull CLI (`webull`) is a single-binary Go tool that wraps the full Webull OpenAPI surface into a structured command-line interface. It provides complete access to all 5 asset classes with the richest feature set across all supported markets.

### Capabilities

| Asset Class | Trading | Market Data |
|-------------|---------|-------------|
| Stocks/ETFs | ✓ | ✓ |
| Options | ✓ | ✓ |
| Futures | ✓ | ✓ |
| Crypto | ✓ | ✓ |
| Event Contracts | ✓ | ✓ |

### Architecture Overview

```mermaid
sequenceDiagram
    participant U as User / AI Agent
    participant CLI as Webull CLI (Go binary)
    participant API as Webull OpenAPI (US)

    U->>CLI: Shell command (e.g. webull data stock snapshot --symbol AAPL)
    CLI->>API: Authenticated REST request (OAuth token or AK/SK signature) → api.webull.com
    API-->>CLI: JSON response
    CLI-->>U: Structured JSON output (stdout)
```

---

## Prerequisites

### API Credentials

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

If you log in with OAuth (the default), you don't need an App Key or App Secret. You authorize the CLI in the browser with your Webull account. The credentials below are only required for AK/SK login.

<Tabs groupId="environment">
  <TabItem value="prod" label="Production" default>

Apply based on your account type:

Individual users: [Individual Application Process](../authentication/IndividualApplicationAPI.md)

Institutional users: [Institution Application Process](../authentication/apply.md)

  </TabItem>
  <TabItem value="test" label="Test Environment">

No application required. Use the publicly shared test credentials to get started immediately. See [SDKs and Tools](../sdk.md).

  </TabItem>
</Tabs>

### Other Requirements

- **Go 1.26.2+** (for `go install`) or download pre-built binary
- **Web browser** on any device (for OAuth login)
- **Webull App** (for AK/SK login, if 2FA verification is required)
- **Market Data Subscription** (for real-time quotes): [Subscription Guide](../market-data-api/subscribe-quotes.md)

---

## Setup Steps

```mermaid
flowchart LR
    S1(Install Go) --> S2(Install CLI) --> S3(Authenticate) --> S4(Verify Connection) --> S5(Start Trading)
```

### Step 1: Install Go Environment

Check if Go is already installed:

```bash
go version
```

If not installed or version is below 1.26.2, install Go:

```bash
# macOS (Homebrew)
brew install go

# Linux
wget https://go.dev/dl/go1.26.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.26.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

# Windows — download installer from https://go.dev/dl/
```

Verify Go installation:

```bash
go version
# Expected: go version go1.26.2 or higher
```

### Step 2: Install Webull CLI

```bash
go install github.com/webull-inc/webull-openapi-cli/cmd/webull@latest
```

Or download pre-built binary from [GitHub Releases](https://github.com/webull-inc/webull-openapi-cli/releases).

Ensure `$GOPATH/bin` is in your PATH:

```bash
export PATH=$PATH:$(go env GOPATH)/bin
```

Verify:
```bash
webull version
```

### Step 3: Authenticate

The CLI supports two login methods:

| Method | Command | Credentials |
|--------|---------|-------------|
| **OAuth** (default) | `webull auth login` | Authorize in the browser with your Webull account |
| **AK/SK** | `webull auth login --method credentials --region us` | App Key and App Secret, plus 2FA if enabled |

:::caution
In the production environment, OAuth login does not currently support trading. To place orders in production, log in with AK/SK.
:::

<Tabs groupId="auth-method">
<TabItem value="oauth" label="OAuth (default)" default>

```bash
webull auth login                 # production
webull auth login --env sandbox   # test environment
```

The CLI prints an authorization URL and a user code, and tries to open your browser. Sign in, choose the account and scope to authorize, and confirm. The CLI completes the login automatically once you approve.

```
Open the following URL in your browser to authorize:
https://.../oauth2/ai-cli/login?client_id=...&user_code=WDJB-MJHT

Enter the code: WDJB-MJHT

Browser opened. Waiting for authorization...

Successfully authenticated.
```

- No `--region` flag is needed. The region is determined during authorization.
- On a machine without a browser, open the printed URL on any other device to authorize.
- The access token is refreshed automatically, so you usually only need to authorize once.

</TabItem>
<TabItem value="aksk" label="AK/SK">

```bash
webull auth login --method credentials --region us                # production
webull auth login --method credentials --region us --env sandbox  # test environment
```

Enter your App Key and App Secret when prompted. If 2FA is enabled, approve the request in the Webull App.

</TabItem>
</Tabs>

The CLI stores only one login at a time. Each successful `auth login` overwrites the previous one, whether it used OAuth or AK/SK. To log out and remove the stored credentials, run `webull auth logout`.

### Step 4: Verify Connection

```bash
webull doctor
```

`doctor` checks your local configuration and prints a JSON summary (no API request is made). Example:

```json
{
  "config_file": { "status": "ok", "path": "~/.config/webull/profiles.json" },
  "auth": { "status": "ok", "auth_method": "oauth", "region": "us", "env": "prod" },
  "network": { "api_host": "api.webull.com" }
}
```

`auth_method` is `oauth` for OAuth login and `ak_sk` for AK/SK login. To check whether your login is still accepted by the server, run `webull auth status`. For OAuth, `session_status` shows `active` or `invalid`.

Use Step 5 to confirm the API connection works.

### Step 5: Verify Account Access

```bash
webull account list
```

---

## Usage Examples

Just talk to your AI assistant in natural language, or use the CLI directly:

**Market Data:**
```bash
webull data stock snapshot --symbol AAPL,TSLA
webull data stock bars --symbol AAPL --timespan D --count 200
webull data futures snapshot --symbol ESM6
webull data crypto snapshot --symbol BTC-USD,ETH-USD
webull data event snapshot --symbol FED-RATE-MAY
```

**Trading:**

Trading in production requires AK/SK login. See [Step 3: Authenticate](#step-3-authenticate).

```bash
webull order stock submit --account-id ACC123 --symbol AAPL \
  --side BUY --qty 10 --type LIMIT --limit-price 185.00

webull order option submit --account-id ACC123 --symbol AAPL \
  --side BUY --qty 1 --option-type CALL --strike 190 --expiry 2026-04-17 \
  --order-type LIMIT --limit-price 3.50

webull order futures submit --account-id ACC123 --symbol ESM6 \
  --side BUY --qty 1 --type LIMIT --limit-price 5200.00 -y

webull order crypto submit --account-id ACC123 --symbol BTC-USD \
  --side BUY --qty 0.01 --type MARKET -y

webull order event submit --account-id ACC123 --symbol FED-RATE-MAY \
  --side BUY --qty 10 --limit-price 0.65 --event-outcome yes -y

# Algo order (TWAP/VWAP/POV) via stock submit
webull order stock submit --account-id ACC123 --symbol AAPL \
  --side BUY --qty 100 --type LIMIT --limit-price 185.00 \
  --algo-type TWAP --max-target-percent 10 \
  --algo-start-time 10:00:00 --algo-end-time 15:00:00
```

**News, Insights & Community:**
```bash
webull data news search --keyword "Tesla earnings"
webull data news stock-news --symbol TSLA --sentiment POSITIVE
webull data market-sentiment
webull data 13f search --keyword "Berkshire"
webull community hot-stocks
webull community post by-symbol --symbol NVDA
```

**Order Management:**
```bash
webull order open --account-id ACC123
webull order stock replace --account-id ACC123 \
  --client-order-id cli_stock_123456 --limit-price 190.00
webull order cancel --account-id ACC123 --client-order-id cli_stock_123456 -y
```

**Account:**
```bash
webull account balance --account-id ACC123
webull account positions --account-id ACC123
```

---

## Available Commands

Every command supports `--help` for the full list of flags, e.g. `webull order stock submit --help`.

### Orders

| Command | Description |
|---------|-------------|
| `order stock submit` | Place stock order (MARKET/LIMIT/STOP_LOSS/STOP_LOSS_LIMIT/TRAILING_STOP_LOSS). Use `--algo-type TWAP\|VWAP\|POV` for algo orders |
| `order stock preview` | Preview stock order cost |
| `order stock replace` | Modify a stock order |
| `order stock combo` | Combo order (OTO/OCO/OTOCO) via JSON |
| `order option submit` | Place single-leg option order |
| `order option preview` | Preview option order cost |
| `order option replace` | Modify an option order |
| `order option strategy` | Multi-leg option strategy via JSON |
| `order futures submit` | Place futures order |
| `order futures replace` | Modify futures order |
| `order crypto submit` | Place crypto order |
| `order event submit` | Place event contract order |
| `order event replace` | Modify event contract order |
| `order cancel` | Cancel any unfilled order |
| `order open` | List open/pending orders |
| `order detail` | Get order details |
| `order history` | Get historical orders (`--start`, `--end`, `--limit`) |

### Market Data

| Command | Description |
|---------|-------------|
| `data stock snapshot` | Real-time stock/ETF snapshot |
| `data stock bars` | Stock OHLCV bars (single) |
| `data stock batch-bars` | Stock OHLCV bars (batch) |
| `data stock quotes` | Order book depth |
| `data stock tick` | Tick-by-tick trades |
| `data stock footprint` | Large order footprint |
| `data stock noii-bars` | NOII auction K-line |
| `data stock noii-snapshot` | NOII auction snapshot |
| `data option snapshot` | Option real-time snapshot |
| `data option bars` | Option OHLCV bars |
| `data option tick` | Option tick-by-tick trades |
| `data futures snapshot` | Futures snapshot |
| `data futures bars` | Futures OHLCV bars |
| `data futures tick` | Futures tick-by-tick |
| `data futures depth` | Futures order book |
| `data futures footprint` | Futures large order footprint |
| `data crypto snapshot` | Crypto snapshot |
| `data crypto bars` | Crypto OHLCV bars |
| `data event snapshot` | Event contract snapshot |
| `data event bars` | Event contract bars |
| `data event tick` | Event contract tick-by-tick |
| `data event depth` | Event contract order book |

### Screener

| Command | Description |
|---------|-------------|
| `data screener gainers-losers` | Top gainers/losers |
| `data screener actives` | Most active stocks |
| `data screener market-sectors` | Market sector overview and rankings |
| `data screener market-sectors-detail` | Stock list for a specific sector |
| `data screener high-dividend` | High dividend stocks ranking |
| `data screener 52whl` | 52-week high/low stocks |
| `data market-sentiment` | US market fear & greed sentiment index |
| `data stock unusual-activities` | US stock unusual activity alerts |

### News

| Command | Description |
|---------|-------------|
| `data news search` | Search US market news by keyword |
| `data news detail` | Get full news content by ID |
| `data news stock-news` | News related to a US stock (optional `--sentiment`) |

### Fundamentals & Insights

| Command | Description |
|---------|-------------|
| `data fundamentals company-profile` | Company profile information |
| `data fundamentals analyst-price` | Analyst target price |
| `data fundamentals analyst-rating` | Analyst rating |
| `data fundamentals forecast-eps` | Forecast EPS |
| `data fundamentals filings` | SEC filings |
| `data fundamentals earnings-calendar` | Earnings calendar |
| `data fundamentals dividend-calendar` | Dividend calendar |
| `data fundamentals capital-flow` | Capital flow distribution |
| `data fundamentals industry-comparison` | Industry peer comparison |
| `data fundamentals indicators` | Financial indicators |
| `data fundamentals income` | Income statement |
| `data fundamentals cashflow` | Cash flow statement |
| `data fundamentals balancesheet` | Balance sheet |
| `data fundamentals alert` | Earnings release alert |
| `data fundamentals fund-brief` | Fund brief information |
| `data fundamentals fund-performance` | Fund performance returns |
| `data fundamentals fund-net-value` | Fund NAV history |
| `data fundamentals fund-holdings` | Fund top 10 holdings |
| `data fundamentals fund-dividends` | Fund dividend history |
| `data fundamentals fund-rating` | Fund rating history |
| `data fundamentals fund-splits` | Fund split history |
| `data fundamentals fund-files` | Fund documents and files |
| `data fundamentals fund-allocation` | Fund asset allocation |
| `data 13f search` | Search US institutional investors by name or CIK |
| `data 13f holdings` | Institution 13F holdings |
| `data 13f transactions` | Institution holding changes (OPEN/CLOSE/CHANGE) |
| `data stock insider-transactions` | US insider transactions |
| `data stock insider-holdings-overview` | US insider ownership overview |
| `data stock economic-calendar` | US macroeconomic calendar |

### Instruments

| Command | Description |
|---------|-------------|
| `instrument stock` | Query stock/ETF instruments |
| `instrument option` | Query option contracts |
| `instrument crypto` | Query crypto instruments |
| `instrument futures` | Query futures contracts |
| `instrument futures-products` | Futures product codes |
| `instrument futures-class` | Futures product classes |
| `instrument event` | Query event contract instruments |
| `instrument event-categories` | List event categories |
| `instrument event-series` | List event series |
| `instrument event-events` | List events by series |

### Watchlists

| Command | Description |
|---------|-------------|
| `watchlist list` | List all watchlists |
| `watchlist get` | Get watchlist instruments |
| `watchlist create` | Create a watchlist |
| `watchlist update` | Update watchlist name/sort |
| `watchlist delete` | Delete a watchlist |
| `watchlist add` | Add instruments |
| `watchlist remove` | Remove instruments |
| `watchlist sort` | Update instrument sort order |

### Community

| Command | Description |
|---------|-------------|
| `community post create` | Create a plain-text post (optional `--symbol` + `--category`). Publishes under your account |
| `community comment create` | Comment on a post. Publishes under your account |
| `community hot-stocks` | List stocks ranked by community activity |
| `community post by-symbol` | List posts associated with a symbol |
| `community post get` | Get post detail |
| `community my-posts` | List posts created by the current user |

### Account

| Command | Description |
|---------|-------------|
| `account list` | List trading accounts |
| `account balance` | Account balance |
| `account positions` | Account positions |

### Auth & Utilities

| Command | Description |
|---------|-------------|
| `auth login` | Log in with OAuth (default) or AK/SK (`--method credentials --region us`). Use `--env sandbox` for the test environment |
| `auth status` | Check auth status |
| `auth logout` | Log out and remove stored credentials |
| `doctor` | Diagnose local configuration |
| `version` | Print version info |

---

## Configuration

### Environment Endpoints

See [API Environments](../sdk.md#api-environments) for production and test endpoint details.

### Flags

The environment (`--env`) and, for AK/SK, the region (`--region`) are set once at `auth login`, and apply to all later commands.

| Flag | Description |
|------|-------------|
| `--csv` | CSV output |
| `-q, --quiet` | Suppress non-data output |
| `--verbose` | Show HTTP request summary |
| `--debug` | Show full request/response |
| `--timeout` | HTTP timeout in seconds (default 30) |
| `-y, --yes` | Skip confirmation prompts |

The trading session is set per command, not globally: use `--session` (CORE/ALL/NIGHT/ALL_DAY) on `order stock submit` and `order stock preview`.

---

## Security Recommendations

- Never share App Key, App Secret, or Token in chat
- Use `order stock submit --dry-run` to print the request payload without submitting
- Use `order stock preview` / `order option preview` to estimate costs before live orders
- `community post create` and `community comment create` publish content under your account
- In Live mode, orders require confirmation unless `-y` is passed
- Use test environment for testing before production
---

## Disclosure

Trading in securities, options, futures, crypto, and event contracts involves substantial risk of loss. All trading decisions are at your own discretion. Verify order details before execution. This software is provided "as is" without warranty.

---

## Related Links

- GitHub: [webull-inc/webull-openapi-cli](https://github.com/webull-inc/webull-openapi-cli)
