API Limits

When you make many API requests within a short amount of time, you may receive a 429 Too Many Requests response back. When you reach the daily or rate limit, Knack will stop processing any more requests until a certain amount of time has passed.

The default daily limits for a Knack account are as follows:

Plan

Daily Limit

Starter

1,000

Pro

5,000

Corporate

10,000

Plus

25,000

📘

For all plan types, there is a rate limit of 10 requests per second.

📘

If you’d like to increase the number of requests you’re able to make in a day, please fill out the form located here.

Which Requests Count Toward Limits

  • All object-based API calls count against your API limits. This uses the X-Knack-REST-API-KEY header and your API key to make requests.
  • All view-based API calls which are authenticated with a user token count against your limits. This uses the Authorization header to send the logged-in user's token.
  • All third-party requests that send data to the object-based API. This includes Zapier and Integromat, as well as others. An easy way to tell is if they ask for your API key when integrating with Knack. If they do, any call made by the third-party will count towards your limits.

Which Requests Do Not Count Toward Limits

  • View-based API calls which are not authenticated with a user token - that is, requests whose URLs refer to scenes/views which are not protected by a login - do not count against your limits. For this reason, adding a new page, removing it from the page menu, and using that page for API calls can be a smooth method of avoiding hitting your daily limit without cluttering up your app (your users will not know this page exists, unless they have its URL, since you removed it from the page menu).

Catching 429 Errors

We strongly recommend that any code which interacts with our API catches any errors caused by hitting our rate limit, since your code can wait under a second for the limit to expire and then retry the failed request. Upon hitting the rate limit, the HTTP response which you’ll receive from Knack will have the HTTP status code 429 Too Many Requests with the message, “Rate limit exceeded”. Every request after this, until the one second is up, will continue to produce these errors and your requests will be ignored by Knack.

As an example, a request which goes over the rate limit might return the following response:

X-PlanLimit-Limit: 10000
X-PlanLimit-Remaining: 9888
X-PlanLimit-Reset: 10738500
X-RateLimit-Limit: 10
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1534205053
Status Code: 429 Too Many Requests

This response contains some key information we can use to avoid hitting a rate limit:

  • X-PlanLimit-Limit: 10000
    • This is how many requests per day your plan is limited to
  • X-PlanLimit-Remaining: 9888
    • This is how many requests your plan has left until midnight GMT
  • X-PlanLimit-Reset: 10738500
    • Milliseconds remaining until your daily limit will be reset
  • X-RateLimit-Limit: 10
    • How many requests you can send per second
  • X-RateLimit-Remaining: 0
    • Number of requests remaining within the timeframe of one second
  • X-RateLimit-Reset: 1534205053
    • The epoch time in seconds UTC when the rate limit will be reset
  • Status Code: 429 Too Many Requests
    • You’ve hit either your daily or the rate limit

With the above response information in mind, you would be able to alter your script to catch rate-limit errors and alter your next requests accordingly.

As an example, the following pseudo-code will catch the rate-limit error, calculate how many milliseconds to wait, and retry:

response = request.get(url, headers)
if (response.status == 429)
{
  now = currentTimeStampInMilliSeconds
  retryAfter = (response.x-ratelimit-reset * 1000) - now
  log("Rate limited, waiting " + retryAfter + " ms before trying again.")
  sleep(retryAfter)
  retry(url, headers, data)
}

Checking the Remaining API Request Limit

To check the remaining number of API requests that are available on your account on a specific day, you can check the following response in the API header:

X-PlanLimit-Remaining

This is how many requests your plan has left until midnight GMT.

Reducing the Amount of API Requests

To reduce the number of requests you make, we suggest:

  • Optimizing code to remove any requests that may no longer be vital to your app’s functionality. Find any requests you make but whose returned data you do not actually use.
  • Caching frequently requested data that doesn’t change. This could be saved either client- or server-side; better yet, you could simply move the data to the page itself as text (or other format) instead of requesting it from your Knack app.
  • Check if your third-party integrations (e.g. Zapier) are pushing you over your daily limits. With multiple users on the Live App and a third-party integration all making calls at the same time, your rate limit could easily be exceeded.

Throttling the Rate of Requests

If you frequently hit your rate limit we strongly suggest throttling the rate at which your requests are being sent to Knack, as this is the most common reason someone would hit the limit. This can be done either statically or dynamically, and clues can be drawn from the aforementioned X-RateLimit-Remaining and X-PlanLimit-Remaining response headers. In order to avoid hitting the rate limit, you might:

  • Wait for a response from the previous request before continuing with another request. In the majority cases, this will add enough of a delay between requests to prevent you from reaching the rate limit. This will not prevent you from hitting your daily limit however, and we suggest referring to the section above - Reducing the Amount of API Requests - for information on how to avoid this.
  • Add just enough of a hard-coded delay between requests to prevent yourself from hitting the rate limit. This can take some trial and error as well as monitoring the number of requests being sent and their responses, to get right.
  • Include a counter variable to track the number of requests you are sending in order to group the requests as a batch. Once you hit the magic number of 10 requests, check the X-RateLimit-Reset header’s value - and wait until that timestamp has passed - before sending the next batch of requests.

What’s Next
Did this page help you?