Skip to main content

Get data from Alpha Vantage into python.

Project description


Get data from Alpha Vantage into python.


Ole Olaussen:


There are other python wrappers for the alpha vantage API, such as alphavantage, alpha-vantage-downloader, alpha_vantage and alphavantage-wrapper. They all have in common that they have different functions for each of the data types that Alpha Vantage offers. This may be less practical when downloading multiple data types at multiple resolutions in one session. Avapi has a single function that can download any data type from Alpha Vantage: avapi.get_data() takes **kwargs as input and outputs a dictionary, unless datatype="csv" is given, in which case a csv file is saved. If the data type is time series, avapi.to_df() converts it to a Pandas data frame. The intention is a simple and flexible way to get data from Alpha Vantage into python.


pip install avapi

Before use

Follow instructions on the Alpha vantage website to get a free API-key. The docs provide all necessary info for à la carte downloading of historical data and indicators. Please checkout Alpha Vantage support and read through the Frequently Asked Questions.


The "demo" api-key only works for these specific examples. If you modify the code you also need to provide your own api-key.

Single download
import avapi as aa
import pandas as pd

data = aa.get_data(function='VWAP', symbol='MSFT',
                   interval='15min', apikey='demo')

df = aa.to_df(data)
Multiple files download

There are limits for free accounts: up to 5 API requests per minute and 500 requests per day. In loops, if you don't incorporate time.sleep(), you might get errors.

import avapi as aa
import pandas as pd
from time import sleep

data_path = 'data/'

data_calls = [

 'function': 'TIME_SERIES_DAILY',
 'symbol': 'MSFT',
 'apikey': 'demo',
 'datatype': 'csv',
 'symbol': 'MSFT',
 'interval': '5min',
 'apikey': 'demo',
 'datatype': 'csv',


for call in data_calls:
    save_to = data_path + call['function'] + '_' + call['symbol'] + '.csv'
    data = aa.get_data(save_to=save_to, **call)
Unexpected results

If you get unexpected results, you may check the latest, original response from the Alpha Vantage server in the following way:

response = aa.response()


  • Issue 1 - Fulfill Alpha Vantage's request to preserve content of JSON/CSV responses in both success and error cases.
  • Issue 2 - Make get_data() work with **kwargs.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for avapi, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size avapi-0.1.3.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View
Filename, size avapi-0.1.3-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page