-
Notifications
You must be signed in to change notification settings - Fork 3
Direct Access to API
The Alpha Vantage API responses vary from end point to end point. This client provides a top level consistent data structure so your code can be as clean as possible. However, you may want direct access to the alpha vantage api thus having minimal manipulation of your responses. You can achieve this by using the client.get_data_from_alpha_vantage(...)
.
This method does inject a few fields: successs
, limit_reached
, status_code
and gives you exact response from the API. Here is a full example:
from alphavantage_api_client import AlphavantageClient
import logging
def sample_direct_access():
client = AlphavantageClient()
event = {
"symbol" : "AAPL",
"function" : "GLOBAL_QUOTE"
} # EACH ATTRIBUTE IS EXACTLY SUPPORTED BY END POINTS
response = client.get_data_from_alpha_vantage(event)
print(response) # a dictionary with exact response from Alpha Vantage End point you requested
if __name__ == "__main__":
sample_direct_access()
Produces the following output
{'success': True, 'limit_reached': False, 'status_code': 200, 'Global Quote': {'01. symbol': 'AAPL', '02. open': '186.8300', '03. high': '188.0500', '04. low': '185.2300', '05. price': '185.2700', '06. volume': '48088661', '07. latest trading day': '2023-06-26', '08. previous close': '186.6800', '09. change': '-1.4100', '10. change percent': '-0.7553%'}, 'symbol': 'AAPL'}
Process finished with exit code 0
You can see that this function injects a few fields into the response success
, limit_reached
, and status_code
, so you can easily determine these conditions.
Simple python wrapper around alpha vantage api, provide consistency across end points, debug easily and get the most out of your free account!