http://example.com/api/2.0/discussions/ — refer to all reviews and comments. Supports only GET and POST.
http://example.com/api/2.0/discussions/:id — refer to a particular review or comment. Supports GET, PUT, and DELETE.
http://example.com/api/2.0/products/:p_id/discussions/ — refer to all reviews and comments related to specific product. Supports only GET and POST.
http://example.com/api/2.0/products/:p_id/discussions/:id — refer to a particular review or comment related to specific product. Supports GET, PUT, and DELETE.
Use the following parameters to find reviews an comments with specific properties and display them in a way you need.
Parameter |
Default value |
Description |
page |
|
Show all reviews and comments on the output page with the specified number. |
items_per_page |
|
The number of reviews and comments displayed on the output page. |
sort_by |
|
Sort reviews and comments by |
sort_order |
|
Ascending or descending sorting order: |
status |
|
Filter reviews and comments by status. Possible values: |
name |
Filter reviews and comments by names. |
|
message |
Filter reviews and comments by their content. |
|
type |
Filter reviews and comments by type. Possible values:
|
|
ip_address |
Filter reviews and comments by IP address. |
|
rating_value |
Filter reviews and comments by rating. |
|
object_type |
Filter reviews and comments by their object. Possible values:
|
|
object_id |
Filter reviews and comments by object ID. |
|
period |
|
Filter carts by time period:
|
time_from |
Filter carts by the specified time period: beginning of the time period. |
|
time_to |
Filter carts by the specified time period: end of the time period. |
Examples:
http://example.com/api/2.0/discussions?items_per_page=20
Response is an array with 20 reviews and comments from the 1st page.
http://example.com/api/2.0/discussions?items_per_page=20
Response is an array with 20 reviews from the 5th output page.
http://example.com/api/2.0/products/167/discussions
Response is an array with reviews and comments about the product with product_id=167.
Reviews and comments have a number of properties represented by fields. See the list of supported fields below (mandatory fields are marked with *).
Note
Any field not listed in the table below will be ignored if occurs in an API request JSON data.
Field name |
Description |
Available for methods |
Supported values |
|---|---|---|---|
object_type* (also requires object_id) |
Type of the object. |
GETPOST |
One of the following strings:
P - productC - categoryA - pageO - orderE - home page |
object_id* (also requires object_type) |
ID of the object. |
GETPOST |
integer |
thread_id* (instead of object_type & object_id) |
ID of the thread. |
GETPOST |
integer |
name |
Name of the customer who posted the review/comment. |
GETPOSTPUT |
string |
message |
Content of the customer’s message. |
GETPOSTPUT |
string |
rating_value |
Rating value. |
GETPOSTPUT |
integer |
timestamp |
Creation timestamp. |
GETPOSTPUT |
A valid timestamp in seconds |
status |
Status of a review or comment. |
GETPOSTPUT |
A - approvedD - disapproved |
post_id |
ID of the post. |
GET |
integer |
user_id |
ID of the user. |
GET |
integer |
ip_address |
IP address of the user. |
GET |
string |
type |
Type of the discussion. |
GET |
C - commentR - reviewB - both |
company_id |
ID of the company. |
GET |
A valid company ID. |
curl -X GET 'http://example.com/api/2.0/discussions/'
This example command returns the list of reviews and comments with their properties.
curl -X GET 'http://example.com/api/2.0/discussions/18'
This example command returns the review or comment with post_id=18.
Send the data in the body of the HTTP request. The data should comply with the content-type.
If you successfully create a review or comment, you will receive HTTP/1.1 201 Created.
If the review or comment couldn’t be created, you will receive HTTP/1.1 400 Bad Request.
Required fields: object_type + object_id or thread_id
Available fields: object_type, object_id, thread_id, name, message, rating_value, timestamp, status
curl -H "Content-Type: application/json" -X POST http://example.com/api/2.0/discussions -d '{"object_type":"P", "object_id":242, "name":"John Doe", "rating_value":4, "message":"Hi, I use the API!"}'
The example request creates a comment from John Doe. He reviews the product with product_id=242 and rates it 4 out of 5. He also leaves a message: “Hi, I use the API!”.
In response you receive the ID of the post.
{post_id: 22}
Send the data in the body of the HTTP request. The data should comply with the content-type.
Available fields: name, message, rating_value, timestamp, status
curl -H "Content-Type: application/json" -X PUT http://example.com/api/2.0/discussions/22 -d '{"rating_value":5, "message":"Changed message via API", "status":"D"}'
The example request sets the status of the comment with post_id=22 to disapproved, changes the rating of the associated object (product_id=242 in this case) to 5 and modifies the message to “Changed the message via API”.
In response you receive the ID of the comment.
{post_id: 22}
If you successfully delete a comment, you will receive HTTP/1.1 204 No Content.
If the comment couldn’t be deleted, you will receive HTTP/1.1 400 Bad Request.
If the comment doesn’t exist, you will receive HTTP/1.1 404 Not Found.
curl -X DELETE 'http://example.com/api/2.0/discussions/22'
The example request deletes the comment with the post_id=22.