Alpha Vantage pulling data from income statement library using python

1.8k Views Asked by At

apologies for noobie question but I am completely lost on how to get any data from the Fundamental Data library in Alpha Vantage. I just started learning to code this month >.<

For example, if I wanted to get 'totalRevenue' from the most recent quarterly report. https://www.alphavantage.co/query?function=INCOME_STATEMENT&symbol=IBM&apikey=demo

I was able to find an answer online on how to get requests from the Time series. I did the following

import pandas as pd
from alpha_vantage.timeseries import TimeSeries
import time
import random
import math
import datetime as dt

ts = TimeSeries (key='apikey', output_format = "pandas")

stock_ticker = "MSFT"

data_daily, meta_data = ts.get_daily_adjusted(symbol=stock_ticker, outputsize ='compact')

last_adjusted_price = data_daily['5. adjusted close'][0]

print(last_adjusted_price)

Does anyone know what the library would be called for this? And if someone could provide an example of how to get the 'totalRevenue' from the last quarterly entree, that would be a lifesaver. This is day 3 of trying to figure out how to get this lol I can't seem to find the documentation anywhere and I don't understand what it says on here www.alphavantage.co/documentation/

2

There are 2 best solutions below

0
On BEST ANSWER

Ok just as soon as I posted that question, I found the answer through brute force trying combinations haha

base_url = 'https://www.alphavantage.co/query?'
params = {'function': 'OVERVIEW',
         'symbol': 'IBM',
         'apikey': keys}

response = requests.get(base_url, params=params)

print(response.json())
test = response.json()['Name']
print(test)

Hopefully this helps someone else in the future if they are a newbie like me haha

0
On

I found the answer to this on this site https://algotrading101.com/learn/alpha-vantage-guide/

This code allows me to access the info

base_url = 'https://www.alphavantage.co/query?'
params = {'function': 'OVERVIEW',
         'symbol': 'IBM',
         'apikey': keys}

response = requests.get(base_url, params=params)
print(response.json())

It outputs a result like this

{'Symbol': 'IBM', 'AssetType': 'Common Stock', 'Name': 'International Business Machines Corporation', 'Description': "International blah blah"}

What would I need to write to output the name?

data_overview_Name = # What do i type here for code? 

# So that I could print out
print(data_overview_Name)
International Business Machines Corporation