Skip to main content

Create New Provider Extension

This page will walk through creating a new OpenBB Provider Extension from scratch. By the end, you will have the shell structure for holding models that connect to the Router through the Provider Interface.

Preparation

Create Project Folder

Create a folder for the project. For this example, we will name the folder, empty_provider.

Create __init__.py File

  • Inside the new folder, create a new file called, __init__.py.
  • Open the file and add a docstring in the first line, and leave an empty line below it.
"""Empty OpenBB Provider."""

Create README.md File

  • In the same location, create a new file called, README.md.
  • Open the file, then add a title and any other high-level information about the extension.
# Empty OpenBB Provider Extension

An example Provider extension for the OpenBB Platform.

Create pyproject.toml File

  • In the same location, create a new file called, pyproject.toml.
[tool.poetry]
name = "openbb-empty-provider"
version = "0.0.1"
description = "Empty provider extension for OpenBB"
authors = ["OpenBB Team <hello@openbb.co>"]
readme = "README.md"
packages = [{ include = "openbb_empty_provider" }]

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
openbb = "^4.1.7"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.plugins."openbb_provider_extension"]
empty = "openbb_empty_provider:empty_provider"

Create Sub-Folder For Code

  • Create a sub-folder that begins with openbb and is followed by the name of the project folder, openbb_empty_provider.

Create __init__.py File

  • In the new sub-folder, create a new file called, __init__.py. This is where all models are mapped to the Provider interface.
"""Empty Provider Module."""

from openbb_core.provider.abstract.provider import Provider

empty_provider = Provider(
name="empty", # This should be the same as the assigned name at the bottom of the pyproject.toml file
website="http://empty.io",
description="""The empty provider is a supplier of promises.""",
#credentials=["api_key"], # uncomment to require credentials
fetcher_dict={
# "SomeModel" : EmptySomeModelFetcher # Map Fetchers to the Router here.
},
)

Create models Sub-Folder

  • In the same location as the file just saved, create a new folder called, models.

Create __init__.py File

  • In the new models folder, make a new file called, __init__.py.
  • Open the file and add a doctstring to the top line, followed by an empty line.
"""Empty Provider Models."""

Build Lock File

  • The Python environment should have toml and poetry installed as packages from PyPI.
pip install toml poetry
  • Navigate into the main folder, and with the environment active, enter:
poetry lock

Install Extension In Editable Mode

pip install -e .

The installation can be verified, and it should display a path similar to the one below. Everything else is installed under the site-packages of the environment.

pip list | grep openbb
openbb                  4.1.7
openbb-benzinga 1.1.5
openbb-commodity 1.0.4
openbb-core 1.1.6
openbb-crypto 1.1.5
openbb-currency 1.1.5
openbb-derivatives 1.1.5
openbb-economy 1.1.5
openbb-empty-provider 0.0.1 /Users/username/path_to_created_folder/empty_provider
...

Build Static Assets

python -c "import openbb; openbb.build()"

The installation can be verified by inspecting obb.reference. Start a Python session and import the OpenBB Platform.

from openbb import obb

obb.reference["info"]["extensions"]["openbb_provider_extension"]

The list should include the newly created and installed extension, empty@0.0.1.

Conclusion

This process created, built, and installed a new OpenBB Platform Provider extension from scratch.

The next step is to create the models for connecting with the Provider Interface and Router.