Merchant Center 限制

除了 API 调用配额外,Merchant Center 还对资源实施其他限制。 这些限制经常与 API 配额混淆,但它们是 Merchant Center 限制的一部分。如需了解详情,请参阅 Google Merchant Center 中的了解配额

产品限制

如需查看产品限制,您可以使用 accounts.limits.getaccounts.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

每个国家/地区的配送服务数 (services)。

每项配送服务的配送组数 (rateGroups)。

每个配送组的标签数 (applicableShippingLabels)。

每个配送组的子表数 (subtables)。

单个费率表中的行数或列数。

配送标签的长度。

20

20

30

100

150

100

费率表中的行数或列数会影响以下数组字段

  • rowHeaderscolumnHeaders 中的数组字段:
    • prices[]
    • weights[]
    • numberOfItems[]
    • postalCodeGroupNames[]
    • locations[]
    • rows[]
    • cells[]