Skip to content

Commit

Permalink
make some updates for when 4.4 is released
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Jan 23, 2025
1 parent e4cd380 commit 7b8612e
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 57 deletions.
2 changes: 1 addition & 1 deletion content/cli/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

<HeadTitle title="Configuration & Settings - | OpenBB Platform CLI Docs" />

In addition to the OpenBB Platform's `user_settings.json` file, described [here](/platform/user_guides/settings_and_environment_variables), there are settings and environment variables affecting the CLI only.
In addition to the OpenBB Platform's `user_settings.json` file, described [here](/platform/settings_and_environment_variables), there are settings and environment variables affecting the CLI only.

:::important
API credentials are defined in the `user_settings.json` file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Authorization and API Keys
sidebar_position: 2
title: API Keys & Credentials
sidebar_position: 3
description: An overview for setting up the OpenBB Platform Python client and Fast API with data provider API keys.
keywords:
- tutorial
Expand All @@ -17,7 +17,7 @@ keywords:

import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

<HeadTitle title="API Keys - Usage | OpenBB Platform Docs" />
<HeadTitle title="API Keys & Credentials | OpenBB Platform Docs" />

By default, authorization is not required to initialize and use the core services. Most data providers, however, require an API key to access their data. Keys can be stored locally and they can also be securely saved to your OpenBB Hub [account](https://my.openbb.co/app/hub) for convenient remote access.

Expand Down Expand Up @@ -79,7 +79,7 @@ Credentials and user preferences are stored locally, `~/.openbb_platform/`, as a
"tradier_account_type": "sandbox OR live",
"tradingeconomics_api_key": "REPLACE",
"tiingo_token": "REPLACE"
}
}
}
```

Expand All @@ -88,3 +88,9 @@ To set keys from the Python client for the current session only, access the Cred
```python
obb.user.credentials.intrinio_api_key = "my_api_key"
```

:::info
See [User Settings & Environment Variables](settings_and_environment_variables) for more information on configuring the installation via `user_settings.json`.

See [Extensions](user_guides/extensions) for a current list of data provider extensions.
:::
2 changes: 1 addition & 1 deletion content/platform/developer_guide/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Developer Guide",
"position": 3
"position": 5
}
6 changes: 4 additions & 2 deletions content/platform/developer_guide/architecture_overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ The class can have a dictionary, `__alias_dict__`, which can be used to map the

The `__json_schema_extra__` dictionary can be used to define whether multiple items are accepted by a parameter.

Additionally, "choices", is a list of accepted vales for the parameter. Adding them here ensures they are included in `openapi.json`.

``` python
__json_schema_extra__ = {
"symbol": ["multiple_items_allowed"],
"category": ["multiple_items_allowed"],
"symbol": {"multiple_items_allowed": True, "choices": SOME_SYMBOL_LIST},
"category": {"multiple_items_allowed": False}, # No need to define this, it is the default behaviour.
}
```

Expand Down
112 changes: 112 additions & 0 deletions content/platform/developer_guide/disabling_output_validation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: Disabling Output Validation
sidebar_position: 4
description: This page provides instructions for disabling output validation, when defining a new router function.
keywords:
- Validation
- Pydantic
- Python
- Development
- OpenBB Platform
- Provider Interface
- Router
- Custom
- Commands
- FastAPI
- extensions
---

import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

<HeadTitle title="Disabling Output Validation - Developer Guides | OpenBB Platform Docs" />

In some cases, it may be desirable to disable output validation for a custom router endpoint.
The example below demonstrates how to do it within your own custom router path.

:::important
This section refers to settings available beginning OpenBB v4.4.0
:::

In boths functions, the output will be typed as "Any", regardless of what the `return` definition states.

Within the `@router.command` decorator, add the keyword argument:

```python
no_validate = True
```

## Example

This example assumes that ficticious extensions have been defined and installed.

```python
from datetime import datetime

from openbb_core.app.model.command_context import CommandContext
from openbb_core.app.model.example import APIEx, PythonEx
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.provider_interface import (
ExtraParams,
ProviderChoices,
StandardParams,
)
from openbb_core.app.query import Query
from openbb_core.app.router import Router
from openbb_core.provider.abstract.data import Data

router = Router(prefix="", description="Some OpenBB Router Extension.")

# This uses the Provider Interface.
@router.command(
model="SomeModel",
no_validate=True,
examples=[
APIEx(parameters={"provider": "some_provider"}),
PythonEx(
description="Say Hello.",
code=[
"result = obb.some_extension.some_provider_function()",
],
),
],
)
async def some_provider_function(
cc: CommandContext,
provider_choices: ProviderChoices,
standard_params: StandardParams,
extra_params: ExtraParams,
) -> OBBject[Data]:
"""Some function using the Provider Interface."""
obbject = await OBBject.from_query(Query(**locals()))

