商品のリソース呼び出し

products リソースを使用すると、60 を超える商品属性を柔軟に管理することができます。Google ショッピングでの表示が承認されるように、多くの項目に入力する必要があります。場所、商品のタイプ、バリエーション商品、商品の一括販売など、さまざまな条件に応じて必須になるオプション フィールドがいくつかあります。商品に設定可能な 60 以上のオプション パラメータについて詳しくは、商品データ仕様をご覧ください。

products リソースを使用すると、一度に 1 つの商品を insertgetupdatedelete で指定し、Merchant Center データベース内のすべての商品を list 化できます。

productstatuses リソースを使用すると、掲載先での商品の承認または不承認のステータスを確認できます。データ品質の問題がある可能性がある商品とその問題の詳細については、商品ステータス ガイドをご覧ください。

API の例では、Google T シャツ 2 枚と Google 帽子の 3 つの商品を使用します。以下の表に示す最小限の商品データセットを使用して、個々の商品や商品のバッチを挿入、取得、更新、一覧表示、削除するための products リソース呼び出しを行います。

送料と税金の情報は、商品単位ではなくアカウント単位で設定することをおすすめします。

ショッピングモールの複数販売者サブアカウントの場合、すべての商品に external_seller_id フィールドを含める必要があります。詳しくは、プロダクト ID をご覧ください。

id online:en:US:1111111111 online:en:US:2222222222 online:en:US:3333333333
offerId 1111111111 2222222222 3333333333
役職 黒の Google T シャツ Google T シャツ(緑) Google ツイルキャップ
description 黒の Google T シャツ 綿 100% の Google T シャツ Google のキャップ(クラシック)
商品グループ ID google_tee google_tee
リンク http://my.site.com/blacktee http://my.site.com/greentee http://my.site.com/blackhat
条件 New New New
価格 2199.00 JPY 2199.00 JPY 1099.00 JPY
稼働率 在庫あり 在庫あり 在庫あり
imageLink https://shop.example.com/store/20160512512/assets/items/images/GGOEGXXX1100.jpg https://shop.example.com/store/20160512512/assets/items/images/GGOEGXXX0906.jpg https://shop.example.com/store/20160512512/assets/items/images/GGOEGHPB071610.jpg
gtin 9504000059422 9504000059446 9504000059452
mpn(製品番号) 00638NIC 00638ANG 00638ABC
brand Google Google Google
Google 商品カテゴリ ファッション・アクセサリー > 衣料品 ファッション・アクセサリー > 衣料品 ファッション・アクセサリー > ファッション・アクセサリー > 帽子
color Black green Black
サイズ L M M
age_group アダルト アダルト アダルト
gender male male 男女共用
included_destination ショッピング アクション、ショッピング広告 ショッピング アクション、ショッピング広告 Shopping Actions

products.insert

単一の商品を挿入するには、次のリクエスト URL を使用して、販売者 ID とサンプルの JSON 本文を指定します。挿入により新しい商品が作成されます。特定の商品の属性 channelcontentLanguageofferIdfeedLabel に値が存在する場合、このメソッドはそのエントリを更新し、その商品の以前の API 呼び出しのデータをすべて置き換えます。

すべての掲載先から除外されてから 7 日を超えた商品は、自動的に削除されます。

この例では、商品に新しい「Black Google T シャツ」を挿入します。

POST https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products

products.insert のリクエスト本文の呼び出し例:

{
 "kind": "content#product",
 "offerId": "1111111111",
 "title": "Google Tee Black",
 "description": "The Black Google Tee is available in unisex sizing.",
 "link": "http://my.site.com/blacktee/",
 "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
 "contentLanguage": "en",
 "targetCountry": "US",
 "feedLabel": "US",
 "channel": "online",
 "ageGroup": "adult",
 "availability": "in stock",
 "availabilityDate": "2019-01-25T13:00:00-08:00",
 "brand": "Google",
 "color": "black",
 "condition": "new",
 "gender": "male",
 "googleProductCategory": "1604",
 "gtin": "608802531656",
 "itemGroupId": "google_tee",
 "mpn": "608802531656",
 "price": {
  "value": "21.99",
  "currency": "USD"
 },
 "sizes": [
  "Large"
 ]
}

商品には、JSON 本文内でカスタム属性を設定することもできます。たとえば、単一の商品に purchase_quantity_limit を設定すると、顧客が注文できるアイテム数を制限できます。

"customAttributes": [
 {
   "name": "purchase_quantity_limit",
   "value": "4"
 }
]

