Question: I need to connect to an API using this sample import json import requests from datetime import datetime, date strAPI = https://api.nasa.gov/neo/rest/v1/feed?start_date=2020-01-01&end_date=2020-01-05&api_key=gx1daXuj2m8vbtrVKtHALsIVu8U2yvBOWcbyjch8 response = requests.get(strAPI)

I need to connect to an API using this sample

import json import requests from datetime import datetime, date

strAPI = "https://api.nasa.gov/neo/rest/v1/feed?start_date=2020-01-01&end_date=2020-01-05&api_key=gx1daXuj2m8vbtrVKtHALsIVu8U2yvBOWcbyjch8" response = requests.get(strAPI) json_data = response.json() asteroids_data = json_data.get('near_earth_objects') results = []

for date in asteroids_data: for asteroid in asteroids_data[date]: print(asteroid)

for this API: https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=MSFT&apikey=demo

I am not doing it right and I am just confused on where to get to inputs. If someone can explain what should go in before "=json_data.get('') that would be very helpful for me to understand what is next. I don't necessarily need the answer I would genuinely like to understand the process which was not explained to me.

import json

import requests

from datetime import date

strAPI = "https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=MSFT&apikey=demo"

response = requests.get(strAPI)

json_data = response.json()

time_series_data = json_data.get('time_series_monthly')

results = []

for date in time_series_data:

for monthly_prices in meta_data[date]:

print(monthly_prices)

I get an error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!