Benchling

Rate Limiting

If you make a lot of API requests in a short amount of time, you may hit the API rate limit. By default, the rate limit is set to 60 requests per 30 seconds. Once the rate limit has been reached, Benchling will respond to further requests with a 429 “Too Many Requests” response until the limit resets.

Handling rate limits

When integrating with a rate-limited API, our recommended best practice is to write your code in a way that handles 429 HTTP status codes in an HTTP response. When the rate limit is exceeded, HTTP response bodies will look like the following:

{
  "error": {
    "message": "Rate limit exceeded.",
    "type": "invalid_request_error",
    "userMessage": "Rate limit exceeded."
  }
}

Additionally, each API response includes the following headers:

Header

Description

Example

x-rate-limit-limit

The total number of requests allowed per period.

60

x-rate-limit-remaining

The number of requests remaining per period.

57

x-rate-limit-reset

The number of seconds remaining in the period.

21

If you receive a 429 HTTP status code from the API, we recommend that you use an exponential backoff strategy to retry requests. This involves repeatedly retrying the request, with a backoff delay that increases exponentially with every retried request, until a maximum delay is reached. A small random constant is also added to the delay time each time in order to avoid situations in which clients are retrying many requests in an exactly synchronized way. In pseudocode, a simplified example to illustrate this strategy might look something like the following:

def safe_api_get(url):
    n = 1
    maximum_delay = 15

    while True:
        try:
            return api_get(url)
        except RateLimitExceededException:
            constant_factor = random_float_between(0, 1)
            delay_time = 2 ** n + constant_factor

            if delay_time > maximum_delay:
                delay_time = maximum_delay

            delay(delay_time)
            n += 1

Increasing your rate limit

API rate limits are configurable, and can be increased by Benchling support ([email protected]) upon request.

Updated 3 months ago

Rate Limiting


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.