purchase_quantity_limit カスタム属性は商品定義に顧客注文ごとの購入上限を設定します。これはフィードでもサポートされています。この属性は現在、API で完全にサポートされるまではベータ版です。販売者はカスタム属性を追加できますが、API によって特定の処理が行われることはありません。

呼び出しが成功すると、HTTP 200 コードと、idofferIdcontentLanguagefeedLabelchannel のみが入力された、挿入された商品リソースを含むレスポンスの本文が返されます。

{
 "kind": "content#product",
 "id": "online:en:US:1111111111",
 "offerId": "1111111111",
 "contentLanguage": "en",
 "targetCountry": "US",
 "feedLabel": "US",
 "channel": "online"
}

products.get

Merchant Center データベース内の特定の商品の情報を取得するには、products.get を使用します。新しく挿入された商品がこの呼び出しで使用可能になるまでに数分かかることがあります。

次の HTTP リクエスト URL とパラメータ、販売者 ID、取得する商品の商品 ID(REST ID 形式)を使用します。

GET https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId}

呼び出しが成功すると、レスポンスの本文で HTTP 200 と「商品リソース」が返されます。ID online:en:US:1111111111 の商品から取得した商品データの例を次に示します。

{
 "kind": "content#product",
 "id": "online:en:US:1111111111",
 "offerId": "1111111111",
 "source": "api",
 "title": "Google Tee Black",
 "description": "The Black Google Tee is available in unisex sizing.",
 "link": "http://my.site.com/blacktee/",
 "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
 "contentLanguage": "en",
 "targetCountry": "US",
 "feedLabel": "US",
 "channel": "online",
 "ageGroup": "adult",
 "availability": "in stock",
 "availabilityDate": "2019-01-25T13:00:00-08:00",
 "brand": "Google",
 "color": "black",
 "condition": "new",
 "gender": "male",
 "googleProductCategory": "1604",
 "gtin": "608802531656",
 "itemGroupId": "google_tee",
 "mpn": "608802531656",
 "price": {
  "value": "21.99",
  "currency": "USD"
 },
 "sizes": [
  "Large"
 ]
}

products.update

1 つの商品を更新するには、次のリクエスト URL を PATCH メソッドで使用します。その際、販売者 ID、商品 ID、更新するデータを含む JSON 本文を指定します。products.insert では該当するすべてのフィールドを指定する必要がありますが、products.update では変更するフィールドを指定するだけで済みます。

属性を追加または変更するには、JSON 本文で新しい値を含むフィールドを指定します。この例では、リクエスト本文で指定された商品データで既存の「Black Google T シャツ」の titledescription を更新し、他のフィールドはすべてそのままにします。

PATCH https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId}

products.update のリクエスト本文の呼び出し例:

{
 "title": "Google Tee Black Limited Edition",
 "description": "The Limited Edition Tee is available in unisex sizing and features a retail fit."
}

products.update リクエストで更新できるのは、最上位のフィールドのみです。ネストされたフィールドを更新する場合は、トップレベル オブジェクト全体を指定する必要があります。

この例では、リクエスト本文で指定された商品データで、既存の商品のネストされたフィールドを含む最上位の salePrice オブジェクトを更新します。他のフィールドはすべて変更しません。

PATCH https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId}
{
 "salePrice": {
  "value": "17.99",
  "currency": "USD"
 }
}

リクエストの本文に含まれる他のフィールドを変更せずに、更新する特定のフィールドを選択するには、updateMask を指定します。このクエリ文字列パラメータは、変更するフィールドのカンマ区切りのリストである必要があります。updateMask は、名前付きフィールドのみが更新されることをアサートする場合に役立ちます。updateMask を指定しないと、上記の例で示すように、リクエスト内のすべてのフィールドを更新対象としてマークするのと同じ結果になります。

この例では、リクエスト本文で指定されたそれぞれの商品データで既存の「Black Google Tee」の descriptionavailability のみを更新し、title を含む他のすべてのフィールドはそのままにします。

PATCH https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId}?updateMask=description,availability

products.update のリクエスト本文の呼び出し例:

{
 "title": "Google Tee Black",
 "description": "This Limited Edition is out of print.",
 "availability": "out of stock"
}

updateMask リストにフィールドがあってもリクエストの本文で指定されていない場合、そのフィールドは Product リソース(存在する場合)から削除されます。

この例では、updateMask を使用して salePrice フィールドの値を削除します。

PATCH https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId}?updateMask=salePrice

