How to get Alpha Vantage API key
To use Alpha Vantage API, you need an API key. Get it by registering on their website at:
https://www.alphavantage.co/support/#api-key
They have free and paid plans, subject to usage limits. The free plan allows maximum 500 API calls per day or 5 API calls per minute. Paid plans have no daily limits and much higher per-minute limits (the more expensive the plan, the more API calls per minute).
Alpha Vantage API key format
The API key is a string of random characters. For free plans, it usually has 16 characters, including uppercase letters and digits.
AV_API_KEY = 'BD167Z1D2D74NVWM' # not real
How to use Alpha Vantage API key
Once you have the API key, you must include it in the API request urls as the apikey
parameter.
For example, the following url gets daily historical data of the IBM stock, using the API key 'demo'
:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=IBM&apikey=demo
This url actually works. The 'demo'
API key only works with IBM stock though. For other symbols, you need to get your own API key.
Alpha Vantage API key errors
Using demo API key for non-demo dataset
If you use the 'demo'
API key for another symbol, you will not get the data. For example, this url (trying to get historical data for AAPL):
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=AAPL&apikey=demo
... will return this JSON result:
{ "Information": "The **demo** API key is for demo purposes only. Please claim your free API key at (https://www.alphavantage.co/support/#api-key) to explore our full API offerings. It takes fewer than 20 seconds." }
Missing or invalid API key
If you forget the apikey
parameter or use an invalid key, you get this error:
{ "Error Message": "the parameter apikey is invalid or missing. Please claim your free API key on (https://www.alphavantage.co/support/#api-key). It should take less than 20 seconds." }
To get your free API key go to: