Skip to main content

Basic Usage

The pages in this section explain the basic query syntax for OpenBB Python functions, what to expect on output, well as instructions for building the static assets behind the obb Python Package.

Endpoint & Model Definitions

All endpoints generated by extensions in the official OpenBB GitHub repo are detailed under the Reference section of the documentation. Standard models are defined under, Models.

note

Because of the modular framework, your specific installation may not contain all points of reference.

Static Assets

The ODP Python Package is compiled into static files, post-installation, based on the installed extensions.

This occurs automatically on first import and will not require a restart of the interpreter.

For general use, importing the package is all you need to do.

When deploying for use in a remote container or temporary environment, always run openbb-build immediately after installation.

Static Assets are exclusive to the Python Interface.

Files imported, by from openbb import obb, are not used by the API or MCP servers.

Rebuild them post-installation, or after removals and updates. You may need to invoke the openbb-build command manually on occassion.

Command Line

From the command line, with the environment active, run:

openbb-build

The script attempts to import the OpenBB package, and watches for assets being built.

Attempting to import the OpenBB package...

Extensions to add: alpha_vantage@1.5.0, benzinga@1.5.0, biztoc@1.5.0, bls@1.2.0, cboe@1.5.0, cftc@1.2.0, commodity@1.4.0,
congress_gov@1.1.0, crypto@1.5.0, currency@1.5.0, deribit@1.1.0, derivatives@1.5.0, ecb@1.5.0, econdb@1.4.0,
econometrics@1.6.0, economy@1.5.0, equity@1.5.0, etf@1.5.0, famafranch@1.1.0, famafrench@1.1.0, federal_reserve@1.5.0,
finra@1.5.0, finviz@1.4.0, fixedincome@1.5.0, fmp@1.5.0, fred@1.5.0, government_us@1.5.0, imf@1.2.0, index@1.5.0,
intrinio@1.5.0, multpl@1.2.0, nasdaq@1.5.0, news@1.5.0, oecd@1.5.0, openbb_charting@2.4.0, polygon@1.5.0, quantitative@1.5.0,
regulators@1.5.0, sec@1.5.0, seeking_alpha@1.5.0, stockgrid@1.5.0, technical@1.5.0, tiingo@1.5.0, tmx@1.4.0, tradier@1.4.0,
tradingeconomics@1.5.0, us_eia@1.2.0, uscongress@1.1.0, wsj@1.5.0, yfinance@1.5.0

Building...

If nothing to add or remove were detected, openbb-build will force the static files to be refreshed.


Did not build on import, triggering rebuild...

Verbose

Errors will be printed if the build process fails, and you can enable debug mode to see STDOUT while the build is occuring. Set the environment variable to enable.

OPENBB_DEBUG_MODE='true'

Importing

Initializing ODP in another application should be controlled by a single, synchronous, event - preferably on startup.

from openbb import obb
warning

Race conditions can occur where multi-threaded tasks share site-packages while static assets are built.

Static assets will need to be updated when extensions are installed, removed, or upgraded in an environment.

Controlled Import

Importing the obb application can take several hundred megabytes of memory, and you may need to control when it is first initialized.

Details
Example Code
from typing import Annotated

from fastapi import Depends, FastAPI
from openbb_core.app.model.abstract.singleton import SingletonMeta

app = FastAPI()


class OpenBB(metaclass=SingletonMeta):
def __init__(self):
import openbb

self._obb = openbb.sdk

@property
def obb(self):
return self._obb


def get_openbb():
return OpenBB().obb


OpenBBApp = Annotated[OpenBB, Depends(get_openbb)]


@app.get("stock_quote", response_model=list)
async def quote(
obb: OpenBBApp,
some_parameter: int,
symbol: str = "AAPL",
):
"""Widget description derived from the endpoint's docstring."""
return obb.equity.price.quote(symbol, provider="yfinance").model_dump()["results"]