Meet Toki Operator

Docs/Wallet SDK

Products

Recently viewed products, product recommendations and products from a collection.

Product data for your own storefront sections: what the customer viewed recently, products picked by your product recommendation rules, and products from a collection. Product and variant IDs are Shopify's numeric IDs as strings, such as "7982301462638".

getRecentlyViewedProducts#

tokiWallet.getRecentlyViewedProducts()→ Promise<RecentlyViewedProducts>

Lists the products the customer viewed recently, newest first.

Toki records a view each time the customer opens a product page in your store. A guest's views are kept in the browser, up to the 50 most recent. A signed-in customer's views are saved to their account, so they follow the customer from device to device, and are combined with the views from this browser. Prices follow the customer's current country and currency.

Returns

Promise<RecentlyViewedProducts>
  • itemsRecentlyViewedProduct[]
    9 fields per item
    • idstring

      Product ID.

    • titlestring
    • handlestring
    • urlstring

      Path of the product page, such as /products/linen-shirt.

    • imagestring

      Image URL.

    • pricenumber | null

      Lowest variant price in cents, such as 4999 for $49.99, or null when the price isn't available. Show display_price to the customer.

    • display_pricestring | null

      price in your store's currency format, such as "$49.99".

    • currencyCodestring | nullOptional

      Currency of price, such as "USD".

    • viewed_atstring

      When the customer last viewed the product, as an ISO 8601 date-time.

Example
const { items } =
  await tokiWallet.getRecentlyViewedProducts()
const recent = items.slice(0, 8)
Result
{
  "items": [
    {
      "id": "7982301462638",
      "title": "Linen Shirt",
      "handle": "linen-shirt",
      "url": "/products/linen-shirt",
      "image": "https://cdn.shopify.com/s/files/1/0601/2345/files/linen-shirt.jpg",
      "price": 4999,
      "display_price": "$49.99",
      "currencyCode": "USD",
      "viewed_at": "2026-10-28T14:03:12.481Z"
    }
  ]
}

addRecentlyViewedProduct#

tokiWallet.addRecentlyViewedProduct(product)→ Promise<void>

Records that the customer viewed a product.

Toki records a view on its own each time a product page loads in your store. Call this when the customer sees a product in another way, such as in a quick view. You can pass the product object from Shopify's Ajax Product API as it is.

For a guest, the view is saved in the browser; for a signed-in customer, it's saved to their account. Viewing a product again moves it to the top of the list.

Arguments

  • productRecentlyViewedProductInputRequired
    6 fields
    • idstring | numberRequired

      Product ID.

    • titlestringRequired
    • handlestringRequired
    • urlstringRequired

      Path of the product page, such as /products/linen-shirt.

    • featured_imagestringRequired

      Image URL.

    • pricenumberRequired

      Lowest variant price in cents, in the currency the customer is shopping in, such as 4999 for $49.99.

Returns

Promise<void>

Nothing, once it's done.

Example
const product = await fetch(
  "/products/linen-shirt.js",
).then((res) => res.json())
await tokiWallet.addRecentlyViewedProduct(product)

getRecommendedProducts#

tokiWallet.getRecommendedProducts({ ruleId })→ Promise<RecommendedProducts>

Lists the products a product recommendation rule picks for the customer.

ruleId is the ID of an active product recommendation rule: the rule's id in the Manage API.

Toki runs the rule's strategies in order and joins their products without duplicates, shuffled if the rule is set to randomize. For a signed-in customer with past orders, co-purchase strategies start from what they bought. Prices are in your store's default currency, such as 49.99. Rejects when no active rule has this ID.

Options

one object
  • ruleIdstringRequired

    Product recommendation rule ID.

Returns

Promise<RecommendedProducts>
  • productsRecommendedProduct[]
    6 fields per item
    • idstring

      Product ID.

    • labelstring

      Product title.

    • imageUrlstring | null

      Image URL.

    • minPricenumber

      Lowest variant price.

    • maxPricenumber

      Highest variant price.

    • variantsRecommendedProductVariant[]
      4 fields per item
      • idstring

        Variant ID.

      • titlestring

        Variant title, or the product title for a product with a single variant.

      • pricenumber
      • imageUrlstring | null

        Image URL.

Example
const { products } =
  await tokiWallet.getRecommendedProducts({
    ruleId: "3f6c1a52-8d0e-4b7a-9c61-2a4e5d7f9b10",
  })
Result
{
  "products": [
    {
      "id": "7982301462638",
      "label": "Linen Shirt",
      "imageUrl": "https://cdn.shopify.com/s/files/1/0601/2345/files/linen-shirt.jpg",
      "minPrice": 49.99,
      "maxPrice": 59.99,
      "variants": [
        {
          "id": "43872109510766",
          "title": "Small",
          "price": 49.99,
          "imageUrl": "https://cdn.shopify.com/s/files/1/0601/2345/files/linen-shirt.jpg"
        }
      ]
    }
  ]
}
read

getCollectionProducts#

tokiWallet.getCollectionProducts({ collectionId })→ Promise<CollectionProducts>

Returns up to 10 products from a collection, picked at random each time.

collectionId is the collection's numeric ID, such as "412093284590". Toki picks from the collection's products that are published to your online store and available for sale, and products you add to the collection show up within an hour. Prices are decimal strings in your store's default currency, such as "49.99". Resolves an empty list when no collection has this ID.

Options

one object
  • collectionIdstringRequired

    Collection ID.

Returns

Promise<CollectionProducts>
  • productsCollectionProduct[]
    8 fields per item
    • idstring

      Product ID.

    • handlestring
    • urlstring

      Product page URL, such as https://acme.com/products/linen-shirt.

    • titlestring | null
    • imagestring | null

      Featured image URL.

    • minPricestring | null

      Lowest variant price.

    • maxPricestring | null

      Highest variant price.

    • variantsCollectionProductVariant[]

      Up to 10 variants that are available for sale.

      3 fields per item
      • idstring

        Variant ID.

      • titlestring

        "Default Title" for a product with a single variant.

      • pricestring | null
Example
const { products } =
  await tokiWallet.getCollectionProducts({
    collectionId: "412093284590",
  })
Result
{
  "products": [
    {
      "id": "7982301462638",
      "handle": "linen-shirt",
      "url": "https://acme.com/products/linen-shirt",
      "title": "Linen Shirt",
      "image": "https://cdn.shopify.com/s/files/1/0601/2345/files/linen-shirt.jpg",
      "minPrice": "49.99",
      "maxPrice": "59.99",
      "variants": [
        {
          "id": "43872109510766",
          "title": "Small",
          "price": "49.99"
        }
      ]
    }
  ]
}