From a6fcb9d47e10fb3a9e0926467f2311d013869d4a Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Mon, 31 Oct 2022 15:46:41 -0700 Subject: [PATCH] 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 --- website/content/SDK/keys/_index.md | 42 +++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/website/content/SDK/keys/_index.md b/website/content/SDK/keys/_index.md index a6c7f46c118..3e23071075d 100644 --- a/website/content/SDK/keys/_index.md +++ b/website/content/SDK/keys/_index.md @@ -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 Keys menu does in the OpenBB Terminal. Each data source requiring authentication will have slight differences of required inputs. Refer to the table here for a compiled list of links for each data source. + +![openbb.keys.mykeys()](https://user-images.githubusercontent.com/85772166/198151758-7fdf1e00-29c2-4fb1-bfb1-7421cc9b8986.png) + +## 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. + +![Contextual Help](https://user-images.githubusercontent.com/85772166/198360190-753d4fd8-768a-4de6-9c24-44491804914f.png) + +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. + +![get_keys_info](https://user-images.githubusercontent.com/85772166/198151924-08f97592-08ce-4631-b333-0f6568124874.png) + +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. + +![Code Completion](https://user-images.githubusercontent.com/85772166/198151847-a09e9589-43b8-4c40-9cd1-be18092a8004.png) + +Enter multiple keys by creating a list of dictionaries: + +![Multiple Keys](https://user-images.githubusercontent.com/85772166/198152166-94ed3544-a03a-4790-9b4a-c76f2419e3d5.png) + +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') +````