Ngoài hạn mức lệnh gọi API, Merchant Center còn áp dụng các hạn mức khác đối với tài nguyên. Những giới hạn này thường bị nhầm lẫn với hạn mức API, nhưng chúng là một phần trong giới hạn của Merchant Center. Để biết thêm thông tin, hãy xem bài viết Tìm hiểu về hạn mức trong Google Merchant Center.
Hạn mức sản phẩm
Để kiểm tra hạn mức sản phẩm, bạn có thể sử dụng các phương thức accounts.limits.get và accounts.limits.list.
Để truy xuất một hạn mức sản phẩm cụ thể, chẳng hạn như để nhận hạn mức EEA của quảng cáo trong một tài khoản, bạn cần chỉ định mã tài khoản và mã hạn mức trong lệnh gọi đến accounts.limits.get.
Mã nhận dạng hạn mức là sự kết hợp giữa loại hạn mức và phạm vi. Ví dụ: products~ADS_EEA cho các sản phẩm nhắm đến quảng cáo ở EEA và products~ADS_NON_EEA cho các sản phẩm nhắm đến quảng cáo bên ngoài EEA.
Sau đây là ví dụ về yêu cầu lấy giới hạn products~ADS_EEA cho một tài khoản nhất định:
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/limits/products~ADS_EEA
Mẫu sau đây minh hoạ cách truy xuất một hạn mức tài khoản cụ thể:
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.quota.v1.AccountLimit;
import com.google.shopping.merchant.quota.v1.AccountLimitsServiceClient;
import com.google.shopping.merchant.quota.v1.AccountLimitsServiceSettings;
import com.google.shopping.merchant.quota.v1.GetAccountLimitRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to get a single account limit for a given Merchant Center account.
*/
public class GetAccountLimitSample {
public static void getAccountLimit(String accountId, String limitId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
AccountLimitsServiceSettings accountLimitsServiceSettings =
AccountLimitsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (AccountLimitsServiceClient accountLimitsServiceClient =
AccountLimitsServiceClient.create(accountLimitsServiceSettings)) {
GetAccountLimitRequest request =
GetAccountLimitRequest.newBuilder()
.setName(String.format("accounts/%s/limits/%s", accountId, limitId))
.build();
System.out.println("Sending get account limit request:");
AccountLimit response = accountLimitsServiceClient.getAccountLimit(request);
System.out.println("Retrieved account limit below");
System.out.println(response);
} catch (Exception e) {
System.out.println("Failed to get account limit.");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The limit ID is a combination of the limit type and the scope, for example:
// `products~ADS_NON_EEA`
getAccountLimit(config.getAccountId().toString(), "products~ADS_EEA");
}
}
Để tìm hiểu về các mã nhận dạng giới hạn có sẵn cho tài khoản của bạn, hãy sử dụng accounts.limits.list với bộ lọc cho type="products":
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/limits?filter=type%3D%22products%22
Mẫu sau đây minh hoạ cách liệt kê các hạn mức trong tài khoản:
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.quota.v1.AccountLimit;
import com.google.shopping.merchant.quota.v1.AccountLimitsServiceClient;
import com.google.shopping.merchant.quota.v1.AccountLimitsServiceClient.ListAccountLimitsPagedResponse;
import com.google.shopping.merchant.quota.v1.AccountLimitsServiceSettings;
import com.google.shopping.merchant.quota.v1.ListAccountLimitsRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to list account limits for a given Merchant Center account. */
public class ListAccountLimitsSample {
public static void listAccountLimits(String accountId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
AccountLimitsServiceSettings accountLimitsServiceSettings =
AccountLimitsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (AccountLimitsServiceClient accountLimitsServiceClient =
AccountLimitsServiceClient.create(accountLimitsServiceSettings)) {
ListAccountLimitsRequest request =
ListAccountLimitsRequest.newBuilder()
.setParent(String.format("accounts/%s", accountId))
.setFilter("type = \"products\"")
.build();
System.out.println("Sending list account limits request:");
ListAccountLimitsPagedResponse response =
accountLimitsServiceClient.listAccountLimits(request);
int count = 0;
// Iterates over all rows in all pages and prints the account limit in each row.
// Automatically uses the `nextPageToken` if returned to fetch all pages of data.
for (AccountLimit accountLimit : response.iterateAll()) {
System.out.println(accountLimit);
count++;
}
System.out.print("The following count of account limits were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println("Failed to list account limits.");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
listAccountLimits(config.getAccountId().toString());
}
}
Giới hạn về cách trình bày tài nguyên
Các giới hạn sau đây mô tả các quy định hạn chế đáng chú ý đối với một số giá trị chuỗi và trường mảng trong cách thể hiện tài nguyên được dùng trong Merchant API. Cả Merchant API và tính năng tương ứng trong Merchant Center đều áp dụng các giới hạn này.
| Tài nguyên | Trường | Hạn mức |
|---|---|---|
shippingsettings |
Dịch vụ vận chuyển cho mỗi quốc gia ( Nhóm phí vận chuyển cho mỗi dịch vụ vận chuyển ( Nhãn cho mỗi nhóm phí vận chuyển ( Bảng phụ cho mỗi nhóm phí vận chuyển ( Số lượng hàng hoặc cột trong một bảng mức phí duy nhất. Độ dài của nhãn vận chuyển. |
20 20 30 100 150 100 |
Số hàng hoặc cột trong một bảng mức phí sẽ ảnh hưởng đến các trường mảng sau:
- Các trường mảng trong
rowHeadershoặccolumnHeaders:prices[]weights[]numberOfItems[]postalCodeGroupNames[]locations[]rows[]cells[]