Skip to content

Commit defa91a

Browse files
author
方佳
committed
Merge branch 'main_merge_20260714' into 'main'
feat: Fix data commands incorrectly routing to quotes endpoint and remove... See merge request webull/webull-openapi-cli!4
2 parents 2164825 + 38e6acd commit defa91a

7 files changed

Lines changed: 24 additions & 88 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@ For non-production environments, you must provide endpoint hosts explicitly:
9595
```bash
9696
webull auth login --region hk --env uat \
9797
--api-endpoint api.sandbox.webull.hk \
98-
--quotes-endpoint api.sandbox.webull.hk \
9998
--name hk-sandbox
10099
```
101100

102-
`--api-endpoint` and `--quotes-endpoint` are required for UAT. `--events-endpoint` is optional.
101+
`--api-endpoint` is required for UAT.
103102

104103
### Environment Variables
105104

@@ -222,7 +221,7 @@ Data is organized by asset class under `webull data <asset>`:
222221
| `webull profile list` | List profiles |
223222
| `webull profile switch` | Switch active profile |
224223
| `webull profile logout` | Remove a profile |
225-
| `webull profile set-endpoint` | Override API endpoints |
224+
| `webull profile set-endpoint` | Override API endpoint |
226225

227226
### Utilities
228227

‎internal/cmd/account.go‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ func newAPIClient() (*client.APIClient, error) {
6969
// Resolve endpoints: env overrides > profile overrides > defaults
7070
envOverrides := config.EnvEndpointOverrides()
7171
var overrides *config.RegionEndpoints
72-
if profile.Endpoints.API != "" || profile.Endpoints.Quotes != "" || profile.Endpoints.Events != "" {
72+
if profile.Endpoints.API != "" {
7373
overrides = &config.RegionEndpoints{
74-
API: profile.Endpoints.API,
75-
Quotes: profile.Endpoints.Quotes,
76-
Events: profile.Endpoints.Events,
74+
API: profile.Endpoints.API,
7775
}
7876
}
7977
endpoints := config.GetEndpoints(profile.Region, overrides)
@@ -82,12 +80,6 @@ func newAPIClient() (*client.APIClient, error) {
8280
if envOverrides.API != "" {
8381
endpoints.API = envOverrides.API
8482
}
85-
if envOverrides.Quotes != "" {
86-
endpoints.Quotes = envOverrides.Quotes
87-
}
88-
if envOverrides.Events != "" {
89-
endpoints.Events = envOverrides.Events
90-
}
9183
}
9284

9385
// Create credential provider

‎internal/cmd/auth.go‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ func init() {
3434
authLoginCmd.Flags().String("env", "prod", "Environment (prod/uat)")
3535
authLoginCmd.Flags().String("name", "", "Profile name (default: 'default')")
3636
authLoginCmd.Flags().String("api-endpoint", "", "API endpoint host (required for uat)")
37-
authLoginCmd.Flags().String("quotes-endpoint", "", "Quotes/Data API endpoint host")
38-
authLoginCmd.Flags().String("events-endpoint", "", "Events API endpoint host")
3937
authLoginCmd.MarkFlagRequired("region")
4038

4139
authCmd.AddCommand(authLoginCmd)
@@ -80,21 +78,12 @@ func runAuthLogin(cmd *cobra.Command, args []string) error {
8078

8179
// Resolve endpoints early so we can fail fast before asking for credentials
8280
apiEndpoint, _ := cmd.Flags().GetString("api-endpoint")
83-
quotesEndpoint, _ := cmd.Flags().GetString("quotes-endpoint")
84-
eventsEndpoint, _ := cmd.Flags().GetString("events-endpoint")
8581

86-
// UAT requires --api-endpoint and --quotes-endpoint
82+
// UAT requires --api-endpoint
8783
if env == config.EnvUAT {
88-
var missing []string
8984
if apiEndpoint == "" {
90-
missing = append(missing, "--api-endpoint")
91-
}
92-
if quotesEndpoint == "" {
93-
missing = append(missing, "--quotes-endpoint")
94-
}
95-
if len(missing) > 0 {
9685
output.PrintError("MISSING_ENDPOINT",
97-
fmt.Sprintf("UAT environment requires %s", strings.Join(missing, " and ")), 0)
86+
"UAT environment requires --api-endpoint", 0)
9887
return errSilent
9988
}
10089
}
@@ -136,9 +125,7 @@ func runAuthLogin(cmd *cobra.Command, args []string) error {
136125
Region: region,
137126
Env: env,
138127
Endpoints: config.Endpoints{
139-
API: apiEndpoint,
140-
Quotes: quotesEndpoint,
141-
Events: eventsEndpoint,
128+
API: apiEndpoint,
142129
},
143130
}
144131
apiHost := auth.ResolveAPIHost(tempProfile)
@@ -164,9 +151,7 @@ func runAuthLogin(cmd *cobra.Command, args []string) error {
164151
Region: region,
165152
Env: env,
166153
Endpoints: config.Endpoints{
167-
API: apiEndpoint,
168-
Quotes: quotesEndpoint,
169-
Events: eventsEndpoint,
154+
API: apiEndpoint,
170155
},
171156
AkSk: &config.AkSkCredentials{
172157
TokenCheckEnabled: configResp.TokenCheckEnabled,

‎internal/cmd/data.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
"github.com/spf13/cobra"
1414
"github.com/webull-inc/webull-openapi-cli/internal/client"
15-
"github.com/webull-inc/webull-openapi-cli/internal/config"
1615
"github.com/webull-inc/webull-openapi-cli/internal/output"
1716
)
1817

@@ -171,7 +170,7 @@ var dataStockBatchBarsCmd = &cobra.Command{
171170
return err
172171
}
173172
resp, err := cl.Do(context.Background(), "POST", "/openapi/market-data/stock/batch-bars", &client.RequestOptions{
174-
Module: config.ModuleQuotes, Body: body,
173+
Body: body,
175174
})
176175
if err != nil {
177176
output.PrintError("REQUEST_ERROR", err.Error(), 0)
@@ -701,7 +700,7 @@ func doDataGet(path string, query map[string]string) error {
701700
return err
702701
}
703702
resp, err := cl.Do(context.Background(), "GET", path, &client.RequestOptions{
704-
Module: config.ModuleQuotes, Query: query,
703+
Query: query,
705704
})
706705
if err != nil {
707706
output.PrintError("REQUEST_ERROR", err.Error(), 0)

‎internal/cmd/profile.go‎

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ func init() {
2525
profileCmd.AddCommand(profileSetEndpointCmd)
2626

2727
profileSetEndpointCmd.Flags().String("api-endpoint", "", "Override API endpoint")
28-
profileSetEndpointCmd.Flags().String("quotes-endpoint", "", "Override Quotes API endpoint (data-api)")
29-
profileSetEndpointCmd.Flags().String("events-endpoint", "", "Override Events API endpoint")
3028
}
3129

3230
var profileListCmd = &cobra.Command{
@@ -130,21 +128,17 @@ var profileLogoutCmd = &cobra.Command{
130128

131129
var profileSetEndpointCmd = &cobra.Command{
132130
Use: "set-endpoint",
133-
Short: "Set custom endpoint overrides for the active profile",
134-
Long: `Set custom API/Data/Events endpoint overrides for the active profile.
135-
Only specified endpoints are updated; others remain unchanged.
131+
Short: "Set custom endpoint override for the active profile",
132+
Long: `Set custom API endpoint override for the active profile.
136133
137134
Examples:
138135
webull profile set-endpoint --api-endpoint us-openapi-alb.uat.webullbroker.com
139-
webull profile set-endpoint --data-endpoint us-data-api.uat.webullbroker.com
140-
webull profile set-endpoint --api-endpoint api.webull.com --data-endpoint data-api.webull.com`,
136+
webull profile set-endpoint --api-endpoint api.webull.com`,
141137
RunE: func(cmd *cobra.Command, args []string) error {
142138
apiEp, _ := cmd.Flags().GetString("api-endpoint")
143-
quotesEp, _ := cmd.Flags().GetString("quotes-endpoint")
144-
eventsEp, _ := cmd.Flags().GetString("events-endpoint")
145139

146-
if apiEp == "" && quotesEp == "" && eventsEp == "" {
147-
output.PrintError("MISSING_PARAMETER", "at least one of --api-endpoint, --quotes-endpoint, --events-endpoint is required", 0)
140+
if apiEp == "" {
141+
output.PrintError("MISSING_PARAMETER", "--api-endpoint is required", 0)
148142
return fmt.Errorf("no endpoint specified")
149143
}
150144

@@ -164,32 +158,15 @@ Examples:
164158
return fmt.Errorf("active profile %q not found", cfg.ActiveProfile)
165159
}
166160

167-
// Incremental update: only override specified endpoints
168-
if apiEp != "" {
169-
profile.Endpoints.API = apiEp
170-
}
171-
if quotesEp != "" {
172-
profile.Endpoints.Quotes = quotesEp
173-
}
174-
if eventsEp != "" {
175-
profile.Endpoints.Events = eventsEp
176-
}
161+
profile.Endpoints.API = apiEp
177162

178163
if err := pm.Save(cfg); err != nil {
179164
return err
180165
}
181166

182167
if !flagQuiet {
183-
fmt.Fprintf(os.Stderr, "✓ Endpoints updated for profile %q\n", profile.Name)
184-
if apiEp != "" {
185-
fmt.Fprintf(os.Stderr, " api: %s\n", apiEp)
186-
}
187-
if quotesEp != "" {
188-
fmt.Fprintf(os.Stderr, " quotes-api: %s\n", quotesEp)
189-
}
190-
if eventsEp != "" {
191-
fmt.Fprintf(os.Stderr, " events-api: %s\n", eventsEp)
192-
}
168+
fmt.Fprintf(os.Stderr, "✓ Endpoint updated for profile %q\n", profile.Name)
169+
fmt.Fprintf(os.Stderr, " api: %s\n", apiEp)
193170
}
194171
return nil
195172
},

‎internal/cmd/root.go‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,9 @@ var doctorCmd = &cobra.Command{
116116
if profile.Endpoints.API != "" {
117117
endpoints.API = profile.Endpoints.API
118118
}
119-
if profile.Endpoints.Quotes != "" {
120-
endpoints.Quotes = profile.Endpoints.Quotes
121-
}
122-
if profile.Endpoints.Events != "" {
123-
endpoints.Events = profile.Endpoints.Events
124-
}
125119

126120
netResult := map[string]interface{}{}
127121
netResult["api_host"] = endpoints.API
128-
netResult["quotes_host"] = endpoints.Quotes
129-
if endpoints.Events != "" {
130-
netResult["events_host"] = endpoints.Events
131-
}
132122

133123
result["network"] = netResult
134124

‎internal/config/env.go‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ package config
77
import "os"
88

99
const (
10-
EnvAppKey = "WEBULL_APP_KEY"
11-
EnvAppSecret = "WEBULL_APP_SECRET"
12-
EnvAPIEndpoint = "WEBULL_API_ENDPOINT"
13-
EnvQuotesEndpoint = "WEBULL_QUOTES_ENDPOINT"
14-
EnvEventsEndpoint = "WEBULL_EVENTS_ENDPOINT"
15-
EnvProfile = "WEBULL_PROFILE"
10+
EnvAppKey = "WEBULL_APP_KEY"
11+
EnvAppSecret = "WEBULL_APP_SECRET"
12+
EnvAPIEndpoint = "WEBULL_API_ENDPOINT"
13+
EnvProfile = "WEBULL_PROFILE"
1614
)
1715

1816
// EnvCredentials attempts to load AK/SK from environment variables.
@@ -29,15 +27,11 @@ func EnvCredentials() (string, string, bool) {
2927
// EnvEndpointOverrides returns endpoint overrides from environment variables.
3028
func EnvEndpointOverrides() *RegionEndpoints {
3129
api := os.Getenv(EnvAPIEndpoint)
32-
quotes := os.Getenv(EnvQuotesEndpoint)
33-
events := os.Getenv(EnvEventsEndpoint)
3430

35-
if api == "" && quotes == "" && events == "" {
31+
if api == "" {
3632
return nil
3733
}
3834
return &RegionEndpoints{
39-
API: api,
40-
Quotes: quotes,
41-
Events: events,
35+
API: api,
4236
}
4337
}

0 commit comments

Comments
 (0)