โหมดกลุ่ม

คุณสามารถใช้ custombatch เพื่อ insert, get หรือ delete ผลิตภัณฑ์หลายรายการพร้อมกันในการเรียก API ครั้งเดียว

ใช้ URL คำขอต่อไปนี้เพื่อเรียก API แบบกลุ่มที่กำหนดเอง

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

เนื้อหาของคำขอมีพารามิเตอร์ที่เฉพาะเจาะจง ได้แก่ batchId, merchantID และ method

ใช้ productId เฉพาะในกรณีที่ดำเนินการ get หรือ delete ระบบไม่จำเป็นต้องใช้ productId ในการเรียก API insert สำหรับ custombatch

custombatch:insert

URL คำขอต่อไปนี้ใช้เพื่อเรียก products.custombatch method=insert

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

หากต้องการแทรกผลิตภัณฑ์ใหม่ 2 รายการ ให้ระบุ batchId สำหรับผลิตภัณฑ์แต่ละรายการ, merchantId ของผู้ขายที่ได้รับอนุญาตให้เรียก API และเมธอด insert

ในตัวอย่างต่อไปนี้ ค่า batchId คือ 1111 และ 1112 ตามลำดับ ซึ่งเป็นตัวระบุที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์แต่ละรายการ merchantId: 1234567 คือผู้ขายที่ได้รับอนุญาตให้เรียก API และเมธอด คือ get, delete หรือ insert

insert จะสร้างผลิตภัณฑ์ใหม่ หากมีค่าสำหรับแอตทริบิวต์ channel, contentLanguage, offerId และ feedLabel สำหรับผลิตภัณฑ์ที่ระบุ เมธอดนี้จะอัปเดตรายการและแทนที่ข้อมูลทั้งหมดจากการเรียก API ก่อนหน้าสำหรับผลิตภัณฑ์

ต่อไปนี้คือตัวอย่างเนื้อหา JSON สำหรับ insert เสื้อยืด 2 ตัวลงในฐานข้อมูล Merchant Center โดยใช้การเรียก API ครั้งเดียว

{
  "entries": [
    {
      "batchId": 1111,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "1111111111",

        "title": "Google Tee Black",
        "description": "The Black Google Tee is available in unisex sizing and
        features a retail fit.",
        "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"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    },
    {
      "batchId": 1112,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "2222222222",

        "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"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    }
  ]
}

การเรียก API ที่สำเร็จจะแสดงรหัส HTTP 200 และการตอบกลับ JSON ซึ่งรวมถึงผลิตภัณฑ์ที่แทรก รูปแบบ JSON ที่แสดงผลจะคล้ายกับตัวอย่างต่อไปนี้

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1111,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and
    features a retail fit.",
    "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"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1112,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "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"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}

custombatch:get

URL คำขอต่อไปนี้จะเรียก products.custombatch ด้วย method=get

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

หากต้องการรับผลิตภัณฑ์ ให้ระบุ batchId ที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์ในการเรียก API, merchantId ของผู้ขายที่ได้รับอนุญาตให้เรียก API, เมธอด get และ productId ของผลิตภัณฑ์ที่จะดึงข้อมูล

ต่อไปนี้คือตัวอย่างเนื้อหาของคำขอ JSON สำหรับการดึงข้อมูลผลิตภัณฑ์ 2 รายการที่แทรกโดยใช้ตัวอย่าง custombatch:insert ก่อนหน้า ซึ่งระบุโดยค่า productId batchId จะไม่ซ้ำกันสำหรับแต่ละรายการในรายการ

{
  "entries": [
    {
      "batchId": 1113,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1114,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:2222222222"
    }
  ]
}

การเรียกนี้จะแสดงรหัส HTTP 200 และเนื้อหาการตอบกลับต่อไปนี้

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1113,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and features a retail fit.",
    "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"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1114,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "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"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}

custombatch:delete

URL คำขอต่อไปนี้ใช้เพื่อเรียก products.custombatch ด้วย method=delete

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

หากต้องการลบผลิตภัณฑ์ ให้ระบุ batchId ที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์ในการเรียก API นี้, merchantId ของผู้ขายที่ได้รับอนุญาตให้เรียก API นี้, เมธอด delete และ productId ของผลิตภัณฑ์ที่จะลบ

{
  "entries": [
    {
      "batchId": 1115,
      "merchantId": 1234567,
      "method": "delete",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1116,
      "merchantId": 1234567,
      "method": "delete",
      "productId": "online:en:US:2222222222"
    }
  ]
}

การเรียกนี้จะแสดงรหัส HTTP 200 และค่า batchId ของรายการที่ลบ

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1115
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1116
  }
 ]
}