For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
5 5 3 8

Multi thread to call API. Error: "Too Many Request"

Hi,

I need to employ multi-threading in order to reduce the time taken to call multiple functions.

With multiple reference IDs, I used a Parallel.For loop to retrieve profile results in C#. Yet the following error occurs.

Even if I set the MaxDegreeOfParallelism to 2. This error occurs sometime.

Can someone advice / provide a solution ?

Thanks.

world-checkworld-check-oneerrormulti-threading
toomanyrequest.jpg (42.3 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
4.2k 8 5 6

Hello @cliff.ching ,

"Error 429 Too Many Requests" is sent as a response when the user has exhausted the maximum number of API calls per second. The users are advised to send 1 API request per second and exceeding this limit they would receive the error 429. The error depends on the maximum number of API calls per second and the available capacity on the WC1 platform (number of API calls being sent to the WC1 server by all the users at that instance).

In order to deal with this error, please re try the failed API calls after a brief delay and have a mechanism at a client's end to detect 429 error and downscale the number of API calls fired accordingly for better results.

Here is an excerpt from the "Quality of Service" section of our WC1 API documentation for your reference.

"The throttling limits are applied to all requests made by a user of the API, so a HTTP 429 response for one method would require a delay waiting period for all other API requests that may be processing during the same time period, for the same API user. Appropriate error handling that can check for errors such as HTTP 429 and retry requests using a policy such as exponential backoff should therefore be added to all World-Check One API calls.

Requests made to the World-Check One API are rate limited to ensure a consistent experience for all customers, however exact throttling limits may vary over time to adjust for available capacity on the platform. When making requests to the World-Check One API, it is advisable to check for HTTP 429 Too Many Requests response codes and attempt to retry the affected requests after a brief delay."

For more detailed information, I request you to refer the "Quality of Service" section of our documentation.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
5 5 3 8

Hi Khan,

Is it possible to encapsulate more multiple queries in one call ?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
4.2k 8 5 6

Hello @cliff.ching ,

If you mean clubbing multiple API requests in one API call, then I must say it is not possible. Currently you have follow the sequence in which the APIs are called and each have to be a separate request.

I suggest you to have a mechanism which automatically detects the 429 response and downscales the frequency of API calls and retries those failed APIs again after a brief delay. This way you can avoid the error 429: too many requests.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
5 5 3 8

Hi Khan,

I have the list of reference IDs to call the requests for profile details, hence it doesn't have to follow any sequence. However, if I understand correctly, multiple API requests in one call is not possible for my case as well. Kindly confirm.

Thanks.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
4.2k 8 5 6

Hi @cliff.ching ,

As you are trying pull the World check profile details of an entity using the reference ID, so yes, you have to call the API call "SEQ-5c: Get a World-Check profile" separately each reference ID.

Multiple API requests in one call is not possible for your case.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.