Enabling product sync
Product sync enables buyers to search, sort, and filter products across multiple shops in the marketplace. Product sync enables more customized searching and filtering by product, across shops.
Product sync requires your database to have the relevant information for each product in the marketplace. However, Shopify doesn't fully support product sync out of the box at this time. It's your responsibility to determine how best to build product sync, given the tools that Shopify makes available to you. This guide will provide high-level instructions for building product sync using Shopify's APIs and webhooks.
The following are the primary APIs you can use to build product sync.
The primary APIs you should use are the GraphQL and REST Admin APIs, specifically the REST Admin API's ProductListing
resource. This resource only returns the products published to your channel app instead of all products on the merchant’s shop.
When the merchant first installs your channel app, you can use this API to fetch all products and perform the initial sync with your database.
Access scopes
Anchor link to section titled "Access scopes"Your channel app requires the following access scopes:
read_product_listings
Bulk operation
Anchor link to section titled "Bulk operation"You can also perform a bulk operation query on the GraphQL Admin API's currentAppInstallation
common object query. For example, you can ask for the products
connection on the Publication
object.
The query could look something like the following:
Storefront API
Anchor link to section titled "Storefront API"You can also use the Storefront API to retrieve information about a product, specifically the Product
APIs.
Querying the Products
object will return a list of products that a merchant has published to your channel app.
Querying the ProductVariant
object will return additional product details.
Access scopes
Anchor link to section titled "Access scopes"Your channel app requires the following access scopes:
unauthenticated_read_product_listings
Storefront API versus Admin API
Anchor link to section titled "Storefront API versus Admin API"It's important to consider rate limits when you decide how to build your product sync. The Storefront API is rate-limited by buyer IP address and returns product information that's represented on a merchant's storefront. This is a great way to retrieve real-time information about products from your buyer experience.
The REST Admin API's rate limit is calculated differently and isn't intended to be used from your buyer experience. A merchant's storefront products are represented by the ProductListing
resource, which can be called directly from your channel app or, more commonly, sent using webhooks and saved to your custom service.
Subscribing to webhooks is essential to doing product sync correctly.
You can subscribe to HTTPS webhooks using either the GraphQL Admin API or the REST Admin API. The following are some useful webhook topics, which share only the updates to products that are published to your channel app.
product_listings/add
product_listings/remove
product_listings/update
For supported topics, refer to the GraphQL Admin API and REST Admin API webhook reference pages.
Putting it all together
Anchor link to section titled "Putting it all together"By using the APIs and webhooks, you can maintain your own datastore of all the products available to the marketplace.
You can have a checkpoint
DateTime
stored on your end that will indicate the last time products were synced. Any products that have been updated in Shopify after this time will need to be synced to your datastore.You can query specifically for products with
updated_at
times that are past your checkpointDateTime
, to reduce the query cost and obtain only the products that you need to update on your end.You can use the REST Admin API for an initial product sync, and then subscribe to the appropriate webhooks to ensure any updates to products are synced with your channel app.
You can re-query the REST Admin API using the
product_listings/update
webhook or the bulk queries to ensure products on your end are kept up to date.
Learn how to surface additional product and purchase information in the context of a marketplace.
Share feedback on Marketplace Kit.