Getting Started
Installation
$ pip install orats
Basic Usage
Direct API requests are particularly simple. For example, to access an endpoint from the Data API, all you need is the following snippet.
from orats.endpoints.data import api, request as req
data_api = api.DataApi(token="demo")
request = req.TickersRequest(ticker="IBM")
tickers = data_api.tickers(request)
for ticker in tickers:
assert isinstance(ticker, res.Ticker)
Have a look at the full list of available API constructs.
Note
You can also set a default token to avoid specifying your API token manually.
Setting a Default Token
If a token is not passed to the DataApi constructor,
the execution environment will be searched for a variable called ORATS_API_TOKEN.
If not token is found in the environment, the demo token will be used.
Warning
API tokens are sensitive! Avoid putting your token directly into source code.
Use of the ORATS_API_TOKEN variable is a recommended best practice.
When the environment is set properly, you can instantiate objects without a token.
from orats.endpoints.data import api, request as req
data_api = api.DataApi()
request = req.DailyPriceRequest(tickers=("IBM", "RIVN"))
prices = data_api.daily_price(request)
Note
The demo token is very restrictive. If you are running to an InsufficientPermissionsError,
make sure your token is available in the execution environment.