Skip to main content

List Product Comments

Retrieves a list of all product comments with filtering, searching, and ordering capabilities.

HTTP Request

GET/api/products/comments

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Query Parameters

ParameterTypeDefaultDescription
limitinteger10Number of results to return per page
offsetinteger0Number of results to skip before returning results
searchstringSearch term to filter results by (`id`, `content`, `product__id`, `product__name`, `product_slug`, `user__id`, `user__username`, `user__mobile_number`, `user__first_name`, `user__last_name`)
orderingstring-created_atField to order results by (`id`, `user`, `product`, `rating`, `is_published`, `updated_at`, `created_at`)
is_anonymousbooleanFilter by anonymous status
is_publishedbooleanFilter by published status
rating_minintegerMinimum rating filter (1-5)
rating_maxintegerMaximum rating filter (1-5)
productintegerFilter by specific product ID
product_instringFilter by multiple product IDs (comma-separated: 1,2,3)
userintegerFilter by specific user ID
user_instringFilter by multiple user IDs (comma-separated: 1,2,3)
id_minintegerMinimum ID filter
id_maxintegerMaximum ID filter
created_datestringFilter by creation date (e.g., 2023-01-01)
updated_datestringFilter by last updated date (e.g., 2023-01-01)
created_fromstringFilter by creation date range start
created_tostringFilter by creation date range end
updated_fromstringFilter by last updated date range start
updated_tostringFilter by last updated date range end

Example Requests

1import requests
2
3# List all product comments
4response = requests.get('http://www.example.com/api/products/comments', 
5  headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search for comments with filters
10response = requests.get('http://www.example.com/api/products/comments', params={
11  'search': 'great product',
12  'is_published': True,
13  'rating_min': 4,
14  'ordering': '-created_at',
15  'limit': 20
16}, headers={'Authorization': 'Token <your_api_key>'})
17print(response.json())
18
19# Filter by specific product and rating range
20response = requests.get('http://www.example.com/api/products/comments', params={
21  'product': 5,
22  'rating_min': 3,
23  'rating_max': 5,
24  'is_published': True
25}, headers={'Authorization': 'Token <your_api_key>'})
26print(response.json())

Status Codes

CodeDescription
200Product comments retrieved successfully
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idintegerUnique ID of the comment
ratingintegerRating given (1-5: Worst, Bad, Average, Good, Best)
contentstringComment content (max 500 characters)
is_anonymousbooleanWhether the comment is posted anonymously
is_publishedbooleanWhether the comment is published
user_dataobjectUser details (read-only)
product_dataobjectProduct details (read-only)
truncated_contentstringShortened version of content
created_atstring (ISO 8601)Timestamp when comment was created
updated_atstring (ISO 8601)Timestamp when comment was last updated

User Data Structure

FieldTypeDescription
idintegerUnique ID of the user
usernamestringUsername of the user
full_namestringFull name of the user
avatarstringURL of the user avatar image

Product Data Structure

FieldTypeDescription
idintegerUnique ID of the product
namestringName of the product

Notes

  • Rating scale: 1=Worst, 2=Bad, 3=Average, 4=Good, 5=Best
  • Comments can be filtered by publication status to show only approved content
  • Anonymous comments hide user identification but retain moderation capabilities
  • All timestamps are in ISO 8601 format (e.g., "2023-01-01T12:00:00Z")