Skip to main content

Overview

The Product Reviews API provides several endpoints for searching and filtering reviews based on different criteria.

By Product ID

Endpoint

GET /api/v1/product-reviews/product/{productId}
Retrieve all reviews for a specific product.

Path Parameters

productId
integer
required
The unique identifier of the product

Example Request

curl -X GET "https://api.example.com/api/v1/product-reviews/product/101"

Example Response

[
  {
    "id": 1,
    "productId": 101,
    "userId": 501,
    "rating": 5,
    "comment": "Excellent quality sofa!",
    "createdAt": "2024-01-15T10:30:00"
  },
  {
    "id": 3,
    "productId": 101,
    "userId": 503,
    "rating": 5,
    "comment": "Beautiful design and great value!",
    "createdAt": "2024-01-17T09:15:00"
  }
]

By Product ID (Ordered)

Endpoint

GET /api/v1/product-reviews/product/{productId}/ordered
Retrieve all reviews for a specific product, ordered by date in descending order (newest first).

Path Parameters

productId
integer
required
The unique identifier of the product

Example Request

curl -X GET "https://api.example.com/api/v1/product-reviews/product/101/ordered"

Example Response

[
  {
    "id": 3,
    "productId": 101,
    "userId": 503,
    "rating": 5,
    "comment": "Beautiful design and great value!",
    "createdAt": "2024-01-17T09:15:00"
  },
  {
    "id": 1,
    "productId": 101,
    "userId": 501,
    "rating": 5,
    "comment": "Excellent quality sofa!",
    "createdAt": "2024-01-15T10:30:00"
  }
]

Average Rating

Endpoint

GET /api/v1/product-reviews/product/{productId}/average-rating
Calculate and retrieve the average rating for a specific product.

Path Parameters

productId
integer
required
The unique identifier of the product

Response

Returns a decimal number representing the average rating.
averageRating
number
The calculated average rating for the product

Example Request

curl -X GET "https://api.example.com/api/v1/product-reviews/product/101/average-rating"

Example Response

4.75

By Minimum Rating

Endpoint

GET /api/v1/product-reviews/rating/{minRating}
Retrieve all reviews with a rating greater than or equal to the specified minimum rating.

Path Parameters

minRating
integer
required
The minimum rating threshold (inclusive)

Example Request

Get all reviews with 4 stars or higher:
curl -X GET "https://api.example.com/api/v1/product-reviews/rating/4"

Example Response

[
  {
    "id": 1,
    "productId": 101,
    "userId": 501,
    "rating": 5,
    "comment": "Excellent quality sofa!",
    "createdAt": "2024-01-15T10:30:00"
  },
  {
    "id": 2,
    "productId": 102,
    "userId": 502,
    "rating": 4,
    "comment": "Good dining table.",
    "createdAt": "2024-01-16T14:20:00"
  },
  {
    "id": 3,
    "productId": 101,
    "userId": 503,
    "rating": 5,
    "comment": "Beautiful design!",
    "createdAt": "2024-01-17T09:15:00"
  }
]

Pagination

Endpoint

GET /api/v1/product-reviews/pagination
Retrieve product reviews with pagination support.

Query Parameters

page
integer
default:"0"
The page number to retrieve (zero-based)
pageSize
integer
default:"10"
The number of reviews per page

Example Request

Get the second page with 20 reviews per page:
curl -X GET "https://api.example.com/api/v1/product-reviews/pagination?page=1&pageSize=20"

Example Response

[
  {
    "id": 21,
    "productId": 105,
    "userId": 520,
    "rating": 4,
    "comment": "Great bookshelf!",
    "createdAt": "2024-02-01T08:45:00"
  },
  {
    "id": 22,
    "productId": 106,
    "userId": 521,
    "rating": 5,
    "comment": "Love this coffee table.",
    "createdAt": "2024-02-02T11:30:00"
  }
]

Notes

  • Pages are zero-based (first page is page=0)
  • Default page size is 10 reviews
  • Returns an array of review objects for the specified page

Status Codes

All search endpoints return:
200
OK
Successfully retrieved matching product reviews

Build docs developers (and LLMs) love