如何使用Yelp API获取业务id数组的数据



我有一个包含企业id的长数组,我想获取与id相关的每个业务数据。

尽管使用axios和正确的标头可以得到结果,但由于以下错误/异常,我仍然会丢失一些数据:TOO_Many_Requests_Per_Second

我用来获取数据的代码如下:

const headers = {
Authorization: 'Bearer <token>',
'Content-Type': 'application/json',
};
data.maps(async (product : any) => {
const res = await axios.get(`${URLS.FETCH_BUSINESS_DETAILS}/${product.businessId}`, { headers      });
});

Yelp API的开发人员文档中有关于此错误响应的以下信息:

每秒查询(QPS(速率限制

QPS限制

如果你对API的查询太快,你可能会得到json主体的HTTP429错误:

{
"error": {
"code": "TOO_MANY_REQUESTS_PER_SECOND",
"description": "You have exceeded the queries-per-second limit for this endpoint.
Try reducing the rate at which you make queries."
}
}

如果您经常看到这些情况,请降低对API的调用速度

最新更新