alpyvantage#

An alternative python backend to the Alpha Vantage API

https://img.shields.io/badge/GitHub-gboehl%2Falpyvantage-blue.svg?style=flat https://readthedocs.org/projects/alpyvantage/badge/?version=stable https://badge.fury.io/py/alpyvantage.svg https://github.com/gboehl/alpyvantage/actions/workflows/continuous-integration.yml/badge.svg

alpyvantage provides a python backend to the Alpha Vantage API. Alpha Vantage provides access to a wide range of financial data and time series. Details can be found in the official API documentation. You can get a free API key here.

Installation#

Installing the repository version is as simple as typing

pip install alpyvantage

in your terminal or Anaconda Prompt.

Documentation#

API calls are straightforward. Either use the build-in functions such as time_series_intraday, time_series_weekly, etc.:

import alpyvantage as av

api = av.API(<your_api_key>)

data, meta_data = api.time_series_intraday('DAX', interval='1min', month='2015-01')

print(data) # its a pandas.DataFrame

Or use the function keyword from the official API documentation and provide the parameters as keyword arguments:

data, meta_data = api('TIME_SERIES_INTRADAY', symbol='DAX', interval='1min', month='2015-01')

A detailed documentation of the individual functions can be found here.

Issues and contributions#

Please use the issues for questions or if you think anything doesn’t do what it is supposed to do. Pull requests are welcome, please include some documentation.

Functions#

class alpyvantage.API(api_key, to_pandas=True, outputsize='full')#

Base class storing the API key and some options

Parameters:
  • api_key (string) – the API key as a string

  • to_pandas (bool, optional) – whether to return time series as pandas.DataFrame, True by default

  • outputsize (bool, optional) – return full output by default for any call

time_series_intraday(symbol, interval='1min', **kwargs)#

API call to TIME_SERIES_INTRADAY

Parameters:
  • symbol (string) – the ticker symbol

  • interval (string, optional) – data frequency, defaults to ‘1min’. See the original Alpha Vantage documentation (https://www.alphavantage.co/documentation/) for options.

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict or pandas.DataFrame) – the requested data

  • meta_data (None or dict) – the meta data if data is a DataFrame

time_series_daily(symbol, **kwargs)#

API call to TIME_SERIES_DAILY

Parameters:
  • symbol (string) – the ticker symbol

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict or pandas.DataFrame) – the requested data

  • meta_data (None or dict) – the meta data if data is a DataFrame

time_series_daily_adjusted(symbol, **kwargs)#

API call to TIME_SERIES_DAILY_ADJUSTED

Parameters:
  • symbol (string) – the ticker symbol

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict or pandas.DataFrame) – the requested data

  • meta_data (None or dict) – the meta data if data is a DataFrame

time_series_weekly(symbol, **kwargs)#

API call to TIME_SERIES_WEEKLY

Parameters:
  • symbol (string) – the ticker symbol

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict or pandas.DataFrame) – the requested data

  • meta_data (None or dict) – the meta data if data is a DataFrame

time_series_weekly_adjusted(symbol, **kwargs)#

API call to TIME_SERIES_WEEKLY_ADJUSTED

Parameters:
  • symbol (string) – the ticker symbol

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict or pandas.DataFrame) – the requested data

  • meta_data (None or dict) – the meta data if data is a DataFrame

time_series_monthly(symbol, **kwargs)#

API call to TIME_SERIES_MONTHLY

Parameters:
  • symbol (string) – the ticker symbol

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict or pandas.DataFrame) – the requested data

  • meta_data (None or dict) – the meta data if data is a DataFrame

time_series_monthly_adjusted(symbol, **kwargs)#

API call to TIME_SERIES_MONTHLY_ADJUSTED

Parameters:
  • symbol (string) – the ticker symbol

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict or pandas.DataFrame) – the requested data

  • meta_data (None or dict) – the meta data if data is a DataFrame

quote_endpoint(symbol, **kwargs)#

API call to GLOBAL_QUOTE

Parameters:
  • symbol (string) – the ticker symbol

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict) – the requested data

  • meta_data (None) – placeholder for consistency

API call to SYMBOL_SEARCH

Parameters:
  • keywords (string) – the ticker keyword(s)

  • kwargs (dict) – any other optional keyword(s)

Returns:

  • data (dict) – the requested data

  • meta_data (None) – placeholder for consistency

global_market_status()#

API call to MARKET_STATUS

Returns:

  • data (dict) – the requested data

  • meta_data (None) – placeholder for consistency

exception alpyvantage.AlphaVantageError#