Inventory API (v2 only)

The Inventory API is used to update price and availability of a product in your Merchant Center account. While the products.insert API method has more functionality than the Inventory API, the Inventory API is recommended for updating pricing and availability of existing offers.

Product update relationship chart

You can create products in the Google Merchant Center database with either a feed or the Products API. Likewise, you can update your products with a supplemental feed, the Product API, or the Inventory API. This guide explains how to use the Inventory API for this purpose.

The Inventory API is used to update your products. Attributes that tend to change often (such as quantity, sellOnGoogleQuantity, availability, price, and salePrice) can be set using the inventory.set method. The inventory.custombatch method allows you to perform set calls on many products at the same time, which saves time and resources.

The inventory.set method is a better choice for updating products than the products.insert method because you are allowed more calls. The number of inventory calls you can make is posted in the Rate Limits document. If you are able to use the Inventory API instead of the Products API to update the sellOnGoogleQuantity for a given product, then you should do so.

Online vs. local

Some attributes can only be set for "online" products and some can only be set for "local" products. In this context "online" means Shopping Actions (SA), and Product Listing Ads (PLA). Also in this context, "local" means Local Inventory Ads (LIA). Throughout this document, "online" and "LIA" are used to refer to these two categories.

Inventory set

Use the inventory.set method to update an existing collection of products (one offer per call), that were added using products.insert. You can't add new products using inventory.set, rather, you use it to update an existing product that you added with the Products API. Refer to the Inventory.setpage for a list of attributes that are set with this API information.

The pickup and instoreProductLocation attributes are only used for Local Inventory Ads products. The sellOnGoogleQuantity are only set for online products (while this can be set for PLA, it's only actually relevant to SA enabled products). Some fields in the Inventory.set table, have the following subfields: price, salePrice, and loyaltyPoints.

Example body for online product

Example URL For inventory.set method for online product:

https://www.googleapis.com/content/v2/{merchantID}/inventory/online/products/{productid}

The productid in the URL should be the REST ID consisting of the channel ("online" or "local"), the language code, the country code, and the offerId:

{
  "inventory": {
    "salePrice": {
      "currency": "USD",
      "value": "225.72"
    },
    "sellOnGoogleQuantity": "1",
    "availability": "out of stock",
    "kind": "content#inventory",
    "price": {
      "currency": "USD",
      "value": "238.13"
    }
  },
  "productId": "online:en:US:999999",
  "storeCode": "online"
}

Example body for LIA product

Updates to LIA products provide per store information on the product.

Example URL for inventory.set method for LIA product:

https://www.googleapis.com/content/v2/{merchantID}/inventory/1301234/products/{productid}

Example of inventory.set for one LIA product:

{
  "price": {
    "value": "15.00",
    "currency": "USD"
  },
  "availability": "in stock",
  "salePrice": {
    "value": "12.00",
    "currency": "USD"
  },
  "salePriceEffectiveDate": "2019-01-10T11:07:31+0100 ,2019-01-31T11:07:31+0100",
  "quantity": 5,
  "pickup": {
    "pickupMethod": "buy",
    "pickupSla": "multi day"
  },
  "instoreProductLocation": "Milpitas",
  "loyaltyPoints": {
    "name": "Eat A Lot, Spend A Lot",
    "pointsValue": 1,
    "ratio": 0.05
  }
}

Inventory custombatch

The inventory.custombatch method allows you to make multiple inventory.set calls at once. This has the advantage of taking less time and using less computer resources because it saves you from having to make and break multiple connections to the API servers.

Example of inventory.custombatch for two products:

{
  "entries": [{
      "batchId": 1,
      "merchantId": 123453678,
      "productId": "local:en:US:0",
      "storeCode": "7777777",
      "inventory": {
        "kind": "content#inventory",
        "price": {
          "value": "15.00",
          "currency": "USD"
        },
        "availability": "in stock",
        "salePrice": {
          "value": "12.00",
          "currency": "USD"
        },
        "salePriceEffectiveDate": "2019-01-10,2019-01-31",
        "installment": {
          "months": 24,
          "amount": {
            "value": "1.00",
            "currency": "USD"
          }
        },
        "quantity": 5,
        "pickup": {
          "pickupMethod": "buy",
          "pickupSla": "multi day"
        },
        "instoreProductLocation": "Milpitas",
        "loyaltyPoints": {
          "name": "Eat A Lot, Spend A Lot",
          "pointsValue": 1,
          "ratio": 0.05
        }
      }
    },
    {
      "batchId": 2,
      "merchantId": 1222222,
      "productId": "online:en:US:0",
      "storeCode": "online",
      "inventory": {
        "kind": "content#inventory",
        "price": {
          "value": "15.00",
          "currency": "USD"
        },
        "availability": "in stock",
        "salePrice": {
          "value": "12.00",
          "currency": "USD"
        },
        "salePriceEffectiveDate": "2019-01-10,2019-01-31",
        "sellOnGoogleQuantity": 5,
        "installment": {
          "months": 24,
          "amount": {
            "value": "1.00",
            "currency": "USD"
          }
        },
        "loyaltyPoints": {
          "name": "Eat A Lot, Spend A Lot",
          "pointsValue": 1,
          "ratio": 0.05
        },
        "customLabel0": "label0",
        "customLabel1": "label1",
        "customLabel2": "label2",
        "customLabel3": "label3",
        "customLabel4": "label4"
      }
    }
  ]
}

Testing the Inventory API

First, you have to have some items provided to your Merchant Center that you can change. To use the Try this API in the reference, fill out the form with your merchant ID, a REST ID for a real item, and a valid request body (either modify a body in this document or use the Try this API body editor to create one).

Since all items are in production, care should be taken to avoid changing anything important on items that are live. We recommend that you change attributes for products that you aren't currently using or change values of an item that is out of stock to mitigate the possibility of unforeseen issues.

Summary

In conclusion, use the products.insert method to create products in the system and the inventory.set method to update the availability and price status of those products.

If you are updating many products at a time, consider using the inventory.custombatch method.

Typ zpětné vazby...

Content API for Shopping