Skip to content

Commit

Permalink
Add rate limits info to docs (#1836)
Browse files Browse the repository at this point in the history
## Describe your changes
Adding docs to describe global rate limiting

## Issue ticket number and link
https://linear.app/nango/issue/NAN-536/document-global-rate-limit
  • Loading branch information
TBonnin committed Mar 11, 2024
1 parent 6a46793 commit 1f5bb5c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs-v2/mint.json
Expand Up @@ -476,6 +476,7 @@
"icon": "cloud",
"pages": [
"reference/api/authentication",
"reference/api/rate-limits",
{
"group": "Integrations",
"pages": [
Expand Down
13 changes: 13 additions & 0 deletions docs-v2/reference/api/rate-limits.mdx
@@ -0,0 +1,13 @@
---
title: 'Rate limits'
---

The Nango API is rate-limited to prevent abuse and ensure fair usage across all clients. The rate limit is enforced on a per-account basis, with a fixed window of time and a maximum number of requests allowed within that window.

Those headers are sent back with every API response:
- `X-RateLimit-Limit` indicates the maximum number of requests a client can make within the rate limit window.
- `X-RateLimit-Remaining` shows how many requests are remaining before the limit is reached.
- `X-RateLimit-Reset` provides a Unix timestamp representing the time at which the current rate limit window resets, and the remaining request count is replenished.

If a client exceeds the rate limit, the API will respond with a 429 `Too Many Requests` status code. In this case, the `Retry-After` header is included, indicating the number of seconds the client should wait before making another request to avoid being rate-limited.

23 changes: 23 additions & 0 deletions docs-v2/reference/sdks/node.mdx
Expand Up @@ -38,6 +38,29 @@ const nango = new Nango({ secretKey: '<SECRET-KEY>' });
</ResponseField>
</Expandable>

# Rate limits

The Nango SDK is rate-limited to prevent abuse and ensure fair usage across all clients. The rate limit is enforced on a per-account basis, with a fixed window of time and a maximum number of requests allowed within that window.

If a client exceeds the rate limit, the API will respond with a 429 `Too Many Requests` status code. In this case, the `Retry-After` header is included, indicating the number of seconds the client should wait before making another request to avoid being rate-limited.

To handle rate limiting gracefully, clients should monitor for the 429 status code and honor the `Retry-After` header value provided in the response.

```js
// Example:
try {
const res = await nango.listIntegrations();
...
} catch(err) {
if (err.response.status === 429) {
const retryAfter = err.response.headers['retry-after'];
// wait and retry
...
}
...
}
```

# Integrations

### List all integrations
Expand Down

0 comments on commit 1f5bb5c

Please sign in to comment.