AVAPI
Get data from Alpha Vantage into python.
Authors:
- Ole Olaussen: ole.olaussen@ekkobit.com
- Xuan Ling: xuan.ling@ekkobit.com
Documentation
For more complete documentation, please go to ReadTheDocs.
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.
Installation
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.
Examples
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)
df.head()
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',
},
{
'function':'TIME_SERIES_INTRADAY',
'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)
sleep(15)
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()
print(response)
Contribute
- Issue Tracker: https://github.com/ekkobit/avapi/issues
- Source Code: https://github.com/ekkobit/avapi
- Documentation: https://avapi.readthedocs.io
Metadata
Release files for avapi 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| avapi-0.1.6.tar.gz | 4.1 kB | Without provenance | Details for avapi-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| avapi-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for avapi-0.1.6-py3-none-any.whl |
Total release size: 9.4 kB
Release files / avapi-0.1.6.tar.gz
| Download URL | avapi-0.1.6.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bdab7e1acf6902f9f19eddd35ffb62bd08bed3ad93e66dd5f2cc29b63d996e6
|
|
BLAKE2b-256 checksum How to use checksums |
c65326b149b012616e47d6242f07aa799a7a49c1d7b3ffaf62c377869280937b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Release files / avapi-0.1.6-py3-none-any.whl
| Download URL | avapi-0.1.6-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f0099f00c18881af4b07c338e2b7716bf146c2272cf92a81e22b2f589ca0586
|
|
BLAKE2b-256 checksum How to use checksums |
c389b135b0792cd30cb4b9ea7ffae0c3ef42df75de327896f6ece31d5e15ed10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for avapi 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.