Rate limit
To ensure the stability of the Genstore platform, rate limits are enforced on all REST API requests. Developers must understand these restrictions and use standard technical methods to prevent rate limit violations.
WARNING
Strictly adhere to API rate limits to ensure reliable service. Avoid using these APIs in customer-facing apps to prevent service interruptions caused by exceeding rate limits.
Rate limit policies
The following table outlines the rate limiting policies for various types of APIs, encompassing standard, advanced, and enterprise-level restrictions:
API type | Limitation type | Standard policy |
---|---|---|
REST API | Number of Requests | Bucket size: 40 tokens Replenishment rate: 2/s |
Rate limit mechanism
Genstore manages API request rates using the token bucket algorithm, detailed as follows:
- Initial bucket size: Each app at each shop starts with 40 tokens.
- Token consumption: Each request consumes one token.
- Token replenishment: When the token count falls below 40, the system replenishes at a rate of 2 tokens per second until the bucket is full again.
- Handling over-limit requests: If the bucket runs out of tokens, any new requests will receive a
429 Too Many Requests
status code, indicating that the rate limit has been reached.
Response header
Developers can monitor their API usage through the X-Genstore-Shop-Api-Rate-Limit
field in the response headers:
X-Genstore-Shop-Api-Rate-Limit: 30/40
This example shows that 30 requests have been made, leaving 10 tokens remaining. If no further requests are made, the bucket will gradually refill to full capacity (40/40) within approximately 15 seconds, assuming a replenishment rate of 2 tokens per second.