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/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO AN INTERNAL REDIRECT WITH 301 STATUS

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with ProductCommentPermission or Admin
  • Permission Code: 1882
  • 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 lookup results by(`id`, `content`, `product__id`, `product__title`, `product_slug`, `user__id`, `user__username`, `user__mobile_number`, `user__first_name`, `user__last_name`)
orderingstring-created_atOrder results by (`id`, `user`, `product`, `rating`, `is_published`, `updated_at`, `created_at`)
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
is_anonymousbooleanFilter comments that are anonymouse/not anonymouse
is_publishedbooleanFilter comments that are published/not published
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)

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())

Response Fields

FieldTypeDescription
countIntegerTotal number of categories
nextStringURL for the next page of results
previousStringURL for the previous page of results
resultsArray[Object]Array of ProductComment objects

ProductComment Object Structure

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 (nullable)
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
titlestringTitle of the product

Example Response

{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"rating": 3,
"content": "واقعا ماوس خوبی است",
"is_anonymous": false,
"is_published": false,
"created_at": "2025-11-22T15:24:49.833816Z",
"updated_at": "2025-11-22T15:24:49.833821Z",
"user_data": {
"id": 2,
"username": "staffer",
"full_name": "عماد رخشانی",
"avatar": "http://127.0.0.1:8000/media/users/avatars/Fantasticheskie_kartinki_dlja_monitora_68_76.jpg"
},
"product_data": {
"id": 36,
"title": "ماوس لاجیتک MX Vertical"
},
"truncated_content": "واقعا ماوس خوبی است"
}
]
}

Notes

  • Rating scale: 1=Worst, 2=Bad, 3=Average, 4=Good, 5=Best