extensions field.
Rate limiting
Rate limiting is a strategy used to control the frequency of requests made to an API. This prevents overuse or abuse, ensuring fair access and stability for all users. By setting limits on the number of requests within a specific time frame, rate limiting safeguards against performance degradation and potential service outages. At Tesouro, we employ rate limiting mechanisms to protect our systems and maintain a consistent experience. The default limit is 50 requests per second. This helps to ensure that no single user or application overwhelms the platform, impacting the performance for others. We monitor and manage request volumes to guarantee that our services remain available and responsive for everyone. This means if a user attempts to send too many requests within a given timeframe, they may encounter a rate limit response and need to adjust their request pattern.Rate limiting responses in extensions
Rate limiting details are included in the extensions field of a GraphQL response. This information will include:| Field | Description |
|---|---|
rateLimit.requestRate | The current rate of requests |
rateLimit.remaining | The remaining amount of requests before reset |
rateLimit.retryAfterMs | How long one should wait before retrying a request |
rateLimit.resetAfterMs | How long until the request rate limit will reset |
Example rate limit extension response
Handling rate limit responses
- Understand the rate limit exceeded error: If, for some reason, you find a way to exceed the Tesouro rate limit, you may end up with a request rejected due to rate limiting. This will result in an HTTP 429 status code.
- Check the
extensionsfield: Examine theextensionsfield for rate limiting information. If you find that remaining is zero, you will have exceeded the rate and will need to back off. - Implement backoff strategy: If rate limits are exceeded, implement a backoff strategy. This involves waiting for the
resetAfterMstime before retrying the request. Consider using exponential backoff for retries.