Retail API interactive tutorials

Stay organized with collections Save and categorize content based on your preferences.

This page lists a set of the Google Retail API interactive tutorials that include actions that can be run in the Google Cloud Shell Editor. With this tool you can write, build, test, run, and debug cloud native applications directly from your browser.

Overview

Try different tutorials depending on what you'd like to learn:

Import catalog information

These tutorials describe how to import your catalog information to the Retail API and keep it up to date.

Import catalog data from BigQuery

This tutorial shows you how to use a BigQuery table to import large amounts of catalog data with no limits.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Import catalog data from Cloud Storage

This tutorial shows you how to import a large number of items to a catalog.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Import catalog data inline

This tutorial shows how to import products into a catalog inline.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Manage catalog information

These tutorials describe how to manage your product information after you have imported a catalog into the Retail API. You can read, write, and delete products in your catalog.

Learn how to call the Google Cloud Retail API with your language of choice.

Create/Get/Update/Delete product tutorial

This tutorial shows you how to use the Retail API Product Service methods, which perform the following actions:

  • Create a product
  • Get a product
  • Update a product
  • Delete a product

For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Create product tutorial

This tutorial shows you how to create a single product.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Get product tutorial

This tutorial shows you how to retrieve a product item.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Update product tutorial

This tutorial shows you how to update a product in a catalog.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Delete product tutorial

This tutorial shows you how to delete a product from a catalog.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Import historical user events

These tutorials describe how to import user event data from past events in bulk. Retail API models require user event data for training.

Import events from Cloud Storage tutorial

This tutorial shows how to import user events from Cloud Storage.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Import events from BigQuery tutorial

This tutorial shows how to import user events from BigQuery.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Import events inline tutorial

This tutorial shows how to import user events data inline.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Record real-time user events

These tutorials describe how to record, view or remove real-time user events. The Retail API uses real-time user events to generate recommendations and search results. Recording as many types of user events as possible with valid product information increases the quality of your results.

Write user events tutorial

This tutorial shows how to record user events using the userEvents.write method.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Rejoin user events tutorial

This tutorial shows how to rejoin user events by making a POST request to the userEvents:rejoin endpoint.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Remove user events tutorial

This tutorial shows how to purge user events.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Search Tutorials

The Retail API search() method is used to search over the catalog according to the search query and other parameters, such as filter, facet, or order_by.

By default, the search response contains a reasonable number of results ordered by relevance.

Querying tutorial

This tutorial shows you how to send a simple search query to the Retail service and analyze the response.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Pagination tutorial

This tutorial shows how to control pagination in the search request. When a shopper looks for products in a shop, they can improve their navigation through search results. For example, they can limit the number of items in the search response by using the page size feature or jump to their preferred page by using the offset feature.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Query expansion tutorial

This tutorial shows you how to enable the query expansion feature. When a shopper uses an ambiguous or a multi-word search phrase, they can get an empty response. After turning on query expansion, Retail Search analyzes the request and returns the expanded list of products based on the parsed search query.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Filtering tutorial

This tutorial demonstrates the filtering feature. It lets you fine-tune search requests according to your or your customer's needs. You can filter by single or multiple fields, filter by text or numeric fields, or both. You can use an expression language to construct a predicate for each field or combine different expressions using logical operators. For example, a shopper looking for shoes can use filters to narrow their search to their preferred brand and color.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Ordering tutorial

This tutorial shows how to order items in a search response. When a shopper looks for a product on your site, Retail Search can show results ordered by multiple fields. For example, a shopper is searching for a dress with the best price and discount. Price and discount are multiple fields here. Retail Search will show the shopper dresses ordered by price, and for the dresses with the same price, ordered by discount.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Boosting tutorial

This tutorial shows some examples of product boosting in search results. With boosting, you can apply a boost to a product to prioritize or deprioritize it in the search results.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Redirect control tutorial

This tutorial shows you how to use the redirect control. The redirect control lets you specify a URL to which you can redirect users when they use a specific search query. For example, if a user requests "sustainable manufacturing products", you can redirect them to a page containing the environmental brands that you are working with.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Update inventory for Retail Search

While the Product create, read, update, and delete (CRUD) methods are used to broadly modify a Product's attributes, there is a set of Product methods that can be used for updating inventory-specific fields with varying levels of granularity. The following Product fields are considered inventory fields:

  • Product.price_info
  • Product.availability
  • Product.available_quantity
  • Product.fulfillment_info

Add fulfillment tutorial

This tutorial shows how to update product fulfillment information using the AddFulfillmentPlaces method. In this way, Retail Search can show updates where products are available and orders can be fulfilled. For example, a shopper is looking for blue jeans in a shop but they're out of stock. The moment the jeans are in stock again at this shop or any other shop, Retail Search shows the updates and the shopper can proceed with their order.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Remove fulfillment tutorial

This tutorial shows how to update product fulfillment information using the [RemoveFulfillmentPlaces][remove-fulfillment-places] method. In this way, Retail Search can show updates where products aren't available and orders can't be fulfilled. For example, a shopper is looking for blue jeans in a shop. If the jeans become out of stock in this shop, Retail Search shows the updates and the shopper can't proceed with their order.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me

Set inventory tutorial

This tutorial shows how to push inventory updates using the SetInventory method instead of updating the entire product.


For step-by-step guidance on this task directly in Cloud Shell Editor, click Guide me:

Guide me