mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 12:22:35 +00:00
Adds guide for SDK/Keys (#3111)
* Adds guide for SDK/Keys * Linter * Applied requested changes, and improved the examples. * Removed bullet point Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com>
This commit is contained in:
42
website/content/SDK/keys/_index.md
vendored
42
website/content/SDK/keys/_index.md
vendored
@@ -1,6 +1,42 @@
|
||||
---
|
||||
title: keys
|
||||
keywords: ""
|
||||
excerpt: ""
|
||||
title: API Keys
|
||||
keywords: "api,keys,key,secret,token,bearer,credentials,secrets,data,sources"
|
||||
excerpt: "This guide explains how to manage API keys within an OpenBB SDK environment."
|
||||
geekdocCollapseSection: true
|
||||
---
|
||||
The `keys` module provides the same functionality as the <a href="https://openbb-finance.github.io/OpenBBTerminal/#accessing-other-sources-of-data-via-api-keys" target="_blank"> Keys menu</a> does in the <a href="https://openbb-finance.github.io/OpenBBTerminal/terminal/" target="_blank">OpenBB Terminal</a>. Each data source requiring authentication will have slight differences of required inputs. Refer to the table <a href="https://openbb-finance.github.io/OpenBBTerminal/#accessing-other-sources-of-data-via-api-keys" target="_blank">here</a> for a compiled list of links for each data source.
|
||||
|
||||

|
||||
|
||||
## How to Use
|
||||
|
||||
Use Python's built-in `help` to print docstrings by entering, `help(openbb.keys.reddit)`. Alternatively, the contextual help window of a Jupyter session can be opened to view them.
|
||||
|
||||

|
||||
|
||||
Note that if `persist = False`, the credentials will not be retained in the local installation. Set as `persist = True` to apply them permanently to the local installation of the Terminal application, or SDK.
|
||||
|
||||
Expected values for all sources is printed with, `openbb.keys.get_keys_info()`, which describes what fields need to be included for each API.
|
||||
|
||||

|
||||
|
||||
Referencing the information above, they are then defined like, `openbb.keys.av(key='putyourkeyhere')`
|
||||
|
||||
A source with multiple inputs should be defined like, `openbb.keys.binance(key='apikeyhere', secret='thesecretstring')`
|
||||
|
||||
Code completion is activated after the `.` is added to `openbb.keys`. This provides a list which is browsable with the arrow keys.
|
||||
|
||||

|
||||
|
||||
Enter multiple keys by creating a list of dictionaries:
|
||||
|
||||

|
||||
|
||||
A simple CSV backup of all credentials can be made generated by utilizing Pandas DataFrame:
|
||||
````
|
||||
from openbb_terminal.sdk import openbb
|
||||
import pandas as pd
|
||||
|
||||
keys_backup = openbb.keys.mykeys(show = True)
|
||||
pd.DataFrame(keys_backup).to_csv('keys_backup.csv')
|
||||
````
|
||||
|
||||
Reference in New Issue
Block a user