Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaslek committed Dec 17, 2024
1 parent 7f78bb4 commit 168ca27
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 53 deletions.
89 changes: 46 additions & 43 deletions content/terminal/custom-backend/custom-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

## Introduction to Custom Backend

The custom backend feature in OpenBB Terminal Pro allows users to integrate their own data sources and APIs into the platform. This enables the creation of personalized widgets that can display data from any API, whether hosted internally or externally. By using a standardized JSON configuration, users can expose their data as widgets in OpenBB. The custom backend allows users to take full advantage of the OpenBB Copilot and our interface.
The custom backend feature in OpenBB Terminal Pro allows users to integrate their own data sources and APIs into the platform. A custom backend is an API that returns JSON data with a standardized JSON configuration. This enables the creation of personalized widgets that can display data from any API, whether hosted internally or externally. By using a standardized JSON configuration, users can expose their data as widgets in OpenBB. The custom backend allows users to take full advantage of the OpenBB Copilot and our interface.

{/* TODO - make new video
import TutorialVideo from '@site/src/components/General/TutorialVideo.tsx';
Expand All @@ -36,44 +36,9 @@ import TutorialVideo from '@site/src/components/General/TutorialVideo.tsx';
/>
*/}

## Widget Types

OpenBB Terminal Pro supports various ways to visualize data through widgets. Each method offers unique features and can be configured to suit different data presentation needs. Below are the different visualization methods available:

1. **Table Widget**:
- Provides a structured view of data in rows and columns.
- Ideal for displaying detailed datasets.
- Can be configured to display charts with Native Charting.
- [Learn more about Table Widgets](Widgets/table/table.md)

<img className="pro-border-gradient" width="600" alt="table" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/simple-table.png" />


2. **Chart Widgets**:
- Offers graphical representation of data.
- Supports Plotly charts and can be configured to display different types of charts. Support for more charting frameworks will be coming soon.
- [Learn more about Chart Widgets](Widgets/chart.md)

<img className="pro-border-gradient" width="600" alt="chart" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/plotly-chart.png" />

3. **Markdown Widget**:
- Displays formatted text and images.
- Can be used to display markdown, txt, and docx files.
- [Learn more about Markdown Widgets](Widgets/markdown.md)

<img className="pro-border-gradient" width="600" alt="markdown" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/markdown-widget.png" />

4. **Metric Widget**:
- Displays a single value or metric.
- Useful for highlighting key performance indicators.
- [Learn more about Metric Widgets](Widgets/metric.md)

<img className="pro-border-gradient" width="600" alt="metric" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/metric-widget.png" />


## Design and implement your API

Choose your preferred programming language and framework. Ensure that the API returns data in JSON format.
You can build your API using any language and framework of your choice. The only requirements are that there must be endpoints returning data in JSON format, and that CORS is supported for OpenBB domains.

:::note
Guidelines for JSON Format:
Expand Down Expand Up @@ -117,12 +82,13 @@ The JSON should resemble the following structure:

:::

## Create your own backend
## Create your own custom backend

You can create your own backend by following these steps:

1. **Create a backend to return JSON data**: This can be done in any language. We will use Python and FastAPI in our examples.
Each backend will use the same setup and structure as below.
1. **Develop an API to return JSON data**: This can be done in any language. In our examples, we will use Python and FastAPI.
2.
Each backend will start with the same setup and structure as below. We enable CORS for OpenBB domains so that the backend can be accessed from the application, and we serve the `widgets.json` file from the backend.

<details>

