0

trivial question here but how can I convert my api request data into a pandas df

I can only view the data by doing print(response1.text) I'd like it as a dataframe

url = "https://alpha-vantage.p.rapidapi.com/query"
querystring = {"interval":"1min","function":"TIME_SERIES_INTRADAY_EXTENDED","symbol":"GME","datatype":"json","slice":'year1month8'}
headers = {
    'x-rapidapi-host': "alpha-vantage.p.rapidapi.com",
    'x-rapidapi-key': "(omitted)"
    }
response1 = requests.request("GET", url, headers=headers, params=querystring)

1 Answer 1

2
import requests
import pandas as pd    
url = "https://alpha-vantage.p.rapidapi.com/query"
querystring = {"interval":"1min","function":"TIME_SERIES_INTRADAY_EXTENDED","symbol":"GME","datatype":"json","slice":'year1month8'}
headers = {
    'x-rapidapi-host': "alpha-vantage.p.rapidapi.com",
    'x-rapidapi-key': "(omitted)"
    }
response1 = requests.request("GET", url, headers=headers, params=querystring)

response1_json = response1.json()
df = pd.json_normalize(response1_json)

print(df)
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for this, in return I receive the following error ` Expecting value: line 1 column 1 (char 0)`
Hey, from my side looks all good and code is working. May be from your side, you need to check requests or pandas lib.
That's interesting, everything seems fine here too, it may be a deeper issue, I will look into it, thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.