Skip to main content

Overview

The Products API provides complete CRUD operations for managing an e-commerce product catalog. Returns ProductInstance objects with direct property access.

Direct Access

Access properties with product.name not product.data.name

Array Methods

Use .map(), .filter() on search results

Instance Methods

Built-in update(), save(), and delete()

Iteration

Use for...of loops

Return Shape Reference

Products.search() and Products.get() do NOT return arrays with a .data property. They return instance wrappers that are directly iterable.
Quick examples:

Methods

Search products by name or description using semantic search.
string
required
Search query to match against product names and descriptions
Returns: ProductSearchInstance - Array-like collection with direct access to products via .products property Example:

get()

Retrieve products with pagination and optional filtering.
ProductFilterOptions:
number
default:1
Page number (1-indexed)
number
default:10
Number of products per page
object
MongoDB-style filter object to query product data fields
Returns: ProductPaginationInstance - Array-like collection with pagination support Examples:
Filter Operators: The filter supports MongoDB-style operators:

getById()

Get a specific product by ID.
Returns: ProductInstance with direct property access and methods Example:

create()

Create a new product.
string
required
Product name
number
required
Product price
string
Product category
string
Stock keeping unit
boolean
default:true
Whether product is in stock
string
Product description
Returns: ProductInstance with direct property access and methods Example:

update() (Instance Method)

Update an existing product via an instance. Use product.update() on a retrieved product — there is no static Products.update() method.
object
required
Partial product data to update
Example:

save() (Instance Method)

Save the current state of the product to the server. This is a convenience method that persists all changes made to the product instance.
Returns: Promise resolving to true if successful Example:
New in Latest Version: The save() method provides a simpler workflow - modify properties then save, rather than calling Products.update() with the product ID.

delete()

Delete a product.
Example:

ProductInstance

All product methods return ProductInstance objects with: Direct Property Access:
Instance Methods:
Backward Compatible:

Complete Examples

Search Tool

Create Product Tool

Update Stock Tool

Use Cases

E-commerce Catalog

Inventory Management

Filtering Products

Product Recommendations

Search vs Filter

Use Products.search() for semantic/fuzzy matching:
  • “laptop for students”
  • “wireless headphones”
  • Natural language queries

Best Practices

Always check if product exists:
If product results don’t look right, log the raw return to see the actual shape:
Then run lua logs --type skill --limit 5 after a test message to inspect the output. See the Debugging Skills guide for the full workflow.

Next Steps

Baskets API

Add products to shopping carts

Product Examples

See complete tool examples

Debugging Skills

Inspect runtime return values