Shopping Content Service

  • The Shopping Content Service allows Apps Script users to interact with the Google Content API for Shopping to manage product listings and Merchant Center accounts.

  • This service is an advanced service in Apps Script and utilizes the same objects, methods, and parameters as the public Google Content API for Shopping.

  • Sample code is provided demonstrating how to insert single or batch products, list products, and update account-level taxes using the Shopping Content Service.

  • Further details and support can be found in the provided reference documentation and support guide for the Google Content API for Shopping.

The Shopping Content Service lets you use theGoogle Content API for Shopping inApps Script. This API gives Google Merchant Center users the abilityto upload and manage their product listings and manage their MerchantCenter accounts.

For detailed information on this service, see thereference documentation for theGoogle Content API for Shopping. Like all advanced services in Apps Script, theShopping Content Service utilizes the same objects, methods, and parametersas the public API.

Note: This is an advanced service that must beenabled before use.

Reference

For detailed information on this service, see thereference documentation for theGoogle Content API for Shopping API. Like all advanced services in Apps Script,the advanced Sheets service uses the same objects, methods, and parameters asthe public API. For more information, seeHow method signatures are determined.

To report issues and find other support, see theGoogle Content API for Shopping support guide.

Sample code

We now show how to use a few features of the Shopping Content Service.

Insert product

This example demonstrates how to insert a single product into a givenmerchant center account.

advanced/shoppingContent.gs
/** * Inserts a product into the products list. Logs the API response. */functionproductInsert(){constmerchantId=123456;// Replace this with your Merchant Center ID.// Create a product resource and insert itconstproductResource={offerId:"book123",title:"A Tale of Two Cities",description:"A classic novel about the French Revolution",link:"http://my-book-shop.com/tale-of-two-cities.html",imageLink:"http://my-book-shop.com/tale-of-two-cities.jpg",contentLanguage:"en",targetCountry:"US",channel:"online",availability:"in stock",condition:"new",googleProductCategory:"Media > Books",productType:"Media > Books",gtin:"9780007350896",price:{value:"2.50",currency:"USD",},shipping:[{country:"US",service:"Standard shipping",price:{value:"0.99",currency:"USD",},},],shippingWeight:{value:"2",unit:"pounds",},};try{response=ShoppingContent.Products.insert(productResource,merchantId);// RESTful insert returns the JSON object as a response.console.log(response);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log("Failed with error: $s",e.error);}}

List products

This example demonstrates how to list your products for a given merchantcenter account.

advanced/shoppingContent.gs
/** * Lists the products for a given merchant. */functionproductList(){constmerchantId=123456;// Replace this with your Merchant Center ID.letpageToken;letpageNum=1;constmaxResults=10;try{do{constproducts=ShoppingContent.Products.list(merchantId,{pageToken:pageToken,maxResults:maxResults,});console.log(`Page${pageNum}`);if(products.resources){for(leti=0;i <products.resources.length;i++){console.log(`Item [${i}] ==>${products.resources[i]}`);}}else{console.log(`No more products in account${merchantId}`);}pageToken=products.nextPageToken;pageNum++;}while(pageToken);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log("Failed with error: $s",e.error);}}

Batch insert products

This example usesProducts.custombatchto insert three products at the same time.

advanced/shoppingContent.gs
/** * Batch updates products. Logs the response. * @param  {object} productResource1 The first product resource. * @param  {object} productResource2 The second product resource. * @param  {object} productResource3 The third product resource. */functioncustombatch(productResource1,productResource2,productResource3){constmerchantId=123456;// Replace this with your Merchant Center ID.custombatchResource={entries:[{batchId:1,merchantId:merchantId,method:"insert",productId:"book124",product:productResource1,},{batchId:2,merchantId:merchantId,method:"insert",productId:"book125",product:productResource2,},{batchId:3,merchantId:merchantId,method:"insert",productId:"book126",product:productResource3,},],};try{constresponse=ShoppingContent.Products.custombatch(custombatchResource);console.log(response);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log("Failed with error: $s",e.error);}}

Update account-level taxes

This sample code usesAccounttax to update theaccount-level tax information for a Merchant Center account. See ourAPI guide for moreinformation about account-level tax and shipping.

advanced/shoppingContent.gs
/** * Updates content account tax information. * Logs the API response. */functionupdateAccountTax(){// Replace this with your Merchant Center ID.constmerchantId=123456;// Replace this with the account that you are updating taxes for.constaccountId=123456;try{constaccounttax=ShoppingContent.Accounttax.get(merchantId,accountId);console.log(accounttax);consttaxInfo={accountId:accountId,rules:[{useGlobalRate:true,locationId:21135,shippingTaxed:true,country:"US",},{ratePercent:3,locationId:21136,country:"US",},{ratePercent:2,locationId:21160,shippingTaxed:true,country:"US",},],};console.log(ShoppingContent.Accounttax.update(taxInfo,merchantId,accountId),);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log("Failed with error: $s",e.error);}}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.