Reference¶
AVAPI is a simple python wrapper for the Alpha Vantage API. AVAPI has one
module: avapi.data. It handles getting and manipulating data from Alpha Vantage.
Getting the data¶
If csv=True, a csv file will be saved in current working directory.
Otherwise, avapi.data.get_data() will return a dictionary of Alpha Vantage
data.
-
avapi.get_data(save_to=None, **kwargs)¶ Downloads a json file from Alpha Vantage.
Parameters: - save_to (
strorNone) – Default None. Where to save csv file ifdatatype="csv"is provided. - **kwargs – See below
Keyword Arguments: - function (
str) – - Any of the Alpha Vantage function types. Such as
"TIME_SERIES_INTRADAY". See their documentation
- function (
- symbol (
str) – - Company ticker symbol, such as
"GOOGL".
- symbol (
- interval (
str) – "1min","5min","15min","30min"or"60min". Also"daily","weekly","monthly"
- interval (
- outputsize (
str) – "compact"(default) or"full"
- outputsize (
- datatype (
str) – "json"(default) or"csv"
- datatype (
- apikey (
str) – - You need to get a free API key from Alpha Vantage
- apikey (
The above list is not exhaustive. Please see Alpha Vantage docs for complete listing and what fuction requires which keyword arguments.
Returns: If datatype is not set to "csv", a dictionary is returnedReturn type: dict[str,float]- save_to (
Converting dictionary to pandas.DataFrame¶
When avapi.get_data(csv=False) downloads data, it converts the Alpha Vantage
server response from json to python dict. If the data type is a time series,
avapi.to_df() can then convert it to a Pandas data frame.
-
avapi.to_df(dic)¶ Converts data dictionary, downloaded from Alpha Vantage, to pandas dataframes.
Parameters: dic ( dict[str,float]) – Python dictionary of Alpha Vantage time series dataReturns: Returns the converted dictionary as a Pandas data frame Return type: pandas.DataFrame()