new_output = []
results = obbject.results

# Do something with results and append to `new_output` list.

return new_output


# This is a standard router "get" command.
@router.command(
methods=["GET"],
no_validate=True
examples=[
PythonEx(
description="Say Hello.",
code=[
"result = obb.some_extension.hello()",
],
),
],
)
async def hello() -> (
Any
):
"""Hello World."""
return {
datetime.now().strftime(
"%Y-%m-%d"
): "Hello from the Empty Router extension!"
}
```
4 changes: 4 additions & 0 deletions content/platform/developer_guide/http_requests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Any function fetching data requires making an outbound HTTP request. Utility fun

Using the helpers will keep the codebase leaner and easier to maintain by eliminating duplicate processes. Anyone can build effective and efficient data fetchers, this guide outlines how to import and implement either type of request into any fetcher.

:::info
See [Environment Variables & Settings](/platform/settings_and_environment_variables#http) for information on configuring global settings and the session object.
:::

## Generate Query String

To pass parameters to a URL, they need to be formatted as a query string. The helper function, `get_querystring()`, converts a dictionary of parameters to a standard query URL string.
Expand Down
2 changes: 1 addition & 1 deletion content/platform/developer_guide/obbject.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: OBBject
sidebar_position: 4
sidebar_position: 3
description: This page provides information about the OBBject class in the OpenBB Platform. This class provides the interface to interact with commands
keywords:
- OBBject
Expand Down
6 changes: 3 additions & 3 deletions content/platform/developer_guide/standardization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Standardizing provider query parameters and response data enhances the user expe
- Transparently defined schemas for the data and query parameters.
- Outputs from multiple sources are comparable with each other and easily interchanged.

The standard models are all defined in the `/OpenBBTerminal/openbb_platform/core/openbb_core/provider/standard_models/` [directory](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_platform/core/openbb_core/provider/standard_models).
The standard models are all defined in the `/OpenBB/openbb_platform/core/openbb_core/provider/standard_models/` [directory](https://github.com/OpenBB-finance/OpenBB/tree/main/openbb_platform/core/openbb_core/provider/standard_models).

### What Is A Standard Model?

Every standard model consists of two classes, with each being a Pydantic model.

- [`QueryParams`](https://raw.githubusercontent.com/OpenBB-finance/OpenBBTerminal/main/openbb_platform/core/openbb_core/provider/abstract/query_params.py)
- [`Data`](https://raw.githubusercontent.com/OpenBB-finance/OpenBBTerminal/main/openbb_platform/core/openbb_core/provider/abstract/data.py)
- [`QueryParams`](https://raw.githubusercontent.com/OpenBB-finance/OpenBB/main/openbb_platform/core/openbb_core/provider/abstract/query_params.py)
- [`Data`](https://raw.githubusercontent.com/OpenBB-finance/OpenBB/main/openbb_platform/core/openbb_core/provider/abstract/data.py)

Any parameter or field can be assigned a custom `field_validator`, or the entire model can be passed through a `model_validator` on creation.

Expand Down
12 changes: 12 additions & 0 deletions content/platform/faqs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ import HeadTitle from "@site/src/components/General/HeadTitle.tsx";

<HeadTitle title="FAQs | OpenBB Platform Docs" />


<details>
<summary mdxType="summary">Endpoints that are displayed in this documentation are not found when I try to use them.</summary>

The [Reference](/platform/reference) pages are created from the contents of our GitHub [repo](https://github.com/OpenBB-finance/OpenBB), and may not match your installation.

If a router/endpoint appears to be missing from your installation, it is quite likely that it is not installed. It may also be that the functions are served by provider extensions that require API keys. The function will not be added to the application unless a value has been supplied, or there is another provider which does not require authorization.

See the page [here](/platform/user_guides/extensions) for a current list of data provider extensions.

</details>

<ul className="grid grid-cols-1 gap-4 -ml-6">
<NewReferenceCard
title="What's the Difference Between OpenBB SDK and Platform?"
Expand Down
2 changes: 1 addition & 1 deletion content/platform/getting_started/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Getting Started",
"position": 2
"position": 3
}
5 changes: 5 additions & 0 deletions content/platform/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ With its ready-to-use data connectors and a wealth of extensions, it lets you co
## Documentation Structure

<ul className="grid grid-cols-1 gap-2 -ml-6">
<NewReferenceCard
title="Installation"
description="Instructions for installation."
url="platform/installation"
/>
<NewReferenceCard
title="Getting Started"
description="Short goal-oriented examples to help users achieve specific tasks."
Expand Down
Loading

0 comments on commit 7b8612e

Please sign in to comment.