Clarify API Usage in Docs

This commit is contained in:
Cameron Yick
2017-08-27 00:53:06 -04:00
parent d490fd3841
commit 91900fac0d
2 changed files with 61 additions and 25 deletions

View File

@@ -39,7 +39,8 @@ First, install the library from PyPi:
pip install tiingo
Now you can use the TiingoClient to make your API calls. (Other parameters are available for each endpoint beyond what has been written below, see docs for full details.)
Next, initialize your client object. It is recommended to use an environment
variable to initialize your client object for convenience.
.. code-block:: python
@@ -47,10 +48,27 @@ Now you can use the TiingoClient to make your API calls. (Other parameters are a
# Set TIINGO_API_KEY in your environment variables in your .bash_profile, OR
# pass a dictionary with 'api_key' as a key into the TiingoClient.
# With environment variable
client = TiingoClient()
# With hardcoded dictionary key
client = TiingoClient({'api_key': "MY_SECRET_API_KEY"})
Alternately, you may use a dictionary to customize/authorize your client.
.. code-block:: python
config = {}
# To reuse the same HTTP Session across API calls (and have better performance), include a session key.
config['session'] = True
# If you don't have your API key as an environment variable,
# pass it in via a configuration dictionary.
config['api_key'] = "MY_SECRET_API_KEY"
# Initialize
client = TiingoClient(config)
Now you can use ``TiingoClient`` to make your API calls. (Other parameters are available for each endpoint beyond what has been written below, see the Tiingo website for full details).
.. code-block:: python
# Get Ticker
# See official docs for list of all supported tickers + date ranges
@@ -69,6 +87,7 @@ Now you can use the TiingoClient to make your API calls. (Other parameters are a
# Get news articles about given tickers or search terms from given domains
# Coming soon!
Further Docs
--------

View File

@@ -6,7 +6,9 @@ To use Tiingo Python in a project::
import tiingo
Now you can use the ``TiingoClient`` to make your API calls. (Other parameters are available for each endpoint beyond what has been written below, see docs for full details.)
Next, initialize your client object. It is recommended to use an environment
variable to initialize your client object for convenience.
.. code-block:: python
@@ -14,11 +16,26 @@ Now you can use the ``TiingoClient`` to make your API calls. (Other parameters a
# Set TIINGO_API_KEY in your environment variables in your .bash_profile, OR
# pass a dictionary with 'api_key' as a key into the TiingoClient.
# With environment variable
client = TiingoClient()
# With hardcoded dictionary key
client = TiingoClient({'api_key': "MY_SECRET_API_KEY"})
Alternately, you may use a dictionary to customize/authorize your client.
.. code-block:: python
config = {}
# To reuse the same HTTP Session across API calls (and have better)
# performance, include a session key.
config['session'] = True
# If you don't have your API key as an environment variable,
# pass it in via a configuration dictionary.
config['api_key'] = "MY_SECRET_API_KEY"
# Initialize
client = TiingoClient(config)
Now you can use ``TiingoClient`` to make your API calls. (Other parameters are available for each endpoint beyond what has been written below, see the Tiingo website for full details).
.. code-block:: python
# Get Ticker
# See official docs for list of all supported tickers + date ranges
ticker_metadata = client.get_ticker_metadata("GOOGL")