Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如果API URL需要API密钥集成到URL中,如何开发API?_Python_Python Requests_Api Design - Fatal编程技术网

Python 如果API URL需要API密钥集成到URL中,如何开发API?

Python 如果API URL需要API密钥集成到URL中,如何开发API?,python,python-requests,api-design,Python,Python Requests,Api Design,我需要对此API()进行基本的GET调用。API文档也不清楚如何将API密钥以及其他参数传递到URL中 此外,API文档中的端点只是解决方案的一部分。我在API设置中得到了一个URL,我认为它是端点的一部分。URL如下所示: https://url.api-us1.com 那么我如何让这个API工作呢 以下是我目前的代码: import requests api_key = '123abc' url = 'https://url.api-us1.com/admin/api.php?api_a

我需要对此API()进行基本的GET调用。API文档也不清楚如何将API密钥以及其他参数传递到URL中

此外,API文档中的端点只是解决方案的一部分。我在API设置中得到了一个URL,我认为它是端点的一部分。URL如下所示:

https://url.api-us1.com
那么我如何让这个API工作呢

以下是我目前的代码:

import requests

api_key = '123abc'
url = 'https://url.api-us1.com/admin/api.php?api_action=address_list'


r = requests.get(url, params=api_key)
我从响应对象返回的错误是:

<?xml version='1.0' encoding='utf-8'?>\n<root><result_code>0</result_code><result_message>You are not authorized to access this file</result_message><result_output>xml</result_output></root>"
\n0您无权访问此文件XML”
API也不提供要传递的头


提前感谢您。

正如文档所述,API密钥需要放在您的URL中,而不是请求正文中

url = 'https://url.api-us1.com/admin/api.php?api_action=address_list&api_key' + api_key