サンプル リクエストの本文に salePrice フィールドを含めないでください。本文を指定しないか、本文を空にすることもできます。他のフィールドは、updateMask に含まれなければそのまま残ります。

products.custombatch リクエスト内で updateMask を使用するには、リクエストの本文で updateMask を指定する必要があります。

この例では、products.custombatch を使用して、バッチエントリで指定された商品データで既存の「Black Google T シャツ」の priceavailability を更新し、titledescription を含む他のフィールドはすべて変更しません。

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
{
  "entries": [{
    "batchId": 1,
    "merchantId": "MERCHANT_ID",
    "productId": "online:en:US:1111111111",
    "method": "update",
    "product": {
      "title": "Google Tee Black",
      "description": "The Black Google Tee is available in unisex sizing.",
      "availability": "in stock",
      "price": {
        "value": "19.99",
        "currency": "USD"
      }
    },
    "updateMask": "availability,price"
  }]
}

products.delete

1 つの商品を削除するには、products.delete を使用して、サンプル HTTP リクエスト URL、販売者 ID、削除する商品の商品 ID(online:en:US:1111111111 などの REST ID 形式)を指定します。

DELETE https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId}

成功すると、レスポンスの本文のない HTTP Status 204 が返されます。

products.list

products.list には、販売者が Merchant Center データベースに登録しているすべての商品が一覧表示されます。次のリクエスト URL を使用します。

GET https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products

呼び出しが成功すると、resources キーに商品の HTTP 200 と JSON データが返されます。

次の 3 つの商品例が返されます。

{
 "kind": "content#productsListResponse",
 "resources": [
  {
   "kind": "content#product",
   "id": "online:en:US:1111111111",
   "offerId": "1111111111",
   "source": "api",
   "title": "Google Tee Black",
   "description": "The Black Google Tee is available in unisex sizing.",
   "link": "http://my.site.com/blacktee/",
   "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
   "contentLanguage": "en",
   "targetCountry": "US",
   "feedLabel": "US",
   "channel": "online",
   "ageGroup": "adult",
   "availability": "in stock",
   "availabilityDate": "2019-01-25T13:00:00-08:00",
   "brand": "Google",
   "color": "black",
   "condition": "new",
   "gender": "male",
   "googleProductCategory": "1604",
   "gtin": "608802531656",
   "itemGroupId": "google_tee",
   "mpn": "608802531656",
   "price": {
    "value": "21.99",
    "currency": "USD"
   },
   "sizes": [
    "Large"
   ]
  },
  {
   "kind": "content#product",
   "id": "online:en:US:2222222222",
   "offerId": "2222222222",
   "source": "api",
   "title": "Google Tee Green",
   "description": "100% cotton jersey fabric sets this Google t-shirt above the crowd.
    Features the google logo across the chest. Unisex sizing.",
   "link": "http://my.site.com/greentee/",
   "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
   "contentLanguage": "en",
   "targetCountry": "US",
   "feedLabel": "US",
   "channel": "online",
   "ageGroup": "adult",
   "availability": "in stock",
   "availabilityDate": "2019-01-25T13:00:00-08:00",
   "brand": "Google",
   "color": "green",
   "condition": "new",
   "gender": "male",
   "googleProductCategory": "1604",
   "gtin": "608802531649",
   "itemGroupId": "google_tee",
   "mpn": "608802531649",
   "price": {
    "value": "21.99",
    "currency": "USD"
   },
   "sizes": [
    "Medium"
   ]
  },
  {
   "kind": "content#product",
   "id": "online:en:US:3333333333",
   "offerId": "3333333333",
   "source": "api",
   "title": "Google Twill Cap",
   "description": "Classic urban styling distinguishes this Google cap.
    Retains its shape, even when not being worn.",
   "link": "http://my.site.com/blackhat/",
   "imageLink": "https://shop.example.com/.../images/GGOEGHPB071610.jpg",
   "contentLanguage": "en",
   "targetCountry": "US",
   "feedLabel": "US",
   "channel": "online",
   "ageGroup": "adult",
   "availability": "in stock",
   "availabilityDate": "2019-01-07T13:00:00-08:00",
   "brand": "Google",
   "color": "black",
   "condition": "new",
   "gender": "male",
   "googleProductCategory": "173",
   "gtin": "689355417246",
   "mpn": "689355417246",
   "price": {
    "value": "10.99",
    "currency": "USD"
   },
   "sizes": [
    "Medium"
   ]
  }
 ]
}