openbb-cli 1.4.2__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. openbb_cli-2.0.0/.gitignore +65 -0
  2. openbb_cli-2.0.0/PKG-INFO +383 -0
  3. openbb_cli-2.0.0/README.md +356 -0
  4. openbb_cli-2.0.0/openbb_cli/__init__.py +1 -0
  5. openbb_cli-2.0.0/openbb_cli/argparse_translator/__init__.py +1 -0
  6. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/argparse_translator/argparse_argument.py +2 -4
  7. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/argparse_translator/argparse_class_processor.py +19 -23
  8. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/argparse_translator/argparse_translator.py +48 -84
  9. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/argparse_translator/obbject_registry.py +21 -49
  10. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/argparse_translator/reference_processor.py +1 -8
  11. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/argparse_translator/utils.py +11 -20
  12. openbb_cli-2.0.0/openbb_cli/assets/figure.html +33 -0
  13. openbb_cli-2.0.0/openbb_cli/auth.py +51 -0
  14. openbb_cli-2.0.0/openbb_cli/backend.py +234 -0
  15. openbb_cli-2.0.0/openbb_cli/cli.py +987 -0
  16. openbb_cli-2.0.0/openbb_cli/codegen/__init__.py +1 -0
  17. openbb_cli-2.0.0/openbb_cli/codegen/credentials.py +98 -0
  18. openbb_cli-2.0.0/openbb_cli/codegen/fetcher_gen.py +1129 -0
  19. openbb_cli-2.0.0/openbb_cli/codegen/namespace_tree.py +158 -0
  20. openbb_cli-2.0.0/openbb_cli/codegen/package_gen.py +601 -0
  21. openbb_cli-2.0.0/openbb_cli/codegen/post_gen.py +782 -0
  22. openbb_cli-2.0.0/openbb_cli/codegen/project_gen.py +130 -0
  23. openbb_cli-2.0.0/openbb_cli/codegen/provider_gen.py +107 -0
  24. openbb_cli-2.0.0/openbb_cli/codegen/pydantic_gen.py +710 -0
  25. openbb_cli-2.0.0/openbb_cli/codegen/router_gen.py +401 -0
  26. openbb_cli-2.0.0/openbb_cli/codegen/test_gen.py +314 -0
  27. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/config/completer.py +53 -89
  28. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/config/constants.py +0 -1
  29. openbb_cli-2.0.0/openbb_cli/config/loader.py +451 -0
  30. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/config/menu_text.py +6 -31
  31. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/config/setup.py +1 -1
  32. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/config/style.py +4 -17
  33. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/controllers/base_controller.py +456 -145
  34. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/controllers/base_platform_controller.py +197 -65
  35. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/controllers/choices.py +41 -59
  36. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/controllers/cli_controller.py +340 -221
  37. openbb_cli-2.0.0/openbb_cli/controllers/credentials_controller.py +118 -0
  38. openbb_cli-2.0.0/openbb_cli/controllers/feature_controller.py +1335 -0
  39. openbb_cli-2.0.0/openbb_cli/controllers/platform_controller_factory.py +82 -0
  40. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/controllers/script_parser.py +17 -82
  41. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/controllers/settings_controller.py +2 -4
  42. openbb_cli-2.0.0/openbb_cli/controllers/user_controller.py +164 -0
  43. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/controllers/utils.py +372 -220
  44. openbb_cli-2.0.0/openbb_cli/dispatchers/__init__.py +18 -0
  45. openbb_cli-2.0.0/openbb_cli/dispatchers/_unpack.py +49 -0
  46. openbb_cli-2.0.0/openbb_cli/dispatchers/base.py +20 -0
  47. openbb_cli-2.0.0/openbb_cli/dispatchers/http.py +1126 -0
  48. openbb_cli-2.0.0/openbb_cli/dispatchers/local.py +78 -0
  49. openbb_cli-2.0.0/openbb_cli/dispatchers/multi.py +116 -0
  50. openbb_cli-2.0.0/openbb_cli/dispatchers/openapi_schema.py +1169 -0
  51. openbb_cli-2.0.0/openbb_cli/dispatchers/protocol.py +42 -0
  52. openbb_cli-2.0.0/openbb_cli/dispatchers/runtime.py +494 -0
  53. openbb_cli-2.0.0/openbb_cli/dispatchers/socrata.py +1073 -0
  54. openbb_cli-2.0.0/openbb_cli/dispatchers/spec.py +590 -0
  55. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/models/settings.py +28 -17
  56. openbb_cli-2.0.0/openbb_cli/outputs/__init__.py +15 -0
  57. openbb_cli-2.0.0/openbb_cli/outputs/base.py +28 -0
  58. openbb_cli-2.0.0/openbb_cli/outputs/figure.py +140 -0
  59. openbb_cli-2.0.0/openbb_cli/outputs/html.py +143 -0
  60. openbb_cli-2.0.0/openbb_cli/outputs/json.py +46 -0
  61. openbb_cli-2.0.0/openbb_cli/outputs/rich.py +113 -0
  62. openbb_cli-2.0.0/openbb_cli/outputs/stdio.py +7 -0
  63. openbb_cli-2.0.0/openbb_cli/outputs/tsv.py +68 -0
  64. openbb_cli-2.0.0/openbb_cli/session.py +185 -0
  65. openbb_cli-2.0.0/pyproject.toml +135 -0
  66. openbb_cli-1.4.2/PKG-INFO +0 -68
  67. openbb_cli-1.4.2/README.md +0 -41
  68. openbb_cli-1.4.2/openbb_cli/__init__.py +0 -1
  69. openbb_cli-1.4.2/openbb_cli/argparse_translator/__init__.py +0 -0
  70. openbb_cli-1.4.2/openbb_cli/cli.py +0 -32
  71. openbb_cli-1.4.2/openbb_cli/controllers/platform_controller_factory.py +0 -56
  72. openbb_cli-1.4.2/openbb_cli/session.py +0 -94
  73. openbb_cli-1.4.2/pyproject.toml +0 -31
  74. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/routines/routine_example.openbb +0 -0
  75. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/Consolas.ttf +0 -0
  76. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/dark.mpfstyle.json +0 -0
  77. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/dark.mplrc.json +0 -0
  78. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/dark.mplstyle +0 -0
  79. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/dark.pltstyle.json +0 -0
  80. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/dark.richstyle.json +0 -0
  81. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/light.mpfstyle.json +0 -0
  82. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/light.mplrc.json +0 -0
  83. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/light.mplstyle +0 -0
  84. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/light.pltstyle.json +0 -0
  85. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/light.richstyle.json +0 -0
  86. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/default/tables.pltstyle.json +0 -0
  87. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/assets/styles/user/openbb.richstyle.json +0 -0
  88. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/config/__init__.py +0 -0
  89. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/config/console.py +0 -0
  90. {openbb_cli-1.4.2 → openbb_cli-2.0.0}/openbb_cli/utils/utils.py +0 -0
