我想请求 Zomato API 密钥。但是,他们的开发人员页面https://developers.zomato.com/api显示 404 错误。该 URL 取自 Zomato API https://www.npmjs.com/package/zomato-api 的npm 页面。我看过几个使用 Zomato API 的 youtube 视频,所需的网页更早显示。Zomato 是停止提供 API 还是有新的访问方式?请帮忙。
我心里有一个非常简单的目标。我想从我的 Node.js 服务器应用程序中通过名为 Zomato 的 API 发出 API 请求。我正在使用一个名为Got的 https 请求框架,它应该是请求 API 的轻量级版本。
var got = require('got');
var httpheaders = {
'Accept': 'application/json',
'user-key': '**********************',
'json': true
}
got('https://developers.zomato.com/api/v2.1/geocode?lat=35&lon=34', {httpheaders}).then(response => {
console.log('We got something');
console.log(response.body);
}).catch(error => {
console.log('We got nothing');
});
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我发现一个错误并打印“我们什么也没得到”。我似乎不知道如何实际包含 http 请求标头,但我无法根据文档找出正确的语法。任何帮助,将不胜感激。谢谢!
Zomato是最受欢迎的餐厅搜索引擎之一,提供免费的api服务......
如果在api请求中使用curl,则效果很好;
curl -X GET --header "Accept: application/json" --header "user_key: MY_API_KEY_HERE" "https://developers.zomato.com/api/v2.1/geocode?lat=41.10867962215988&lon=29.01834726333618"
Run Code Online (Sandbox Code Playgroud)
但是使用Python的requests库,它不起作用.当我执行下面的代码时;
import requests
r = requests.get("https://developers.zomato.com/api/v2.1/geocode?lat=41.10867962215988&lon=29.01834726333618", headers={"user_key": "MY_API_KEY_HERE", "Accept": "application/json"});
Run Code Online (Sandbox Code Playgroud)
解释器返回以下错误;
requests.exceptions.ProxyError: Cannot connect to proxy. Socket error: Tunnel connection failed: 403 Forbidden.
Run Code Online (Sandbox Code Playgroud)
通过pyCurl库进行了几次尝试但不幸的结果是相同的;403 Forbidden
我该如何解决这个问题?
当我尝试获得5条以上的评论时,“评论” API会返回相同的评论集。
我正在使用curl请求进行评论。例如,我正在尝试获得10条“ Impromptu”的评论,起始索引为20。
curl -X GET --header "Accept: application/json" --header "user-key: <API_KEY>" "https://developers.zomato.com/api/v2.1/reviews?res_id=311104&start=20&count=10"
如果不提供以下start和count参数,它将获得与我相同的评价:
curl -X GET --header "Accept: application/json" --header "user-key: <API_KEY>" "https://developers.zomato.com/api/v2.1/reviews?res_id=311104"
因此,我说一家餐厅仅获得5条评论。这是我的API_KEY的限制吗?