如何在使用 python 向 Stackoverflow API 发出请求时通过 header 传递我的 API 密钥
How can I pass my API key through header while making request to Stackoverflow API using python
headers = {'APIKEY':'----my API key here-----'}
response = requests.get('https://api.stackexchange.com/2.2/users?page=1&pagesize=5&order=desc&sort=reputation&site=Whosebug',headers=headers)
"quota_max":300,"quota_remaining":299
这表明最大配额为 300,但我认为我应该获得 Whosebug API 页面上提到的最大配额 10000。如果我在发出请求时以错误的方式传递 API 密钥,请帮助我。正确的做法是什么?
不确定从哪里得到 APIKEY
,但应该是 access_token
,并且应该是 url 参数。改为在字典中将 access_token
作为 url 参数传递。您还可以在 url.
中包含其他参数
url = 'https://api.stackexchange.com/2.2/users'
params = {'access_token': my_token, 'page': 1, 'pagesize': 5,
'order': 'desc', 'sort': 'reputation', 'site': 'Whosebug'}
response = requests.get(url, params=params)
headers = {'APIKEY':'----my API key here-----'}
response = requests.get('https://api.stackexchange.com/2.2/users?page=1&pagesize=5&order=desc&sort=reputation&site=Whosebug',headers=headers)
"quota_max":300,"quota_remaining":299
这表明最大配额为 300,但我认为我应该获得 Whosebug API 页面上提到的最大配额 10000。如果我在发出请求时以错误的方式传递 API 密钥,请帮助我。正确的做法是什么?
不确定从哪里得到 APIKEY
,但应该是 access_token
,并且应该是 url 参数。改为在字典中将 access_token
作为 url 参数传递。您还可以在 url.
url = 'https://api.stackexchange.com/2.2/users'
params = {'access_token': my_token, 'page': 1, 'pagesize': 5,
'order': 'desc', 'sort': 'reputation', 'site': 'Whosebug'}
response = requests.get(url, params=params)