Files
OpenBB/website/content/sdk/guides/advanced/api-keys.md
Jeroen Bouma bc48e8051a Significantly update the API Keys documentation for the OpenBB Terminal and OpenBB SDK (#3780)
* Update guides to API Keys for the OpenBB Terminal

* Small updates

* Update OpenBB SDK API Key documentation

* Update with summary tags

* Update api-keys.md

* Update api-keys.md

* SDK Update

* Terminal Update

* Jamesiboy had a request

* And this file needed changing too

Co-authored-by: James Maslek <jmaslek11@gmail.com>
2022-12-16 09:11:43 -05:00

30 KiB
Vendored

title, sidebar_position
title sidebar_position
Set API Keys 1

Accessing API Keys

With the OpenBB SDK you can define your, often free, API key from various platforms like Alpha Vantage, FRED, IEX, Twitter, DeGiro, Binance and Coinglass. An API key is a set of random characters provided to you by a third party vendor that allows you to access data via their API endpoints. API keys can be managed directly from the SDK environment. If there is already a Terminal installation configured with API keys, they will be recognized by the SDK. Find the complete list of options below:

Summary of API Key Providers
Command Name URL
av AlphaVantage https://www.alphavantage.co/support/#api-key
binance Binance https://binance.com
bitquery Bitquery https://bitquery.io/
cmc CoinMarketCap https://coinmarketcap.com/api/
cb Coinbase https://help.coinbase.com/en/exchange/managing-my-account/how-to-create-an-api-key
coinglass Coinglass https://coinglass.github.io/API-Reference/#api-key
cpanic Crypto Panic https://cryptopanic.com/developers/api/
degiro DeGiro https://www.degiro.com/
eodhd EODHD https://eodhistoricaldata.com/
ethplorer Ethplorer https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API
finnhub Finnhub https://finnhub.io/
fmp Financial Modelling Prep https://site.financialmodelingprep.com/developer/docs/
fred Federal Reserve Economic Database (FRED) https://fred.stlouisfed.org
github GitHub https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api
glassnode Glassnode https://docs.glassnode.com/basic-api/api-key#how-to-get-an-api-key/
iex IEX Cloud https://iexcloud.io/
messari Messari https://messari.io/api/docs
news News API https://newsapi.org/
oanda Oanda https://developer.oanda.com
polygon Polygon https://polygon.io
quandl Quandl https://www.quandl.com
reddit Reddit https://www.reddit.com/wiki/api
rh Robinhood https://robinhood.com/us/en/
santiment Santiment https://app.santiment.net/
shroom ShroomDK https://sdk.flipsidecrypto.xyz/shroomdk
smartstake Smartstake https://www.smartstake.io
stocksera Stocksera https://stocksera.pythonanywhere.com/
tokenterminal Token Terminal https://tokenterminal.com/
tradier Tradier https://documentation.tradier.com/
twitter Twitter https://developer.twitter.com
si Sentiment Investor https://sentimentinvestor.com
walert Whale Alert https://docs.whale-alert.io/

Their status can be verified with the line of code below.

from openbb_terminal.sdk import openbb
openbb.keys.mykeys(show = True)

Removing show = True from the syntax will hide the values for the keys, as shown in the table below.

API Key
BINANCE_KEY *******
BINANCE_SECRET *******
BITQUERY_KEY *******
CMC_KEY *******

Individual keys are entered like this example:

obb.keys.fred(
    key = 'replace_me',
    persist = True,
)

The required fields for each source will vary, print the docstring for each to know the required inputs.

help(openbb.keys.reddit)
    Help on Operation in module openbb_terminal.core.library.operation:

    <openbb_terminal.core.library.operation.Operation object>
    Set Reddit key

    Parameters
    ----------
    client_id: str
        Client ID
    client_secret: str
        Client secret
    password: str
        User assword
    username: str
        User username
    useragent: str
        User useragent
    persist: bool
        If False, api key change will be contained to where it was changed. For example, Jupyter notebook.
        If True, api key change will be global, i.e. it will affect terminal environment variables.
        By default, False.
    show_output: bool
        Display status string or not. By default, False.

    Returns
    -------
    str
        Status of key set

In cases where API credentials must be passed to another process, use the following import statement:

from openbb_terminal import config_terminal as cfg

Values can then be passed to a request URL as a variable, f"{cfg.API_KEY_QUANDL}"

The code block below will authorize Quandl to request data from Nasdaq Data Link. The series in the example is for the historical price of gold.

import quandl
from openbb_terminal import config_terminal as cfg

gold = quandl.get("LBMA/GOLD", collapse="monthly", transform="", index_col=0, order="desc", parse_dates=True, authtoken=f"{cfg.API_KEY_QUANDL}")
Date USD (AM) USD (PM) GBP (AM) GBP (PM) EURO (AM) EURO (PM)
2022-11-30 00:00:00 1757.35 1768.9 1491.46 1506.57 1704.98 1714.06
2022-10-31 00:00:00 1638.85 1639 1419.74 1425.27 1649.5 1656.87
2022-09-30 00:00:00 1672.75 1671.75 1495.94 1502.4 1703.7 1710.53
2022-08-31 00:00:00 1712.4 1715.9 1472.15 1478.08 1713.6 1715.21
2022-07-31 00:00:00 1758.9 1753.4 1447.4 1451.64 1724.07 1725.7

To make a backup file containing all stored keys, use the code block below.

df_keys = openbb.keys.mykeys(show = True)
df_keys.to_csv('backup.csv')

How to obtain the API Key from each source

This section covers all API keys listed above and include detailed instructions how to obtain each API key. By clicking on each name, the section will expand and instructions are provided.

AlphaVantage

Go to https://www.alphavantage.co/support/#api-key. You will be greeted with the following screen:

image

Once you enter the type of investor you are, the organization you work at and your email address pressing "GET FREE API KEY" gets you the key that you can submit into the OpenBB SDK with openbb.keys.av

Binance Go to https://www.binance.com/en/support/faq/how-to-create-api-360002502072. You will be greeted with the following screen:

image

These instructions should provide clear guidance how to set up an API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.binance.

Bitquery

Go to https://bitquery.io/. You will be greeted with the following screen:

image

Click "Try GraphQL API". This opens the following screen:

image

After creating an account and verifying your email address, you will be able to access your API Key by clicking "Api Key". Enter this API key into the OpenBB SDK by typing openbb.keys.bitquery.

image

CoinMarketCap

Go to https://coinmarketcap.com/api. You will be greeted with the following screen:

image

From here, click "Get Your Free API Key Now". This opens up the following screen:

image

Once you have created an account, you will be able to find your API key in the following screen. Enter this API key into the OpenBB SDK by typing openbb.keys.cmc

image

CoinBase

Go to https://help.coinbase.com/en/exchange/managing-my-account/how-to-create-an-api-key. You will be greeted with the following screen:

image

By following these instructions you should be able to set-up an API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.coinbase.

Coinglass

Go to https://www.coinglass.com/. You will be greeted with the following screen:

image

Click "Log in" and sign up for an account. This opens up the following screen:

image

Once you created your account, you will be able to find the API Key on your profile. Enter this API key into the OpenBB SDK by typing openbb.keys.coinglass.

Crypto Panic

Go to https://cryptopanic.com/developers/api/. You will be greeted with the following screen:

image

Click "Sign up" under "Your free API auth token". This opens up the following screen:

image

Once you have created your account, your API Key will be displayed under "Your free API auth token". Enter this API key into the OpenBB SDK by typing openbb.keys.cpanic.

image

DeGiro

Go to https://www.degiro.com/. You will be greeted with the following screen:

image

Click "Sign up" and go to the registrations process. After setting up your account you will be able to use this broker by entering your username and password in the OpenBB SDK as follows openbb.keys.degiro. We also support 2FA, you can find more information about that here.

EODHD

Go to https://eodhistoricaldata.com/. You will be greeted with the following screen:

image

Click "Registration". This opens up the following screen:

image

Once you have registered, you can find the API Key next to "API TOKEN". Enter this API key into the OpenBB SDK by typing openbb.keys.cpanic.

image

Finnhub

Go to https://finnhub.io/. You will be greeted with the following screen:

image

Press "Get free api key". This opens up the following screen:

image

Once you have created an account, you will be able to find your API key in the following screen. Enter this API key into the OpenBB SDK by typing openbb.keys.finnhub

image

Financial Modelling Prep

Go to https://site.financialmodelingprep.com/developer/docs/. You will be greeted with the following screen:

image

From here, press "Get my API KEY here". This opens up the following screen:

image

If you already have an account, you can sign-in directly and obtain the API key, otherwise click "Sign Up". Once you have created an account you can access your API Key by pressing the "Dashboard" button which will show the API key. Enter this API key into the OpenBB SDK by typing openbb.keys.fmp

image

FRED

Go to https://fred.stlouisfed.org. You will be greeted with the following screen:

image

Click on "My Account". This opens up the following screen:

image

Once you have signed up, go to "My Account" and select "API Keys". This will get you to the following screen:

image

Click on "Request API Key" and fill in information about why you wish to use FRED. Then, by pressing "Request API key" you will be able to obtain the API key. Enter this API key into the OpenBB SDK by typing openbb.keys.fred

image

GitHub

Go to https://github.com/. You will be greeted with the following screen:

GitHub

Click "Sign up" and create an account with GitHub. Once you have done so go to as depicted below: https://github.com/settings/apps

image

Press "New GitHub App". This opens up the following screen:

image

Once the app is created you are able to obtain the API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.github.

Glassnode

Go to https://studio.glassnode.com/. You will be greeted with the following screen:

image

Click on "Sign up". This opens up the following screen:

image

After you have created your account, go to https://studio.glassnode.com/settings/api where you can create your API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.glassnode.

image

IEX Cloud

Go to https://iexcloud.io/. You will be greeted with the following screen:

image

Press "Sign in". This opens up the following screen:

image

Once you have signed up you are asked what kind of plan you would like. You have the option to start a free plan at the bottom.

image

Once you have confirmed you email address, you can find your API Key under "Access & Security". Enter this API key into the OpenBB SDK by typing openbb.keys.iex

image

Messari

Go to https://messari.io/. You will be greeted with the following screen:

image

Press "Sign up". This opens up the following screen:

image

Once you have signed up, go to https://messari.io/account/api where you will be able to find your API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.messari.

image

News API

Go to https://newsapi.org/. You will be greeted with the following screen:

image

Press "Get API Key". This opens up the following screen:

image

Register for an account. The next screen will provide you with the API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.news

image

Oanda

Go to https://developer.oanda.com. You will be greeted with the following screen:

image

After you have created an account with Oanda, you will be able to find the API key by following the steps below. After setting up your account you will be able to use this broker by entering your username and password in the OpenBB SDK as follows openbb.keys.oanda.

image

Polygon

Go to https://polygon.io. You will be greeted with the following screen:

image

Press the button "Get your Free API Key". This opens up the following screen:

image

Once signed up you will find the API Key at the bottom. Enter this API key into the OpenBB SDK by typing openbb.keys.polygon

image

Quandl

Go to https://www.quandl.com. You will be greeted with the following screen:

image

From here, click "Sign Up" at the top. This opens up the following screen:

image

Follow the sign-up instructions and once you have signed up you will be able to retrieve your API key. Enter this API key into the OpenBB SDK by typing openbb.keys.quandl

image

Reddit

Go to https://www.reddit.com/wiki/api. You will be greeted with the following screen:

image

Press "Read the full API terms and sign up for usage" and start the sign-up process. This opens up the following screen:

image

Once you have filled out everything, you will receive an email when your application is approved. Once this is approved you will receive the necessary information that needs to be entered in the OpenBB SDK. Enter these into the OpenBB SDK by typing openbb.keys.reddit.

Robinhood

Go to https://robinhood.com/us/en/. You will be greeted with the following screen:

image

Click "Sign up" and go to the registrations process. After setting up your account you will be able to use this broker by entering your username and password in the OpenBB SDK as follows openbb.keys.rh.

Santiment

Go to https://app.santiment.net/. You will be greeted with the following screen:

image

Click "Sign up". This opens up the following screen:

image

After creating an account go to https://app.santiment.net/account#api-keys and generate a key. Enter this API key into the OpenBB SDK by typing openbb.keys.santiment.

image

ShroomDK

Go to https://app.santiment.net/. You will be greeted with the following screen:

image

Click "Mint Your ShroomDK API Key" and sign up for an account. This opens up the following screen:

image

Once you have your account created, connect a wallet and access the API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.shroom.

image

Stocksera

Go to https://stocksera.pythonanywhere.com/. You will be greeted with the following screen:

image

Click "Log in" and create an account. This opens up the following screen:

image

Once you have created an account, go to "Developers" to access your API Key. Enter this API key into the OpenBB SDK by typing /openbb.keys.stocksera.

image

Token Terminal

Go to https://tokenterminal.com/. You will be greeted with the following screen:

image

Click "Log in" and sign up for an account. This opens up the following screen:

image

Once you have created an account, go to "API" to access your API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.tokenterminal.

image

Tradier

Go to https://documentation.tradier.com/. You will be greeted with the following screen:

image

Click the button "Open Account" and start the sign-up process. Once you have gone through the whole process you will be able to find your API key within your account. Enter this API key into the OpenBB SDK by typing openbb.keys.tradier

Twitter

Go to https://developer.twitter.com. You will be greeted with the following screen:

image

Click "Sign Up". Note that you are required to have a Twitter account and that you have verified your phone number. This opens up the following screen:

image

Create an account and verify your email. Then, you will be able to create an app to obtain your API Key.

image

This will give you the following keys. Enter these into the OpenBB SDK by typing openbb.keys.twitter.

image

Whale Alert

Go to https://docs.whale-alert.io/. You will be greeted with the following screen:

image

Click "sign up here". This opens up the following screen:

image

Once you have created your account, click "Create" to create your own API Key. Enter this API key into the OpenBB SDK by typing openbb.keys.walert.

image