POST /recommendations to rank products from a Shopify or Custom JavaScript catalog. Call this endpoint from a trusted backend with your virtual.fit API key.
Send requests to https://api.virtual.fit.
Request
- Custom JavaScript
- Shopify
Body fields
Use the same stable IDs that you send during catalog sync and commerce tracking. For Shopify, send the full GraphQL product ID, such as
gid://shopify/Product/9876543210. Unknown or disabled candidate IDs are ignored. If candidate_product_ids is present, it must be an array containing at least one ID, and at least one supplied ID must resolve to an enabled product; otherwise the request fails with 400. Omitting the field leaves ranking open to the enabled catalog. A request fails when none of its ranking context is prepared.
The JSON body is limited to 1 MiB. Each product ID and shopper_id is limited to 256 UTF-8 bytes. Requests over a body, identifier, or array limit fail with 413.
Response
rank defines the display order. score is optional and meaningful only within that response. Do not re-sort items by score or compare scores across requests.
Each item includes the selected target plus the product fields needed for a
card. It deliberately omits full galleries, sibling variants, and complete
option matrices.
virtual.fit returns at most one item per product. A visually best color can be
returned as
visual_group without inventing a size; an exact in-stock variant
can be returned as variant.
unknown_context_ids contains supplied context IDs that are not prepared in the selected catalog. The request can still succeed when at least one other context product is available.
Same-category recommendations
Send exactly one context product:candidate_product_ids when your backend has a more specific constraint, such as an in-stock collection or shopper market.
You do not need to send a category. virtual.fit categorizes prepared products automatically. Keep Custom JavaScript product titles and images current so similar can return relevant alternatives.
Recommendation eligibility is broader than try-on eligibility. Apparel accessories such as shoes, bags, and jewellery can appear in recommendation results even when they are not supported as virtual try-on items.
Intent semantics
complete_the_look
The hosted fitting room uses this intent automatically. Call it directly for another outfit placement or your own outfit builder. It excludes categories already represented by known context products.
If no eligible compatible product remains, items can be empty. Treat that as a valid result instead of widening it to unrelated products.
Send one to five products already selected for the outfit. Send the current cart separately when it should also influence relevance:
product_ids determines which outfit categories are already occupied. cart_product_ids improves the ranking and is excluded from results, but a bag sitting in the cart does not prevent the outfit builder from recommending another bag.
likely_purchases
Use this for “You may also like,” cart, post-add-to-cart, and general cross-sell placements. It uses the same current-product context and learned purchase behavior, but it does not remove categories already represented in that context:
likely_purchases accepts a current product, selected products, a cart, or any combination of them. All supplied products are excluded automatically. Your backend must send the latest full cart in cart_product_ids; it affects that request immediately. Synced cart and purchase events can improve recommendations over time.
Error handling
Rate limits
The recommendations API uses short-term safety thresholds of60 requests per shopper per minute and 6,000 requests per store per minute. Treat these values as usage guidance rather than exact quotas, and always handle 429 responses.
Send shopper_id on shopper-facing backend requests. Different shoppers then use separate allowances even when every request leaves your infrastructure through the same IP address. Authenticated requests are not limited by the merchant backend’s shared egress IP.
The hosted Shopify and Custom JavaScript browser integrations supply shopper identity automatically. Direct browser requests also use a short-term safety threshold of 600 requests per IP per minute. Treat it as usage guidance and handle 429 responses.
Rate-limited requests return 429 with Retry-After and retry_after_seconds. Wait for that duration before retrying. Keep your existing merchandising order visible while waiting.
Keep your current merchandising order as a fallback. A temporary recommendation failure should not hide eligible products or block checkout.