简体   繁体   中英

How to fetch the data of an array of business ids using Yelp API?

I have an long array containing ids of businesses and I want to fetch each business data associated with the id.

Although using axios and the right headers gives me the result, I still get some of the data missing due to the following error/exception: TOO_Many_Requests_Per_Second .

The code I use for fetching the data is as follows:

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      });
      });

The developer docs for the Yelp API has the following information about this error response:

Queries-Per-Second (QPS) Rate Limiting

QPS Limit

If you make queries against the API too quickly, you may get HTTP 429 errors with the json body:

{
    "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."
    }
}

If you are seeing these regularly, please slow down the rate at which you are making calls to the API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM