Using the Sell Anything API
The Sell Anything API requires you to explicitly request tracking for individual products and stores. This guide will walk you through the steps required to request tracking for products and stores, how to retrieve information about them once they have been tracked, and how to maintain your own copy of the product data.
Tutorial
Step 1: Request tracking for products and stores
Rye has three different API operations that can be used to request tracking for products and stores:
-
Used to request individual Amazon products. This operation returns a
productId
field which should be stored on your end for the next step. -
Used to request individual Shopify products. This operation returns both a
canonicalDomain
andproductId
field, both of which should be stored on your end for use in the next step. -
Used to request entire Shopify stores. This operation returns a
canonicalDomain
value which you should keep track of for the next step.
For each product or store you selected in the previous step, your technical implementation team should send a GraphQL request which hits the relevant API operation. For instance, if you wanted to sell these Gymshark leggings you would send the following GraphQL request:
This request returns the fields canonicalDomain
and productId
. Both of these fields should be stored on your end, as they are useful for subsequent API operations. canonicalDomain
can be used with productsByDomainV2
, and productId
can be used with productByID
to retrieve information about this product at a later date.
These mutations will add your requested product or store to a queue, and it will eventually be processed by our system. This process can take up to 24 hours, but usually completes within a few minutes. You can verify that the data has pulled through to Rye’s systems by querying for the product.
We have an in depth tutorial on how to track products and stores using the Sell Anything API here.
Step 2: Query product information
After you have requested tracking for a product or store, you can retrieve information using the following API operations:
-
Used to retrieve information about a specific product. This works for both Amazon and Shopify products. You will need a
productId
value here, which you should have stored from Step 1. -
Used to retrieve all products from a specific store. This works for Shopify stores. You will need a
canonicalDomain
value here, which you should have stored from Step 1.
We generally recommend using productsByDomainV2
—unless you are selling Amazon products—as it allows you to query product data efficiently in bulk as opposed to fetching everything one-by-one. The following GraphQL documents will retrieve information about the Gymshark leggings we requested in Step 1:
Forgot to store the productId
or canonicalDomain
values from Step 1?
You can call the relevant request operation again; requesting the same product or store URL multiple times will only count once towards your API usage limits.
Note that there are many more fields available on a product than just the id
and title
. Check out the following API reference pages for a complete listing of fields available to query:
Step 3: Keep your product data up to date
Now that you’ve requested tracking and have verified that you are able to query product information, you need to decide how you want this product information to flow through to your frontend. There are two main strategies for doing this:
- Server-side sync (recommended). Under this strategy, you will perform a one-off sync of all products you are tracking with Rye into your own database. After performing the initial data pull, you will keep your copy of the data up to date by receiving webhooks from Rye when product catalog data changes. This option is recommended as it affords you the most control over the data and allows you to query it in a way that is most efficient for your use case.
- Client-side queries. Under this strategy, you will query Rye’s API directly from your frontend to retrieve product data. This is simpler, but significantly less flexible.
Server-side sync (recommended)
To implement server-side sync using webhooks, you will need to do the following:
- Set up webhooks per our guide.
- Handle the
PRODUCT_UPDATED
webhook event.
We currently do not fire a webhook when Sell Anything API products are deleted. In order to handle this edge case, you will need to periodically query Rye’s API for products you are tracking and delete them from your database if they are no longer present. Our recommendation is to run this cleanup operation once every six hours.
When you requested products and stores in the previous step, Rye automatically created subscriptions on your account for updates to those products. There is no further action required on your part to receive these updates once you have requested tracking and set up a webhook endpoint.
Client-side queries
Client-side queries can be performed via JWT authentication. This method is mentioned for completeness’ sake, but for gifting platforms we strongly recommend server-side sync as it avoids potential privacy issues down the line. We have more in-depth discussion on this in the next section, where we explain how to place gifting orders.
Congratulations!
At this point you have successfully started tracking all of your products and stores inside Rye’s API, and are able to pull product catalog data through to your frontend application. The next step from here is to implement a checkout flow so that users can purchase products and you can start earning revenue.
Was this page helpful?