使用RESTAPI JSON响应作为数据在Python中构建报告

2024-06-25 23:58:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我真的很难将来自QuickBase API的json响应转换为Pandas数据框架,这样我就可以使用Pandas和Chartly工作并绘制数据图表

import requests
import json
token = "b5u67z_pgnr_dkqwwkbbmmhnzwcjd4cexbi893ux"
realm_hostname = "builderprogram-ypetrov.quickbase.com"
headers = {
    'QB-Realm-Hostname': realm_hostname,
    'User-Agent': 'Python_Reporting',
    'Authorization': 'QB-USER-TOKEN ' + token
}
body = {
    "from": "bq4zh7zip",
    "select": [
    7,
    11,
    16
    ]
}
r = requests.post(
'https://api.quickbase.com/v1/records/query',
headers = headers,
json = body
)
json_export = (json.dumps(r.json(),indent=4))
import pandas as pd
#everything works fine until here, I can print json_export and the data is there but can't continue from here onwards
pd.read_json(json_export)

API请求详细信息在测试环境中有效,因此如果需要,请随时使用。
任何帮助都将不胜感激
问候


Tags: 数据importcomtokenapijsonpandasbody