I am new to python and want to fetch data from an API via Google Cloud Functions so that I can store the data in Google Cloud Storage afterwards.
The data is available in JSON format and I want to transform it in a table via pandas.
Since I am really unsure about the correct syntax I'd like to know how I have to call the function test_topic - The following code doesn't work for me. I get no error message but also I get no result.
What do I have to do that I get the table as a result?
import requests
import pandas as pd
def test_topic(df):
url = "https://api.domain.com/v1/"
payload={}
headers = {}
parameters = {
"api_key": "1234567890",
"start_date": "2020-01",
"end_date": "2021-01",
"format": "json"
}
response = requests.request("GET", url, headers=headers, data=payload, params=parameters)
df = response.json()['visits']
pd.DataFrame(df)