From 717401c571881655b21533adee1eb817adfd5c55 Mon Sep 17 00:00:00 2001 From: gustavorodriguespereira Date: Fri, 1 Nov 2024 18:23:55 -0300 Subject: [PATCH 1/7] add limits documentation --- docs/limits.md | 40 ++++++++++++++++++++++++++++++++++++++++ sidebars.js | 1 + 2 files changed, 41 insertions(+) create mode 100644 docs/limits.md diff --git a/docs/limits.md b/docs/limits.md new file mode 100644 index 000000000..33767bd5d --- /dev/null +++ b/docs/limits.md @@ -0,0 +1,40 @@ +--- +title: Limits +description: Limits +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import useBaseUrl from '@docusaurus/useBaseUrl'; + +## About + +To ensure reliable performance and fair usage across all users, our API enforces rate limits on requests. These limits are applied on a per-method basis and are measured over specified time intervals. Each method has defined thresholds for the number of requests allowed per user within these intervals. If the rate limit for a method is exceeded, further requests will be temporarily restricted until the time interval resets. + + +## Limits TreshHold + +| HTTP Method | Requests per Second | +|-------------|----------------------| +| GET | 10 | +| POST | 5 | +| PUT | 3 | +| DELETE | 2 | +| PATCH | 2 | + + +## Troubleshooting Rate Limit Errors + +When a request exceeds the rate limit for a given API method, the server will return a `429 Too Many Requests` response. This response includes a `Retry-After` header indicating the number of seconds to wait before retrying the request. Below are some common scenarios and suggested actions for handling rate limits effectively. + +| Issue | Description | Suggested Action | +|--------------------------------|-----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| **Received 429 Response** | The rate limit for the requested method has been exceeded. | Read the `Retry-After` header value to determine the wait time before making another request. | +| **Repeated 429 Errors** | Too many requests are being sent in a short time frame. | Implement a backoff strategy, increasing the wait time between requests, to avoid repeated errors. | +| **Invalid Retry-After Handling** | Ignoring the `Retry-After` header and continuing to send requests. | Ensure your code respects the `Retry-After` value to avoid unnecessary rate-limit errors. | +| **Unexpected Rate Limit Hit** | Rate limits are being reached unexpectedly, possibly due to high traffic or unexpected load. | Evaluate your request patterns and consider caching or reducing request frequency where possible. | + +**Best Practices**: +- **Implement Retry Logic**: Use the `Retry-After` header to adjust your request timing. Wait at least the number of seconds specified before retrying. +- **Backoff Strategy**: If repeated 429 responses occur, consider using an exponential backoff approach, gradually increasing the time between requests. +- **Monitor Usage**: Track your API usage patterns and rate limit hits to optimize request volume and avoid unnecessary retries. diff --git a/sidebars.js b/sidebars.js index 2f14c1215..94c80c36a 100644 --- a/sidebars.js +++ b/sidebars.js @@ -12,6 +12,7 @@ module.exports = { 'introduction', 'authentication', 'setup_information', + 'limits'] { type: 'category', label: 'Configurations', From 3ad7f2096440f52a47637b10bc066c16b7e14522 Mon Sep 17 00:00:00 2001 From: gustavorodriguespereira Date: Fri, 1 Nov 2024 18:32:14 -0300 Subject: [PATCH 2/7] add support contact --- docs/limits.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/limits.md b/docs/limits.md index 33767bd5d..b653ada36 100644 --- a/docs/limits.md +++ b/docs/limits.md @@ -38,3 +38,9 @@ When a request exceeds the rate limit for a given API method, the server will re - **Implement Retry Logic**: Use the `Retry-After` header to adjust your request timing. Wait at least the number of seconds specified before retrying. - **Backoff Strategy**: If repeated 429 responses occur, consider using an exponential backoff approach, gradually increasing the time between requests. - **Monitor Usage**: Track your API usage patterns and rate limit hits to optimize request volume and avoid unnecessary retries. + +:::tip +Please don't hesitate to [contact][contact] us at help@withleaf.io for more information! +::: + +[contact]: mailto:help@withleaf.io \ No newline at end of file From 40cecb54aaa8d2f5321c15c5c337b2f32f85646b Mon Sep 17 00:00:00 2001 From: gustavorodriguespereira Date: Fri, 1 Nov 2024 18:38:46 -0300 Subject: [PATCH 3/7] fix sidebars.js setup --- sidebars.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sidebars.js b/sidebars.js index 94c80c36a..e6bbed4f2 100644 --- a/sidebars.js +++ b/sidebars.js @@ -12,7 +12,7 @@ module.exports = { 'introduction', 'authentication', 'setup_information', - 'limits'] + 'limits',] { type: 'category', label: 'Configurations', From 0a45818546e209e7a80bfdae9e75a898a3eed177 Mon Sep 17 00:00:00 2001 From: gustavorodriguespereira Date: Fri, 1 Nov 2024 18:47:44 -0300 Subject: [PATCH 4/7] fix sidebars.js setup --- sidebars.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sidebars.js b/sidebars.js index e6bbed4f2..1b342f89d 100644 --- a/sidebars.js +++ b/sidebars.js @@ -12,7 +12,7 @@ module.exports = { 'introduction', 'authentication', 'setup_information', - 'limits',] + 'limits'], { type: 'category', label: 'Configurations', From 5e05a7e5b4670102bb8003f757af880d18cd48ee Mon Sep 17 00:00:00 2001 From: gustavorodriguespereira Date: Fri, 1 Nov 2024 22:21:00 -0300 Subject: [PATCH 5/7] fix sidebars.js setup (for real this time) --- sidebars.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sidebars.js b/sidebars.js index 1b342f89d..96a2c2460 100644 --- a/sidebars.js +++ b/sidebars.js @@ -12,7 +12,7 @@ module.exports = { 'introduction', 'authentication', 'setup_information', - 'limits'], + 'limits', { type: 'category', label: 'Configurations', From 0d4412a88b59ef213937dbf75bbd4a34573cd5ff Mon Sep 17 00:00:00 2001 From: gustavorodriguespereira Date: Wed, 6 Nov 2024 15:44:24 -0300 Subject: [PATCH 6/7] remove the limits link from the sidebar --- sidebars.js | 1 - 1 file changed, 1 deletion(-) diff --git a/sidebars.js b/sidebars.js index 96a2c2460..2f14c1215 100644 --- a/sidebars.js +++ b/sidebars.js @@ -12,7 +12,6 @@ module.exports = { 'introduction', 'authentication', 'setup_information', - 'limits', { type: 'category', label: 'Configurations', From a02ae62c491492f288d3b21fd19a0214bff07953 Mon Sep 17 00:00:00 2001 From: gustavorodriguespereira Date: Wed, 6 Nov 2024 15:51:47 -0300 Subject: [PATCH 7/7] adjust the description based on the devops update --- docs/limits.md | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/docs/limits.md b/docs/limits.md index b653ada36..e7c0b8f44 100644 --- a/docs/limits.md +++ b/docs/limits.md @@ -9,36 +9,41 @@ import useBaseUrl from '@docusaurus/useBaseUrl'; ## About -To ensure reliable performance and fair usage across all users, our API enforces rate limits on requests. These limits are applied on a per-method basis and are measured over specified time intervals. Each method has defined thresholds for the number of requests allowed per user within these intervals. If the rate limit for a method is exceeded, further requests will be temporarily restricted until the time interval resets. +To ensure reliable performance and fair usage across all users, our API enforces rate limits on requests. These limits are applied globally and are measured over specified time intervals. If a user exceeds these limits, further requests will be temporarily restricted until the interval resets. +## Request Limit -## Limits TreshHold - -| HTTP Method | Requests per Second | -|-------------|----------------------| -| GET | 10 | -| POST | 5 | -| PUT | 3 | -| DELETE | 2 | -| PATCH | 2 | - +The API allows up to **1000 requests per minute** per user. This global limit applies to all methods and endpoints, regardless of the specific HTTP method used. Once this limit is reached, additional requests will be blocked until the minute resets. Users exceeding this limit will receive a `429 Too Many Requests` error response, prompting them to reduce their request frequency. ## Troubleshooting Rate Limit Errors -When a request exceeds the rate limit for a given API method, the server will return a `429 Too Many Requests` response. This response includes a `Retry-After` header indicating the number of seconds to wait before retrying the request. Below are some common scenarios and suggested actions for handling rate limits effectively. +When a request exceeds the rate limit, the server will return a `429 Too Many Requests` response. Below are common scenarios and suggested actions for handling rate limits effectively. | Issue | Description | Suggested Action | |--------------------------------|-----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| -| **Received 429 Response** | The rate limit for the requested method has been exceeded. | Read the `Retry-After` header value to determine the wait time before making another request. | +| **Received 429 Response** | The rate limit has been exceeded. | Read the error message to understand the limit and adjust the request frequency accordingly. | | **Repeated 429 Errors** | Too many requests are being sent in a short time frame. | Implement a backoff strategy, increasing the wait time between requests, to avoid repeated errors. | -| **Invalid Retry-After Handling** | Ignoring the `Retry-After` header and continuing to send requests. | Ensure your code respects the `Retry-After` value to avoid unnecessary rate-limit errors. | | **Unexpected Rate Limit Hit** | Rate limits are being reached unexpectedly, possibly due to high traffic or unexpected load. | Evaluate your request patterns and consider caching or reducing request frequency where possible. | -**Best Practices**: -- **Implement Retry Logic**: Use the `Retry-After` header to adjust your request timing. Wait at least the number of seconds specified before retrying. +### Error Response Format + +When the rate limit is exceeded, you will receive an error response in the following format: + +```json +{ + "error": "Request limit exceeded", + "message": "You have exceeded the maximum allowed requests of 1000 per minute. Please reduce your request rate and try again after a short delay.", + "status_code": 429 +} +``` + +## Best Practices + +- **Implement Retry Logic**: After receiving a 429 response, wait a few seconds before retrying. - **Backoff Strategy**: If repeated 429 responses occur, consider using an exponential backoff approach, gradually increasing the time between requests. - **Monitor Usage**: Track your API usage patterns and rate limit hits to optimize request volume and avoid unnecessary retries. +Please don't hesitate to contact us at help@withleaf.io for more information! :::tip Please don't hesitate to [contact][contact] us at help@withleaf.io for more information! :::