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 (str or None) – Default None. Where to save csv file if datatype="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
  • symbol (str) –
    Company ticker symbol, such as "GOOGL".
  • interval (str) –
    "1min", "5min", "15min", "30min" or "60min". Also "daily", "weekly", "monthly"
  • outputsize (str) –
    "compact" (default) or "full"
  • datatype (str) –
    "json" (default) or "csv"
  • apikey (str) –
    You need to get a free API key from Alpha Vantage

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 returned
Return type:dict [str, float]

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 data
Returns:Returns the converted dictionary as a Pandas data frame
Return type:pandas.DataFrame()

Unexpected results

When you get unexpected results, you might want to check out the latest raw response from the Alpha Vantage server.


avapi.response()

Opens and reads last response from Alpha Vantage server.

Returns:Content of response.
Return type:str