Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.shopi.lk/llms.txt

Use this file to discover all available pages before exploring further.

shop.reviews.list(productId, limit?)

Returns approved reviews for a product, ordered by newest first.
const reviews = await shop.reviews.list('product-uuid-here', 10);

Parameters

ParamTypeDefaultDescription
productIdstringThe product’s UUID
limitnumber50Max reviews to return (max 100)

Response

Array<{
  id: string;
  product_id: string;
  rating: number;            // 1–5
  review_text: string | null;
  image_url: string | null;
  is_verified_purchase: boolean;
  created_at: string;
}>

Example — Review list with star rating

const reviews = await shop.reviews.list(product.id, 10);

const avgRating = reviews.reduce((sum, r) => sum + r.rating, 0) / reviews.length;
ratingAvg.textContent = avgRating.toFixed(1);

reviews.forEach(review => {
  reviewList.innerHTML += `
    <div class="review">
      <div class="stars">${'★'.repeat(review.rating)}${'☆'.repeat(5 - review.rating)}</div>
      <p>${review.review_text ?? ''}</p>
      ${review.is_verified_purchase ? '<span class="verified">Verified Purchase</span>' : ''}
      <time>${new Date(review.created_at).toLocaleDateString()}</time>
    </div>
  `;
});

shop.reviews.submit(params)

Submits a new review for a product. Reviews require seller approval before appearing publicly.
const result = await shop.reviews.submit({
  product_id: 'product-uuid-here',
  rating: 5,
  review_text: 'Amazing quality!',
  customer_name: 'Jane Doe',
  customer_email: 'jane@example.com',
});

Parameters

ParamTypeRequiredDescription
product_idstringUUID of the product being reviewed
ratingnumberInteger between 1 and 5
review_textstringWritten review
customer_namestringReviewer’s name
customer_emailstringReviewer’s email
image_urlstringURL of an attached image

Response

{ id: string }

Example — Review submission form

reviewForm.addEventListener('submit', async (e) => {
  e.preventDefault();
  submitBtn.disabled = true;

  try {
    await shop.reviews.submit({
      product_id: product.id,
      rating: parseInt(ratingInput.value),
      review_text: reviewTextarea.value,
      customer_name: nameInput.value,
      customer_email: emailInput.value,
    });

    successMsg.textContent = 'Thank you! Your review will appear after approval.';
    reviewForm.reset();
  } catch (error) {
    errorMsg.textContent = 'Failed to submit review. Please try again.';
  } finally {
    submitBtn.disabled = false;
  }
});
Submitted reviews are not immediately visible. They require manual approval from the shop owner in their seller dashboard.