Skip to content

webullapi4go

webullapi4go is an idiomatic Go SDK for the Webull OpenAPI. It wraps Webull's HTTP, MQTT, and gRPC services in typed Go clients.

The latest repository tag is v2.1.4 (2026-09-26). Current request-pipeline, OMS, streaming, event-telemetry, and documentation hardening is tagged in repository v2.1.4, implemented, and offline-tested; it is not presented as live-verified. This is a repository patch release, not a Go-semver-compatible v2 module: the module path uses the /v2 import path by decision, so v2.x tags are repository-only. See the implementation status and changelog.

Coverage

The generated SDK ↔ API Reconciliation reports 209 implemented endpoints, 0 documented-only gaps, and the partition 184 exact OpenAPI JSON path matches, 4 summary-only matches, 1 path differing from both sources, 0 unresolved SDK paths, 3 rows carrying the no OpenAPI schema on page label, and 17 manifest entries deliberately mapped to no SDK symbol in its 2026-09-26 snapshot. The 189 rows with a verified path plus those 3 and 17 account for all 209, so no endpoint is missing, and the snapshot is not a zero-discrepancy report. That 3 is a label count, not a page count: 7 gRPC reference pages embed no OpenAPI schema, and 4 of them are recorded as intentionally unmapped instead because the generator evaluates that status first, which keeps the status table a partition of the 209 rows. Coverage does not mean every endpoint has been live-verified.

Feature status

Area Implementation Verification boundary
Authentication Implemented Core token flow live-verified in HK; production 2FA is user-driven
Market Data HTTP Implemented Offline-tested; selected HK calls live-verified, US/entitlement surfaces partial
Market Data MQTT Implemented Offline-tested; basic HK streaming path previously live-verified
Trading HTTP + OMS Implemented Offline-tested; accounts/assets/preview and guarded paths exercised in HK
Trading Events Implemented Offline-tested; basic stream path previously exercised
Broker API HK Implemented Offline-tested; HK blocked by missing route scope (401)
Broker FD US Implemented Offline-tested; live verification blocked without US credentials
Display Solution Implemented Offline-tested; HK host returns 403
Connect OAuth Implemented Offline-tested; US live access unavailable

Architecture

┌──────────────────────────────────────────────────────────────────────┐
│                          Your Application                            │
├───────────┬───────────┬───────────┬───────────┬──────────────────────┤
│  client   │   data    │   trade   │  stream   │ events / connect /   │
│  (core)   │ (market)  │ (trading) │  (MQTT)   │ display / brokerfd   │
├───────────┴───────────┴───────────┴───────────┴──────────────────────┤
│ Shared foundations: pkg/errors · observability · resilience ·        │
│ transport · types · domain/money · domain/order                      │
├──────────────────────────────────────────────────────────────────────┤
│ internal: signing and compatibility implementation details           │
└──────────────────────────────────────────────────────────────────────┘
         broker/ = separate Broker API HK Go module
         webull/ = optional thin aliases for the core client

The root service packages are canonical. A full relocation under pkg/ is superseded and closed. Public financial DTOs use money.Money or *money.Money, not raw decimal.Decimal.

Install

The module path is github.com/shing1211/webullapi4go/v2. Install the latest release:

go get github.com/shing1211/webullapi4go/v2@latest

The first installable Go-semver v2 tag is v2.2.0. Earlier v2.1.x repository tags declared the pre-migration module path and were not installable; they have been removed. A commit pin (@<sha>) or branch ref (@main) still work for a specific tree. Requires Go 1.26 or newer.

Quickstart

package main

import (
    "context"
    "log"

    "github.com/shing1211/webullapi4go/v2/client"
    "github.com/shing1211/webullapi4go/v2/data"
)

func main() {
    cl, err := client.New(client.WithEnv())
    if err != nil {
        log.Fatal(err)
    }
    defer func() { _ = cl.Close() }()

    ctx := context.Background()
    if _, err := cl.EnsureToken(ctx); err != nil {
        log.Fatal(err)
    }

    market := data.New(cl)
    snaps, err := market.GetSnapshot(ctx, data.SnapshotQuery{
        Symbols:  []string{"AAPL"},
        Category: data.StockCategoryUS,
    })
    if err != nil {
        log.Fatal(err)
    }
    for _, snap := range snaps {
        log.Printf("%s %s", snap.Symbol, snap.Price)
    }
}

Set credentials through the environment or client.WithCredentials:

export WEBULL_APP_KEY="your-sandbox-app-key"
export WEBULL_APP_SECRET="your-sandbox-app-secret"
export WEBULL_ENVIRONMENT="sandbox"

Core patterns

  • client.New constructs one shared core; data.New, trade.New, stream.New, and events.New bind service clients to it.
  • Financial DTOs preserve decimal precision through money.Money while JSON remains a string.
  • pkg/errors exposes stable Code values and sentinels for errors.Is and errors.As; do not match error strings.
  • Trading tracks successful place/batch results and can reconcile order snapshots or event-driven states locally.
  • Streaming exposes lifecycle state, a data-age watchdog, and bounded channels with blocking, drop-oldest, or sampling policies.
  • REST, MQTT, and both gRPC event clients inherit core logging, correlation, and OTel configuration.

Documentation

Disclaimer

This SDK is an independent, unofficial wrapper and is not affiliated with or endorsed by Webull. It is provided for reference and educational use and is not investment advice.