{"id":7927,"library":"alpha-vantage","title":"Alpha Vantage Python Library","description":"The `alpha-vantage` library is a Python wrapper for the Alpha Vantage API, providing access to real-time and historical financial data, including stocks, cryptocurrencies, technical indicators, and economic data. The library is actively maintained, with the current version being 3.0.0, and receives regular updates.","status":"active","version":"3.0.0","language":"en","source_language":"en","source_url":"https://github.com/RomelTorres/alpha_vantage","tags":["finance","stocks","API","data","cryptocurrency","economic-indicators"],"install":[{"cmd":"pip install alpha-vantage","lang":"bash","label":"Install base package"},{"cmd":"pip install \"alpha-vantage[pandas]\"","lang":"bash","label":"Install with pandas support"}],"dependencies":[{"reason":"Often used for data manipulation and analysis; enables DataFrame output format. Not a hard dependency since v1.6.0.","package":"pandas","optional":true},{"reason":"Commonly used for plotting data fetched via the library in quickstart examples.","package":"matplotlib","optional":true}],"imports":[{"symbol":"TimeSeries","correct":"from alpha_vantage.timeseries import TimeSeries"},{"symbol":"DigitalCurrency","correct":"from alpha_vantage.cryptocurrencies import DigitalCurrency"},{"symbol":"FundamentalData","correct":"from alpha_vantage.fundamentaldata import FundamentalData"}],"quickstart":{"code":"import os\nfrom alpha_vantage.timeseries import TimeSeries\nimport pandas as pd\n\n# Get your Alpha Vantage API key from environment variable or replace 'YOUR_API_KEY'\n# Register for a free API key at https://www.alphavantage.co/support/#api-key\napi_key = os.environ.get('ALPHAVANTAGE_API_KEY', 'YOUR_API_KEY')\n\nif api_key == 'YOUR_API_KEY':\n    print(\"Warning: Please replace 'YOUR_API_KEY' with your actual Alpha Vantage API key or set the ALPHAVANTAGE_API_KEY environment variable.\")\n    print(\"You can get a free API key at: https://www.alphavantage.co/support/#api-key\")\n    exit()\n\ntry:\n    # Initialize TimeSeries with your API key and set output format to pandas DataFrame\n    ts = TimeSeries(key=api_key, output_format='pandas')\n\n    # Get daily adjusted time series for a symbol (e.g., IBM)\n    print(\"Fetching daily adjusted data for IBM...\")\n    data, meta_data = ts.get_daily_adjusted(symbol='IBM', outputsize='compact')\n\n    print(\"\\n--- Daily Adjusted Data (last 5 rows) ---\")\n    print(data.tail())\n\n    # Get real-time global quote for a symbol\n    print(\"\\nFetching global quote for AAPL...\")\n    global_quote, meta_global_quote = ts.get_global_quote(symbol='AAPL')\n\n    print(\"\\n--- Global Quote for AAPL ---\")\n    # The global_quote result is usually a dictionary, not a DataFrame for single quotes\n    # Convert to DataFrame for consistent printing, if it's a dict (which it often is for single quote)\n    if isinstance(global_quote, dict):\n        print(pd.DataFrame([global_quote]))\n    else:\n        print(global_quote)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure your API key is correct and you are not exceeding rate limits (5 calls/minute for free tier).\")","lang":"python","description":"This quickstart demonstrates how to initialize the `TimeSeries` object with an API key (preferably from an environment variable) and fetch daily adjusted stock data and a real-time global quote, displaying the output using pandas DataFrames. Ensure you have `pandas` installed for DataFrame output."},"warnings":[{"fix":"Implement proper rate limiting and exponential backoff in your code. For higher call volumes, consider a premium Alpha Vantage plan. Store your API key as an environment variable (ALPHAVANTAGE_API_KEY) to avoid hardcoding.","message":"The free Alpha Vantage API key has strict rate limits, typically 5 calls per minute and 500 calls per day. Exceeding these limits will result in API errors or blocked access. Some user reports indicate stricter limits (e.g., 25/day) in certain scenarios.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the official Alpha Vantage API documentation for updated endpoints and alternative data sources if your application relies on these deprecated features. Adjust your code to use new or existing supported functions.","message":"As of version 3.0.0, several data endpoints have been deprecated. Specifically, 'All sector performance, extended intraday, and the FCAS crypto rating have been deprecated.' This means functions related to these services will no longer work or return data.","severity":"breaking","affected_versions":"3.0.0+"},{"fix":"For free API keys, use `outputsize='compact'` which returns the latest 100 data points. To access full historical data, a premium Alpha Vantage membership is required.","message":"The `outputsize='full'` parameter for historical time series data (e.g., `get_daily_adjusted`) is a premium feature. Using it with a free API key will result in an 'Invalid API call' error message from the Alpha Vantage API.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update your code to account for the exact column names returned by the API. If migrating old code, verify the expected column names in your data processing logic.","message":"Prior to version 1.8.0, the library might have modified column names (e.g., removing numbers like '4. close' to 'close'). From version 1.8.0 onwards, DataFrame column names precisely match the JSON response from the Alpha Vantage API. This can break older code expecting simplified names.","severity":"gotcha","affected_versions":"<1.8.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Double-check the symbol and parameters against the Alpha Vantage API documentation. Ensure your API key supports the requested feature. For historical data, try `outputsize='compact'` if using a free key. Confirm the API key is correctly provided to the library.","cause":"This error typically occurs when an invalid symbol or an unsupported function/parameter is used, or when attempting to access a premium feature (like `outputsize='full'`) with a free API key.","error":"ValueError: Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for <FUNCTION_NAME>."},{"fix":"Verify your API key is correct and active. Check the symbol for typos or if it's supported by Alpha Vantage. Ensure you are not exceeding the API call limits (5 calls/minute for free tier). Inspect the raw JSON response if possible to diagnose the missing key.","cause":"This usually indicates that the API response did not contain the expected 'Time Series (Daily)' key, often due to an invalid API key, an incorrect symbol, or hitting API rate limits, leading to an empty or malformed response from the Alpha Vantage API.","error":"KeyError: 'Time Series (Daily)'"},{"fix":"Obtain a new API key from the Alpha Vantage website. Double-check that the API key is copied and pasted correctly without extra spaces or characters. Ensure it's correctly passed to the `TimeSeries` (or other client) constructor, or set as the `ALPHAVANTAGE_API_KEY` environment variable.","cause":"The Alpha Vantage API key provided is invalid, expired, or has insufficient permissions for the requested data.","error":"Could not authenticate. Please check your credentials."}]}