Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
custombatch là một phương thức phổ biến cho phép bạn nhóm một số lệnh gọi API,
được gọi là "mục nhập" thành một yêu cầu HTTP duy nhất. Mỗi mục nhập chỉ tham chiếu đến một lệnh gọi phương thức duy nhất.
Lô tuỳ chỉnh là lựa chọn phù hợp khi:
Bạn mới bắt đầu sử dụng API này và có nhiều dữ liệu sản phẩm cần tải lên.
Bạn cần đồng bộ hoá dữ liệu cục bộ với máy chủ bằng cách gửi nhiều nội dung cập nhật và xoá.
Thực hiện yêu cầu hàng loạt
Việc gửi yêu cầu theo lô tương tự như việc gửi song song lệnh gọi API. Xin lưu ý rằng
không có gì đảm bảo rằng thứ tự của các mục nhập được xác định trong yêu cầu sẽ
theo thứ tự được thực thi. Bạn không nên sử dụng các lệnh gọi phụ thuộc trong một yêu cầu lô duy nhất (chẳng hạn như tạo và cập nhật cùng một lô hàng).
Tương tự, phản hồi nhận được cho các yêu cầu theo lô có thể được trả về theo thứ tự khác với phản hồi của các mục nhập yêu cầu. Bạn có thể sử dụng BatchId để liên kết các yêu cầu và phản hồi vì các phản hồi có thể bị trả về không theo trình tự.
Bạn có thể gọi lô các yêu cầu trong API bằng cách gọi phương thức custombatch thích hợp:
Tài nguyên và phương thức nhóm tuỳ chỉnh tương ứng
Để tránh lỗi khi tải lên các lô lớn, bạn nên giới hạn kích thước của các yêu cầu custombatch ở mức tối đa là 1.000 mục nhập. Các mức tối đa sau đây áp dụng cho yêu cầu custombatch:
50.000 mục cho mỗi custombatch yêu cầu
Kích thước chuyển 32 MB
Những lệnh gọi vượt quá mức tối đa sẽ dẫn đến lỗi request_too_large sau:
"Too many requests in a batch."
"Request payload size exceeds the limit: %d bytes."
[null,null,["Cập nhật lần gần đây nhất: 2025-08-13 UTC."],[[["\u003cp\u003eThe Merchant API is the new version of the Content API for Shopping and is now in beta.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003ecustombatch\u003c/code\u003e method to group several API calls into a single HTTP request for efficiency, especially for initial data uploads and synchronization.\u003c/p\u003e\n"],["\u003cp\u003eBatch requests have a limit of 50,000 entries and 32Mb transfer size; exceeding these limits will result in errors.\u003c/p\u003e\n"],["\u003cp\u003eThere's no guarantee that batched requests will be executed or returned in the order they were defined; use \u003ccode\u003eBatchId\u003c/code\u003e to correlate requests and responses.\u003c/p\u003e\n"],["\u003cp\u003eFor more details and to learn how the Merchant API can improve your integration, visit the announcement blog post.\u003c/p\u003e\n"]]],["The Merchant API beta, a new version of the Content API for Shopping, is introduced. It uses `custombatch`, a method to group multiple API calls into a single HTTP request for efficient data uploading and synchronization. `Custombatch` suits large data transfers but doesn't guarantee execution order. `BatchId` correlates requests and responses. Batches can have top-level or entry-specific errors. There is a recommended limit of 1,000 entries per batch with maximum limits of 50,000 entries, and 32Mb size.\n"],null,["# Batch requests\n\n`custombatch` is a common method that allows you to group several API calls,\nknown as \"entries\" into one single HTTP request. Each entry only references a\nsingle method call.\n\nCustom batch is a good choice when:\n\n- You've just started using the API and have a lot of product data to upload.\n- You need to synchronize local data with the server by sending lots of updates and deletes.\n\nMake batch requests\n-------------------\n\nSending batch requests is similar to sending API calls in parallel. Note that\nthere is no guarantee that the order of entries defined in the request will\nbe in the order that they are executed. We recommend that you don't use\ninterdependent calls in a single batch request (such as creating and updating\nthe same shipment).\n\nSimilarly, the responses received for batched requests may be returned in a\ndifferent order to that of the request entries. The `BatchId` can be used to\ncorrelate requests and responses since the responses may be returned out of\nsequence.\n| **Note:** Batch requests have two failure modes: one for top-level errors and one for errors resulting from individual entries in the batch. If a request fails because of a top-level error, responses for individual entries are not returned.\n\nYou can batch requests in the API by calling the appropriate `custombatch`\nmethod:\n\n| Resources and their corresponding custom batch methods ||\n|--------------------|------------------------------------------------------------------------------------------------------|\n| `Accounts` | [`accounts.custombatch`](/shopping-content/reference/rest/v2.1/accounts/custombatch) |\n| `Accountstatuses` | [`accountstatuses.custombatch`](/shopping-content/reference/rest/v2.1/accountstatuses/custombatch) |\n| `Accounttax` | [`accounttax.custombatch`](/shopping-content/reference/rest/v2.1/accounttax/custombatch) |\n| `Datafeeds` | [`datafeeds.custombatch`](/shopping-content/reference/rest/v2.1/datafeeds/custombatch) |\n| `Datafeedstatuses` | [`datafeedstatuses.custombatch`](/shopping-content/reference/rest/v2.1/datafeedstatuses/custombatch) |\n| `Localinventory` | [`localinventory.custombatch`](/shopping-content/reference/rest/v2.1/localinventory/custombatch) |\n| `Liasettings` | [`liasettings.custombatch`](/shopping-content/reference/rest/v2.1/liasettings/custombatch) |\n| `Pos` | [`pos.custombatch`](/shopping-content/reference/rest/v2.1/pos/custombatch) |\n| `Products` | [`products.custombatch`](/shopping-content/reference/rest/v2.1/products/custombatch) |\n| `Productstatuses` | [`productstatuses.custombatch`](/shopping-content/reference/rest/v2.1/productstatuses/custombatch) |\n| `Shippingsettings` | [`shippingsettings.custombatch`](/shopping-content/reference/rest/v2.1/shippingsettings/custombatch) |\n\nLimits\n------\n\nTo avoid errors when uploading large batches, we recommend limiting the size\nof `custombatch` requests to a maximum of 1,000 entries. The following maximums\napply to `custombatch` requests:\n\n- 50,000 entries per `custombatch` request\n- 32Mb transfer size\n\nCalls that exceed the maximums result in the following `request_too_large`\nerrors:\n\n- `\"Too many requests in a batch.\"`\n- `\"Request payload size exceeds the limit: %d bytes.\"`"]]