Public API (for the React storefront)
Base URL: https://mobile-ivory-crab-19.hostingersite.com. All endpoints return JSON, allow CORS (set CORS_ORIGINS in .env.local), and need no authentication yet. Errors look like { "error": "message", "details": … } with a 4xx status. Submissions are rate-limited per IP. The admin API (/api/admin/*) uses the CMS login cookie. See docs/API.md in the project for the full reference.
/api/v1/reviews— List reviews for a productApproved reviews of the product. If the product is in a group, reviews of all products in the group are pooled, newest first. Includes the rating summary.
| slug | productId | required: identify the product |
| page, limit | pagination (limit max 50, default 10) |
| sort | newest (default) | oldest | highest | lowest | helpful | featured | top (featured → most helpful → newest) |
| rating | 1–5: only reviews with this star rating |
| media | 1: only reviews with photos/videos |
| verified | 1: only verified purchases |
| scope | product: ignore the group, show only this product's reviews |
| summary | 0: skip the summary block |
GET https://mobile-ivory-crab-19.hostingersite.com/api/v1/reviews?slug=cotton-kurta-blue&page=1&limit=10
{
"product": { "productId": "101", "slug": "cotton-kurta-blue", "name": "Cotton Kurta - Blue", "image": "…", "url": "…" },
"group": { "id": "…", "name": "Cotton Kurta", "slug": "cotton-kurta" },
"summary": {
"average": 4.4, "count": 128,
"distribution": { "1": 3, "2": 4, "3": 10, "4": 30, "5": 81 },
"distributionPercent": { "1": 2, "2": 3, "3": 8, "4": 23, "5": 63 },
"criteria": [
{ "key": "quality", "label": "Quality", "average": 4.6, "count": 120 },
{ "key": "price", "label": "Price", "average": 4.1, "count": 118 }
],
"withMediaCount": 42
},
"reviews": [{
"id": "…", "rating": 5, "title": "Loved it", "body": "…",
"criteria": [{ "key": "quality", "label": "Quality", "rating": 5 }],
"media": [{ "type": "image", "url": "https://mobile-ivory-crab-19.hostingersite.com/uploads/reviews/2025/06/….jpg" }],
"author": { "name": "Riya", "location": "Pune" },
"verifiedPurchase": true, "featured": false, "helpfulCount": 3,
"publishedAt": "2025-06-01T10:00:00.000Z",
"product": { "productId": "102", "slug": "cotton-kurta-red", "name": "Cotton Kurta - Red" },
"reply": { "body": "Thank you!", "repliedAt": "…" }
}],
"pagination": { "page": 1, "limit": 10, "total": 128, "totalPages": 13 }
}/api/v1/reviews/summary— Rating summary onlyLightweight call for the product page header. summary = pooled group rating, productSummary = this product only.
| slug | productId | required |
GET https://mobile-ivory-crab-19.hostingersite.com/api/v1/reviews/summary?productId=101
{ "product": {…}, "group": {…} | null, "summary": {…}, "productSummary": {…} }/api/v1/summaries— Ratings for many products (listing pages)Average + count for up to 200 products in one call, e.g. to show stars on a category page.
| productIds / slugs | comma separated |
GET https://mobile-ivory-crab-19.hostingersite.com/api/v1/summaries?productIds=101,102,205
{ "items": [ { "productId": "101", "slug": "…", "average": 4.4, "count": 128, "distribution": {…} } ] }/api/v1/reviews/media— Customer photos & videos galleryAll media from approved reviews of the product/group, newest first.
| slug | productId | required |
| type | image | video (optional) |
| page, limit | default limit 30 |
GET https://mobile-ivory-crab-19.hostingersite.com/api/v1/reviews/media?slug=cotton-kurta-blue&type=image
{ "media": [ { "type": "image", "url": "…", "reviewId": "…", "rating": 5, "author": "Riya", "publishedAt": "…" } ], "pagination": {…} }/api/v1/form-config— Review form configurationThe dynamic rating fields (criteria) to show for this product, plus validation rules and media limits. Build the “Write a review” form from this.
| slug | productId | required |
GET https://mobile-ivory-crab-19.hostingersite.com/api/v1/form-config?slug=cotton-kurta-blue
{
"product": {…},
"criteria": [
{ "key": "quality", "label": "Quality", "description": "", "required": true },
{ "key": "delivery_time", "label": "Delivery time", "description": "", "required": false }
],
"rules": { "ratingScale": 5, "requireEmail": true, "requireTitle": false, "minBodyLength": 0, "maxBodyLength": 5000,
"maxImages": 6, "maxVideos": 2, "maxImageMB": 5, "maxVideoMB": 50,
"acceptedImageTypes": ["image/jpeg", …], "acceptedVideoTypes": ["video/mp4", …], "moderation": "manual" }
}/api/v1/uploads— Upload photos / videosmultipart/form-data with one or more files in the field "files". Returns URLs to send with the review.
const fd = new FormData();
files.forEach(f => fd.append("files", f));
await fetch("https://mobile-ivory-crab-19.hostingersite.com/api/v1/uploads", { method: "POST", body: fd });{ "files": [ { "type": "image", "url": "https://mobile-ivory-crab-19.hostingersite.com/uploads/reviews/2025/06/abc.jpg", "mime": "image/jpeg", "size": 183422 } ] }/api/v1/reviews— Submit a reviewCreates the review with status pending (goes to the moderation queue) unless auto-approve is on. Send JSON (with media URLs from /uploads) or multipart/form-data with files directly.
POST https://mobile-ivory-crab-19.hostingersite.com/api/v1/reviews
Content-Type: application/json
{
"slug": "cotton-kurta-blue", // or "productId": "101"
"rating": 5,
"title": "Loved it",
"body": "Great fabric and fast delivery",
"criteria": { "quality": 5, "price": 4, "delivery_time": 5 },
"media": [{ "url": "https://mobile-ivory-crab-19.hostingersite.com/uploads/reviews/2025/06/abc.jpg" }],
"name": "Riya",
"email": "riya@example.com",
"location": "Pune",
"userId": "", // storefront customer id (later, with login)
"orderId": ""
}201 { "id": "…", "status": "pending", "media": [...], "message": "Thank you! Your review has been submitted and will appear after moderation." }
422 { "error": "Please rate: Quality", "details": { "missing": ["quality"] } }/api/v1/reviews/:id/helpful— Mark a review helpfulIncrements helpfulCount (one vote per visitor IP per review per day).
POST https://mobile-ivory-crab-19.hostingersite.com/api/v1/reviews/665f…/helpful
{ "helpfulCount": 4, "counted": true }