I've been doing some API requests using Requests and Pandas. Now I'm trying to use a for loop to iterate through a list of URL parameters. When I test using print(), I get the JSON response for the entire list back. What I really want to do is turn the response into a Pandas dataframe but I don't know what function I can use to do that.
import requests
import requests_cache
from requests_cache import CachedSession
import pandas as pd
session = CachedSession()
base_url = "https://api.crossref.org/works/"
for doi in ["10.4324/9780429202483", "10.1177/2053168017702990", "10.1016/j.chb.2019.05.017", "10810730.2017.1421730," "10.1002/wmh3.247", "10.1177/1940161220919082"]:
url = base_url + str(doi)
response = session.get(url, headers={"mailto":"[email protected]"})
data = response.json()['message']
dataframe = pd.json_normalize(data)
dataframe.head(6)
Basically, I'm trying to create a dataframe like the one below, but with six lines, one for each of the parameters. Dataframe