Expand Down Expand Up @@ -180,17 +146,54 @@ An example structure in your backend might look like below.
└── widgets.json
```

3. **Create endpoints for each widgets.json entry**: Your `widgets.json` file lets OpenBB Terminal know how to display the data but you need to build out the endpoint to supply the data for each widget. Following the structure above, these endpoints would live in the `main.py` file.
1. **Create endpoints for each widgets.json entry**: Your `widgets.json` file lets the frontend know how to display your data, but you need to build out the endpoint to supply the data for each widget. Following the structure above, these endpoints would live in the `main.py` file.

4. **Connect to your API**: Once your API is up and running, you can add the custom backend using the OpenBB Terminal Pro interface. You will need to input your main endpoint and the system will read the `/widgets.json` endpoint to fetch all the necessary settings and configurations. Once connected, all the widgets will appear in your search and ready to be added to any dashboard.
2. **Connect to your API**: Once your API is up and running, you can add the custom backend using the OpenBB Terminal Pro interface. You will need to input your main endpoint and the system will read the `/widgets.json` endpoint to fetch all the necessary settings and configurations. Once connected, all the widgets will appear in your search and ready to be added to any dashboard.

<div style={{display: 'flex', justifyContent: 'center'}}>
<img className="pro-border-gradient" width="600" alt="folder" src="https://openbb-web-assets.s3.amazonaws.com/docs/launch_oct_24/backend.png" />
</div>


## Widget Types

OpenBB Terminal Pro supports various ways to visualize data through widgets. Each method offers unique features and can be configured to suit different data presentation needs. Below are the different visualization methods available:

1. **Table Widget**:
- Provides a structured view of data in rows and columns.
- Ideal for displaying detailed datasets.
- Can be configured to display charts with Native Charting.
- [Learn more about Table Widgets](Widgets/table/table.md)

<img className="pro-border-gradient" width="600" alt="table" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/simple-table.png" />


2. **Chart Widgets**:
- Offers graphical representation of data.
- Supports Plotly charts and can be configured to display different types of charts. Support for more charting frameworks will be coming soon.
- [Learn more about Chart Widgets](Widgets/chart.md)

<img className="pro-border-gradient" width="600" alt="chart" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/plotly-chart.png" />

3. **Markdown Widget**:
- Displays formatted text and images.
- Can be used to display markdown, txt, and docx files.
- [Learn more about Markdown Widgets](Widgets/markdown.md)

<img className="pro-border-gradient" width="600" alt="markdown" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/markdown-widget.png" />

4. **Metric Widget**:
- Displays a single value or metric.
- Useful for highlighting key performance indicators.
- [Learn more about Metric Widgets](Widgets/metric.md)

<img className="pro-border-gradient" width="600" alt="metric" src="https://openbb-assets.s3.us-east-1.amazonaws.com/docs/pro/metric-widget.png" />



### Examples

Our team has created several examples that you can use to quickly get started with Python and FastAPI. For more information, check [this open source repository](https://github.com/OpenBB-finance/backend-for-terminal-pro/tree/main) for examples.
Our team has created several examples that you can use to quickly get started with Python and FastAPI. For more information, check out [this open source repository](https://github.com/OpenBB-finance/backend-for-terminal-pro/tree/main).


## Frequently Asked Questions
Expand Down
31 changes: 21 additions & 10 deletions content/terminal/custom-backend/widgets.json.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,29 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

# Widgets.json Overview

The `widgets.json` file is essential for integrating custom widgets into the OpenBB Terminal Pro. It serves as a configuration file that connects your backend data to the widgets displayed in the application. Key components include:
The `widgets.json` file is your configuration file that connects custom backend data to the widgets displayed in the application. Key components include:

- **Basic Information**: Defines the widget's name, description, and API endpoint.
- **Categorization**: Organizes widgets using primary and secondary categories.
- **Display Settings**: Specifies visualization type and grid dimensions.
- **Data Configuration**: Details how data is displayed, including table and chart settings.
- **Parameters**: Lists configurable query parameters for the widget.
- **Data Source and Refresh Settings**: Identifies data sources and sets refresh intervals.
- **Basic Information**: Defines the widget's name, description, and API endpoint that the data comes from.
- **Metadata**: Provide categories for organization and AI enhancement.
- **Display Settings**: Specifies widget type and grid dimensions.
- **Data Configuration**: Details table and chart settings, including column level information and data types.
- **Parameters**: Details query parameters that can be passed to the API endpoint for customization.

The `widgets.json` file is the bridge between your backend and OpenBB Terminal widgets. Each entry in this file will directly map to a widget in the app. You can find examples [here](https://github.com/OpenBB-finance/backend-for-terminal-pro/tree/main).
Each entry in this file will directly map to a widget in the app. You can find example backends [here](https://github.com/OpenBB-finance/backend-for-terminal-pro/tree/main), where each folder contains a `widgets.json` file specifying the available widgets.

Below are all of the values you can set along with a description for each.
Below are all of the configurable fields and their descriptions. When you see a period in a field name (like `data.table.chartView.chartType`), it represents nested JSON objects. For example:

```json
{
"data": {
"table": {
"chartView": {
"chartType": "column"
}
}
}
}
```

| Name | **Type** | **Description** |
|------------------------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
Expand Down Expand Up @@ -82,7 +93,7 @@ Below are all of the values you can set along with a description for each.

## Example widgets.json

Below is an example `widgets.json` with a single widget defined. This widget will default to a column chart but have the ability to switch between a table and chart view.
Below is an example `widgets.json` with a single widget defined. This widget will default to a column chart but have the ability to switch between a table and chart view. The widget will have a start date parameter, a ticker parameter, and a colors parameter, all of which will be able to be selected on the widget in the application.

```json
{
Expand Down

0 comments on commit 168ca27

Please sign in to comment.