Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rate limits info to docs #1836

Merged
merged 1 commit into from Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No documentation about the actual limit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of the headers is to specify the actual limit. It is easier not to mention the limit imho so docs doesn't have to be changed when we modify the limit or if we start implementing different limits for different endpoints/group of endpoints.


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