@@ -0,0 +1,65 @@
1
+ # General
2
+ __pycache__/
3
+ *.pyc
4
+ .DS_Store
5
+ *.env
6
+ .venv
7
+ venv*/
8
+ venv
9
+ .vscode
10
+ *.ipynb
11
+ env/
12
+ venv/
13
+ !notebooks/jupyter/.gitkeep
14
+ .python-version
15
+ .mypy_cache
16
+ .ruff_cache
17
+ .pytest_cache
18
+ iframe_figures/
19
+ exports/*
20
+ .idea
21
+ .coverage
22
+ .scannerwork
23
+ htmlcov
24
+ **/.ipynb_checkpoints
25
+ *.swp
26
+ *.http
27
+ .coverage.*
28
+ *_tests.csv
29
+ *_sdk_audit.csv
30
+ !build/docker/compose.env
31
+ .dccache
32
+ *rome.json
33
+ **/node_modules/*
34
+ .cursorignore
35
+ darts_logs/
36
+ custom_imports/*.csv
37
+ custom_imports/*/*.csv
38
+ cache/
39
+ lightning_logs/
40
+ */mocked_path
41
+ *.pem
42
+
43
+ # CLI
44
+ *.pyo
45
+ **/dist/*
46
+ build/cli
47
+ build/nsis/app
48
+ DMG/*
49
+ *.dmg
50
+ *.sh
51
+ cli/openbb_cli/assets/styles/user/*
52
+
53
+ # Platform
54
+ openbb_platform/core/openbb/package/*
55
+ openbb_platform/core/openbb/.build.lock
56
+ **/assets/*.json.xz
57
+
58
+ # Dev Container env
59
+ obb/*
60
+
61
+ # OpenBB Distribution
62
+ !build/conda/installer/*.sh
63
+ *.pkg
64
+ *.exe
65
+ build/conda/tmp
@@ -0,0 +1,383 @@
1
+ Metadata-Version: 2.5
2
+ Name: openbb-cli
3
+ Version: 2.0.0
4
+ Summary: Investment Research for Everyone, Anywhere.
5
+ Project-URL: Homepage, https://openbb.co
6
+ Project-URL: Repository, https://github.com/OpenBB-finance/OpenBB
7
+ Project-URL: Documentation, https://docs.openbb.co/cli
8
+ Author-email: OpenBB Team <hello@openbb.co>
9
+ License: Apache-2.0
10
+ Requires-Python: <4,>=3.10
11
+ Requires-Dist: httpx<1.0.0,>=0.28.0
12
+ Requires-Dist: openbb-core[pandas]>=2.0.0
13
+ Requires-Dist: openpyxl<4.0.0,>=3.1.5
14
+ Requires-Dist: prompt-toolkit<4.0.0,>=3.0.50
15
+ Requires-Dist: python-dotenv<2.0.0,>=1.0.1
16
+ Requires-Dist: pyyaml>=6.0
17
+ Requires-Dist: rich<15.0.0,>=14.0.0
18
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
19
+ Provides-Extra: all
20
+ Requires-Dist: openbb-charting>=3.0.0; extra == 'all'
21
+ Requires-Dist: pywry>=2.0.4; extra == 'all'
22
+ Provides-Extra: charting
23
+ Requires-Dist: openbb-charting>=4.0.0; extra == 'charting'
24
+ Provides-Extra: interactive
25
+ Requires-Dist: pywry>=2.0.4; extra == 'interactive'
26
+ Description-Content-Type: text/markdown
27
+
28
+ <br />
29
+ <img src="https://github.com/OpenBB-finance/OpenBB/blob/develop/images/odp-light.svg?raw=true#gh-light-mode-only" alt="Open Data Platform by OpenBB logo" width="600">
30
+ <img src="https://github.com/OpenBB-finance/OpenBB/blob/develop/images/odp-dark.svg?raw=true#gh-dark-mode-only" alt="Open Data Platform by OpenBB logo" width="600">
31
+ <br />
32
+ <br />
33
+
34
+ # ODP Command-Line Interface
35
+
36
+ ## Overview
37
+
38
+ `openbb-cli` is a command-line interface for the [OpenBB Platform](https://docs.openbb.co/platform) and any other OpenAPI 3.x server. It runs in three modes:
39
+
40
+ * **Non-TTY one-shot** (default) — `openbb <command.path> [--key value]` dispatches one command, prints a JSON line, exits. The form CI tools and agents reach for.
41
+ * **Batch** — `openbb --batch` reads NDJSON requests from stdin, fans them out concurrently, writes NDJSON responses to stdout.
42
+ * **Interactive REPL** — `openbb -i` drops into a rich-output prompt with auto-completion, menu navigation, and routine playback.
43
+
44
+ Backends are pluggable: dispatch through an in-process `obb` namespace, an `openbb-platform-api` HTTP server, or any OpenAPI 3.x server (e.g. `https://api.congress.gov`) without touching code.
45
+
46
+ The full user docs live at **[docs.openbb.co/odp/cli](https://docs.openbb.co/odp/cli)**.
47
+
48
+ ## Backends
49
+
50
+ Four sources for the command surface. Three are OpenBB-aware; the fourth is the generic OpenAPI 3.x fallback.
51
+
52
+ | Source | Flag | Cold start | When to use |
53
+ |--------|------|------------|-------------|
54
+ | **In-process `obb`** | _(default)_ | slow (`import openbb` ~2s) | Local script with `openbb` already installed; no separate process to manage. |
55
+ | **OpenBB Platform server** | `--server URL` | fast after first fetch | Long-running shared server (`openbb-platform-api`) — many CLI invocations or many users amortize the import cost. |
56
+ | **OpenBB `.spec` file** | `--spec PATH` | fastest (~50ms) | Ship the spec next to scripts/agents; skips OpenAPI fetch + parse on every call. Generate with `openbb --generate-spec --server URL -o file.spec`. |
57
+ | **Arbitrary OpenAPI 3.x server** | `--server URL` (non-OpenBB host) | depends on host | Any external API with an OpenAPI document — Congress.gov, NY Fed, USDA, NWS, your own FastAPI service. |
58
+
59
+ The first three speak the same OpenBB Platform surface (the `OBBject` envelope, providers, the `obb.reference` menu tree). The fourth treats whatever the upstream publishes as the truth — same dispatcher, same parser, same auth, just no OpenBB-specific affordances.
60
+
61
+ ### What's different about OpenBB upstreams
62
+
63
+ Multi-provider Pydantic models and the `OBBject` envelope are OpenBB Platform conventions, not OpenAPI ones. The CLI detects an OpenBB endpoint by the presence of a `provider` discriminator parameter on the operation and turns on extra behavior:
64
+
65
+ | Feature | OpenBB upstream | Generic OpenAPI upstream |
66
+ |---------|-----------------|--------------------------|
67
+ | Response envelope | `OBBject` — `id`, `results`, `provider`, `warnings`, `chart`, `extra` | Whatever the server returns |
68
+ | `--describe COMMAND` | Groups parameters + result schema **per provider** | Flat `{parameters, output_schema}` |
69
+ | `--describe COMMAND:PROVIDER` | Returns just that provider's slice | Suffix ignored |
70
+ | Per-provider argparse narrowing | `--provider X` filters accepted flags; passing a flag from another provider errors at parse time | Every declared flag accepted |
71
+ | Help text per provider | `(provider: …)` annotations stripped; only sections relevant to the chosen provider | Description shown verbatim |
72
+ | REPL menu tree | Mirrors `obb.reference` (router descriptions, command groupings) | Built from URL path prefixes |
73
+ | Boolean flags | `--flag` / `--no-flag` toggle (OpenBB exposes `default: true` booleans) | Same — applies to any spec |
74
+
75
+ Everything else — `--list-commands`, `--describe COMMAND`, `--batch`, headers/query auth, spec generation, REPL playback — works identically against both kinds of upstream.
76
+
77
+ ## Installation
78
+
79
+ ```bash
80
+ pip install openbb-cli
81
+ ```
82
+
83
+ Optional extras:
84
+
85
+ ```bash
86
+ pip install "openbb-cli[charting]" # Plotly + openbb-charting
87
+ pip install "openbb-cli[interactive]" # PyWry browser-based tables
88
+ pip install "openbb-cli[all]" # everything
89
+ ```
90
+
91
+ ## Quick start
92
+
93
+ ### One-shot dispatch
94
+
95
+ ```bash
96
+ # Against the local in-process obb namespace (the historical default)
97
+ openbb economy.gdp --provider oecd --limit 5
98
+
99
+ # Against any OpenAPI server — auto-detects spec layout, $ref-resolves params,
100
+ # auto-extracts HTML-embedded specs (e.g. Congress.gov)
101
+ openbb --server http://127.0.0.1:6900 equity.price.historical --symbol AAPL --provider fmp
102
+ openbb --server https://api.congress.gov bill --limit 5
103
+ ```
104
+
105
+ ### Spec files for instant cold-start
106
+
107
+ ```bash
108
+ # Generate once; ship alongside the script that invokes the CLI
109
+ openbb --generate-spec --server https://api.congress.gov --output congress.spec
110
+
111
+ # Subsequent calls skip the OpenAPI fetch + parse on every invocation
112
+ openbb --spec congress.spec law --congress 119 --limit 5
113
+ ```
114
+
115
+ ### Generate an installable OpenBB extension from a spec
116
+
117
+ A `.spec` file is enough to dispatch commands directly. Going one step further, `--generate-extension` turns that spec into a full installable OpenBB Platform extension package — `Provider(...)` + `Fetcher` classes + a router that mirrors the upstream's namespace tree — that registers with `openbb-build` like any first-party extension. After install, every command shows up on the typed `obb.*` surface (auto-completion, `obb.reference`, `OBBject` envelopes, the works).
118
+
119
+ End-to-end with the NY Fed Markets API:
120
+
121
+ ```bash
122
+ # 1. Snapshot the OpenAPI surface as a spec file. NY Fed publishes its
123
+ # spec at a non-default path, so point --openapi-path at the YAML.
124
+ openbb --generate-spec \
125
+ --server https://markets.newyorkfed.org \
126
+ --openapi-path /static/docs/markets-api.yml \
127
+ --output nyfed.spec
128
+ # wrote 55 commands to nyfed.spec
129
+
130
+ # 2. Generate a complete extension project from that spec
131
+ openbb --generate-extension \
132
+ --spec nyfed.spec \
133
+ --provider-name nyfed \
134
+ --output ./openbb-nyfed
135
+ # wrote project to ./openbb-nyfed/openbb-nyfed
136
+ # providers (1): nyfed
137
+ # routers (10): ambs, fxs, guidesheets, marketshare, pd, rates, rp, seclending, soma, tsy
138
+ # fetchers: 55 GET (across all providers)
139
+ # POST: 0 local-compute commands
140
+ # install: pip install -e ./openbb-nyfed/openbb-nyfed
141
+ # build: openbb-build
142
+
143
+ # 3. Install + register with the OpenBB Platform
144
+ pip install -e ./openbb-nyfed/openbb-nyfed
145
+ openbb-build
146
+
147
+ # 4. The new namespaces are live on the typed obb surface
148
+ python -c "from openbb import obb; print(obb.nyfed.rates.all.latest().to_df())"
149
+ ```
150
+
151
+ (`--openapi-path` is only needed when the upstream doesn't expose `/openapi.json` directly. For servers that do — most FastAPI deployments, Congress.gov via the embedded-spec scraper — drop the flag.)
152
+
153
+ What `--generate-extension` produces:
154
+
155
+ ```
156
+ openbb-nyfed/
157
+ ├── pyproject.toml # PEP 621 / Hatchling — every provider + router declared as entry points
158
+ ├── README.md
159
+ └── openbb_nyfed/
160
+ ├── providers/
161
+ │ └── nyfed/
162
+ │ ├── __init__.py # nyfed_provider = Provider(name="nyfed", fetcher_dict={...}, credentials=[...])
163
+ │ └── models/<command>.py # one Fetcher class per command (QueryParams + Data + Fetcher)
164
+ └── routers/
165
+ ├── rates.py # @router.command(model="RatesAllLatest") — typed signature
166
+ ├── ambs.py
167
+ └── ... # one router per top-level namespace; sub-routers nest via include_router(prefix="/sub")
168
+ ```
169
+
170
+ Every flag is optional except `--spec`:
171
+
172
+ | Flag | Default | What it controls |
173
+ |------|---------|------------------|
174
+ | `--output PATH` | _required_ | Project root directory written to disk. |
175
+ | `--provider-name NAME` | derived from `--output` basename | Snake-case provider identifier — drives credential lookup keys (`credentials.get(f"{provider}_api_key")`). |
176
+ | `--project-name NAME` | `openbb-<provider-name>` | PyPI distribution name in `pyproject.toml`. Use dashes. |
177
+ | `--package-name NAME` | `openbb_<provider-name>` | Snake-case Python package name. |
178
+ | `--router-name NAME` | `<provider-name>` | Top-level router identifier. |
179
+
180
+ Bring-your-own-key APIs: parameter names that look like credentials (`api_key`, `apikey`, `app_token`, `X-API-Key`, `Authorization`, `client_secret`, `bearer_token`, …) are auto-promoted to the provider's `credentials=[...]` list. After install, `openbb` reads them through the standard user-settings flow (`OBB_USER_SETTINGS` / `~/.openbb_platform/user_settings.json`) — no per-call flag needed.
181
+
182
+ ### Multi-spec — combine APIs under one CLI
183
+
184
+ Repeat `--spec NAME=PATH` to mount more than one spec at once. Each spec's commands get prefixed with its namespace, and each backend keeps its own `base_url`, headers, and query params:
185
+
186
+ ```bash
187
+ openbb \
188
+ --spec congress=congress.spec \
189
+ --spec nyfed=nyfed.spec \
190
+ congress.bill --limit 5
191
+
192
+ openbb \
193
+ --spec congress=congress.spec \
194
+ --spec nyfed=nyfed.spec \
195
+ nyfed.markets.ambs --operation rates
196
+ ```
197
+
198
+ Scope auth per namespace by prefixing the flag value with `<NAME>:`:
199
+
200
+ ```bash
201
+ openbb \
202
+ --spec congress=congress.spec \
203
+ --spec usda=usda.spec \
204
+ -Q congress:api_key="$CONGRESS_KEY" \
205
+ -Q usda:api_key="$USDA_KEY" \
206
+ -H usda:Authorization="Bearer $USDA_BEARER" \
207
+ congress.bill --limit 5
208
+ ```
209
+
210
+ Tokens without a namespace prefix (`-H Authorization=...`, `-Q api_key=...`) apply to every backend; namespace-scoped tokens override on conflict for that one backend only.
211
+
212
+ The same shape works in TOML, which is the better fit when scripts reach for the same set repeatedly:
213
+
214
+ ```toml
215
+ [specs.congress]
216
+ path = "/path/congress.spec"
217
+ [specs.congress.query]
218
+ api_key = "..."
219
+
220
+ [specs.usda]
221
+ path = "/path/usda.spec"
222
+ [specs.usda.headers]
223
+ Authorization = "Bearer ..."
224
+ [specs.usda.query]
225
+ api_key = "..."
226
+ ```
227
+
228
+ `--list-commands` aggregates across every namespace; `--describe NAMESPACE.command[:provider]` resolves to the right backend automatically.
229
+
230
+ A single unnamed `--spec PATH` keeps the flat (unprefixed) command surface — backward-compatible with the historical single-spec form.
231
+
232
+ ### Auth
233
+
234
+ Pick whichever the upstream API uses:
235
+
236
+ ```bash
237
+ # Headers (Authorization, X-API-Key, ...)
238
+ openbb --server URL -H "Authorization: Bearer xxx" -H "X-Tenant: acme" cmd
239
+
240
+ # Query-string params (e.g. ?api_key=... like Congress.gov, USDA, NWS)
241
+ openbb --server URL -Q api_key=xxx cmd
242
+ # or via env — OPENBB_HTTP_QUERY_<NAME> auto-injected
243
+ OPENBB_HTTP_QUERY_API_KEY=xxx openbb --server URL cmd
244
+ ```
245
+
246
+ #### Auth hooks (RBAC, token refresh, dynamic credentials)
247
+
248
+ Static headers and query params cover the common case. For RBAC, expiring tokens, or per-user credentials sourced from a vault, register an importable callable as an auth hook. Configured in TOML by `module:attribute` path — global, or per `[specs.<ns>]`:
249
+
250
+ ```toml
251
+ auth-hook = "myapp.auth:default_hook" # applies to every backend
252
+
253
+ [specs.congress]
254
+ path = "/path/congress.spec"
255
+ auth-hook = "myapp.auth:congress_hook" # overrides the global for this one
256
+
257
+ [specs.internal]
258
+ path = "/path/internal.spec"
259
+ auth-hook = "myapp.auth:rbac_hook"
260
+ ```
261
+
262
+ The hook receives an `AuthContext` (namespace, command, params, method) and returns an `AuthDecision`:
263
+
264
+ ```python
265
+ # myapp/auth.py
266
+ from openbb_cli.auth import AuthContext, AuthDecision
267
+ from myapp.identity import current_user, get_token
268
+
269
+
270
+ def rbac_hook(ctx: AuthContext) -> AuthDecision:
271
+ user = current_user()
272
+ if not user.can_access(ctx.namespace, ctx.command):
273
+ return AuthDecision(
274
+ allow=False, deny_reason=f"{user.role} cannot call {ctx.command}"
275
+ )
276
+ return AuthDecision(headers={"Authorization": f"Bearer {get_token(user)}"})
277
+ ```
278
+
279
+ Hooks may be sync or async; coroutines are awaited. Returned headers and query params merge on top of the dispatcher's static auth (hook wins on conflict). `allow=False` short-circuits the dispatch with an `AccessDenied` error response — no network call is made.
280
+
281
+ Introspection is gated by the same hook: `--list-commands` invokes it for every command and silently drops denied entries from the listing, and `--describe COMMAND` returns `AccessDenied` when the hook denies. RBAC implementations that hide endpoints therefore hide them everywhere — discovery, schema, and dispatch all see the same surface.
282
+
283
+ ### Batch
284
+
285
+ NDJSON request/response over stdin/stdout, concurrent dispatch:
286
+
287
+ ```bash
288
+ cat <<'EOF' | openbb --spec congress.spec --batch
289
+ {"id":"a","command":"bill","params":{"limit":5,"format":"json"}}
290
+ {"id":"b","command":"law","params":{"congress":119,"format":"json"}}
291
+ {"id":"c","command":"__commands__"}
292
+ EOF
293
+ ```
294
+
295
+ ### Introspection
296
+
297
+ ```bash
298
+ openbb --spec congress.spec --list-commands # every command + short description
299
+ openbb --spec congress.spec --describe bill # full schema (params + response)
300
+ ```
301
+
302
+ The same calls work as reserved commands in batch mode (`__commands__`, `__schema__`).
303
+
304
+ ### Interactive REPL
305
+
306
+ ```bash
307
+ openbb -i # in-process obb backend
308
+ openbb -i --spec congress.spec # spec-driven; no obb install required
309
+ openbb -i --server URL # live OpenAPI fetch
310
+ ```
311
+
312
+ The REPL adds menu navigation (`bill`, `..`, `home`, `exit`), tab/auto-completion against parser flags, `--help` per command, the OBBject registry, and routine playback (`exe --file ...`).
313
+
314
+ ## Configuration
315
+
316
+ Layered, all optional. Resolution order (lowest → highest priority):
317
+
318
+ 1. Built-in defaults
319
+ 2. `[tool.openbb-cli]` in nearest ancestor `pyproject.toml`
320
+ 3. `~/.openbb_platform/openbb.toml` (user-global; same dir as `user_settings.json`)
321
+ 4. `./openbb.toml` (project-local, walks up from CWD)
322
+ 5. `--config PATH` (or `OPENBB_CLI_CONFIG`)
323
+ 6. `~/.openbb_platform/.env` and `--env-file PATH`
324
+ 7. `OPENBB_*` shell exports
325
+ 8. CLI flags
326
+
327
+ Bootstrap a documented template:
328
+
329
+ ```bash
330
+ openbb --print-config-template > ~/.openbb_platform/openbb.toml
331
+ ```
332
+
333
+ Inspect what's currently active across all layers:
334
+
335
+ ```bash
336
+ openbb --show-config
337
+ ```
338
+
339
+ Schema:
340
+
341
+ ```toml
342
+ # Backend / dispatch — pick one of these forms
343
+ server = "https://api.congress.gov" # live OpenAPI fetch
344
+ spec = "/path/to/api.spec" # single spec (flat surface)
345
+ batch-concurrency = 16
346
+
347
+ # Multi-spec: each table mounts under its own namespace
348
+ [specs.congress]
349
+ path = "/path/congress.spec"
350
+ [specs.congress.query]
351
+ api_key = "..."
352
+
353
+ [specs.usda]
354
+ path = "/path/usda.spec"
355
+ [specs.usda.headers]
356
+ Authorization = "Bearer ..."
357
+ [specs.usda.query]
358
+ api_key = "..."
359
+
360
+ # REPL display preferences (top-level shortcuts)
361
+ output-mode = "rich" # rich | json | tsv | html
362
+ flair = ":fox_face"
363
+ timezone = "America/New_York"
364
+ rich-style = "dark"
365
+
366
+ [headers] # global — applied to every backend
367
+ Authorization = "Bearer ..."
368
+
369
+ [query] # global — applied to every backend
370
+ api_key = "..."
371
+
372
+ [settings]
373
+ # Every other Settings field — same surface as the /settings/ REPL menu
374
+ allowed-number-of-rows = 50
375
+ use-prompt-toolkit = true
376
+ toolbar-hint = false
377
+ ```
378
+
379
+ ## Documentation
380
+
381
+ Full user documentation: **[docs.openbb.co/odp/cli](https://docs.openbb.co/odp/cli)**
382
+
383
+ API reference: [docs.openbb.co/platform](https://docs.openbb.co/platform)