Optifeed API
Limits
The size of a request, the rate limits, what to do when Optifeed limits a request, and the hourly product import.
Summary
| Limit | Value | Counted for | Answer after the limit |
|---|---|---|---|
| Records in one request (orders, customers, products or campaigns) | At least 1, at most 1,000 | One request | No list or an empty list: invalid_batch, more than 1,000: batch_too_large (both 400) |
| Request body | 5 MB | One request | 413 with payload_too_large |
| API requests | 120 a minute (the count starts again at the start of each minute) | One API user | 429 with rate_limited |
| API requests | 300 in one minute | One IP address | 429 with rate_limited |
| Sign-ins | 30 in one minute | One IP address | 429 with rate_limited |
| Sign-ins with a wrong client secret | 10 a minute (the count starts again at the start of each minute) | One client id | 429 with rate_limited |
Records in one request
Each write request sends one JSON object with one list: orders, customers, products or campaigns. The list has 1 to 1,000 records. An order with its lines is one record.
- A body that is not JSON gets
400with the codeinvalid_json. - A body with no list, or with an empty list, gets
400with the codeinvalid_batch. - A list with more than 1,000 records gets
400with the codebatch_too_large.
In these cases, Optifeed stores nothing. Divide a large set of records into batches of 1,000 records or fewer.
Request body size
A request body is 5 MB (5,242,880 bytes) at most. A larger body gets 413 with the code payload_too_large, and Optifeed stores nothing.
Optifeed checks the size before it reads the body and before it checks the access token. The limit also applies to a chunked body. Send fewer records in each request.
Rate limits
Each API user
An API user can send 120 requests a minute. The count starts again at the start of each minute (at second 0). Each request with a valid access token counts, also a dry run.
Each answer after the token check has these headers:
| Header | Value |
|---|---|
RateLimit-Limit |
120 |
RateLimit-Remaining |
The number of requests that are left in this minute. |
RateLimit-Reset |
The number of seconds to the next minute. |
Request number 121 in a minute gets 429 with the code rate_limited and a Retry-After header. Retry-After gives the number of seconds to the next minute.
Each API user has its own count. Two systems with two API users do not share a limit.
Each IP address
One IP address can send 300 requests in one minute to the API. This limit does not include the sign-in. Request number 301 gets 429 with the code rate_limited and Retry-After: 60.
Optifeed checks this limit before it checks the access token, so this answer has no RateLimit-* headers.
Sign-in
The token endpoint has two limits:
- 30 sign-ins in one minute from one IP address, for all client ids together.
- 10 sign-ins a minute with a wrong client secret for one client id, from all IP addresses together. The count starts again at the start of each minute. A sign-in with the correct client secret still works.
The next sign-in after a limit gets 429 with this body:
{
"error": "rate_limited",
"error_description": "Too many sign-ins. Wait one minute."
}
This answer has no Retry-After header. Wait one minute before you sign in again.
When Optifeed limits a request
- Wait for the number of seconds in
Retry-After. - Send the same request again. Optifeed did not store the records of a request that got
429. - Read
RateLimit-Remainingin each answer, and slow down before it gets to0.
To send fewer requests:
- Send up to 1,000 records in each request.
- Use one access token for its full hour.
- Give each system its own API user.
Product import
POST /v1/products stores the products in Optifeed at once. The products get to your catalog with the hourly import:
- At minute 20 of each hour, Optifeed writes all the products that you sent into one file.
- At minute 30 of each hour, the hourly import starts. It reads that file into your catalog.
The first accepted product also creates the feed source of the API products in the Optifeed web app. The first import comes after the first file.
DELETE /v1/products/{sku} answers 202 Accepted. The product leaves the catalog with the next file and the next import.
The import guard
The import guard stops an import when the number of products falls too much:
- The last import had 100 products or more, and the new file has fewer than half of that number.
- The new file has 0 products, and the last import had products.
Then the products of the last import stay in the catalog. A person must accept the drop. Open the page of the feed source in the web app and click Accept the drop. The next import then publishes the smaller catalog.
The guard also applies to deletes. If you delete more than half of a catalog of 100 products or more before one import, that import stops.
