除了 API 呼叫配額外,Merchant Center 也會對資源強制執行其他限制。這些限制經常與 API 配額混淆,但其實是 Merchant Center 限制的一部分。詳情請參閱「瞭解 Google Merchant Center 的配額」。
產品數量上限
如要查看產品限制,請使用 accounts.limits.get 和 accounts.limits.list 方法。
如要擷取特定產品限制 (例如取得帳戶的廣告歐洲經濟區配額),您需要在對 accounts.limits.get 的呼叫中指定帳戶 ID 和限制 ID。
限制 ID 是限制類型和範圍的組合。舉例來說,
products~ADS_EEA適用於指定在歐洲經濟區放送廣告的產品,
products~ADS_NON_EEA則適用於指定在歐洲經濟區以外放送廣告的產品。
以下範例要求會取得指定帳戶的 products~ADS_EEA 限制:
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/limits/products~ADS_EEA
以下範例說明如何擷取特定帳戶限制:
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");
}
}
如要瞭解帳戶可用的限制 ID,請使用
accounts.limits.list
並篩選 type="products":
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/limits?filter=type%3D%22products%22
以下範例說明如何列出帳戶相關限制:
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());
}
}
資源表示法限制
以下限制說明瞭 Merchant API 中,資源表示法的特定字串值和陣列欄位會有特別的使用限制。這些限制適用於 Merchant API 和 Merchant Center 中的對應功能。
| 資源 | 欄位 | 限制 |
|---|---|---|
shippingsettings |
依國家/地區劃分的運送服務 ( 每個運送服務的運送群組 ( 每個運送群組的標籤 ( 每個運送群組的子表格 ( 單一費率表中的列數或欄數。 運送標籤的長度。 |
20 20 30 100 150 100 |
費率表中的列數或欄數會影響下列陣列欄位:
rowHeaders或columnHeaders中的陣列欄位:prices[]weights[]numberOfItems[]postalCodeGroupNames[]locations[]rows[]cells[]