Api Python/Javascript 中的密钥请求

Api key request in Python/Javascript

我正在尝试向 API 发出请求。我有 API 密钥并阅读文档。

文档:https://info.nobil.no/images/downloads/API-NOBIL-Documentation_v3_20180808.pdf

文档中的示例在我看来在 javascript.

 jQuery.ajax({
 type: 'POST',
 url: 'https://nobil.no/api/server/search.php',
data: { 'apikey': nobilApiKey, 'apiversion': '3',
'action': "search",
 'type': 'rectangle',
 'northeast': '(59.943921193288915, 10.826683044433594)',
 'southwest': '(59.883683240905256, 10.650901794433594)',
'existingids': '189,195,199,89,48'},
 dataType: 'json'
});    

问题: 1.) 我可以用 python 向服务器发出请求吗? 2.) 如何将 api 键合并到代码中?

非常感谢展示如何操作的代码片段!

您将使用 requests

看起来像这样:

import requests
url = 'https://nobil.no/api/server/search.php?mode=ajax'
post_data = { 'apikey': nobilApiKey, 'apiversion': '3',
'action': "search",
 'type': 'rectangle',
 'northeast': '(59.943921193288915, 10.826683044433594)',
 'southwest': '(59.883683240905256, 10.650901794433594)',
'existingids': '189,195,199,89,48'}
r = requests.post(url, data=post_data)
# do something with r

在此处阅读文档:https://requests.readthedocs.io/en/master/