Skip to main content

Create Product Comments

Creates a new comment/review for a specific product.

HTTP Request

POST/api/shop/products/:slug/comments

Authorization

Authorization

  • Required: Yes
  • Permission: Authenticated Users
  • Authentication: Token-based (`Authorization: Token <your_api_key>`)

Path Parameters

ParameterTypeRequiredDescription
slugstringYesURL-friendly product identifier

Request Body

ParameterTypeDefaultDescription
is_anonymousbooleanWhether to post the comment anonymously (default: false)
ratingintegerProduct rating (1-5)
contentstringComment content/review text (max 500 characters)

Example Requests

1import requests
2
3# Create a new comment
4response = requests.post('http://www.example.com/api/shop/products/iphone-14-pro/comments', 
5  json={
6      'rating': 5,
7      'content': 'Excellent product! Really happy with the purchase.',
8      'is_anonymous': False
9  },
10  headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())
13
14# Create anonymous comment
15response = requests.post('http://www.example.com/api/shop/products/iphone-14-pro/comments', 
16  json={
17      'rating': 4,
18      'content': 'Good value for money.',
19      'is_anonymous': True
20  },
21  headers={'Authorization': 'Token <your_api_key>'}
22)
23print(response.json())

Status Codes

CodeDescription
201Comment created successfully
400Bad request — invalid input
401Unauthorized — authentication required
404Product not found
500Internal server error

Response Fields

FieldTypeDescription
idintegerUnique ID of the newly created comment
ratingintegerProduct rating (1-5)
contentstringFull comment content
is_anonymousbooleanWhether the comment is posted anonymously

Notes

    • Default ordering for listing comments is by creation date (newest first)