Docs
Introduction

Documentation

Learn how to integrate ConnectX into your application.

Reviews API Overview

Learn how to manage product reviews in ConnectX

The Reviews API allows you to manage product reviews in ConnectX. Users can create, read, update, and delete their reviews, as well as view review statistics for products.

Most API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Note: Some endpoints like viewing product reviews and statistics are publicly accessible without authentication.

All API endpoints are relative to the base URL:

https://connectx-backend-4o0i.onrender.com/api

Reviews

  • POST /reviews/ - Create a new review
  • GET /reviews/product-reviews/ - Get product reviews
  • GET /reviews/product-stats/ - Get product review statistics
  • GET /reviews/product-summary/ - Get product review summary
  • GET /reviews/my_reviews/ - Get user's reviews

User Permissions

  • Users can only create reviews for products they have purchased
  • Users can only update or delete their own reviews
  • Anyone can view product reviews and statistics
  • Users can only view their own reviews through the my_reviews endpoint

Review Requirements

  • Rating must be between 1 and 5
  • Comment is required for all reviews
  • Title is optional but recommended
  • Users can only review a product once

Create a new review for a product. You must have purchased the product to review it.

Command

curl -X POST 'https://connectx-backend-4o0i.onrender.com/api/reviews/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "product": "123e4567-e89b-12d3-a456-426614174000",
    "rating": 5,
    "title": "Great Product!",
    "comment": "This product exceeded my expectations."
  }'

Response

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "product": "123e4567-e89b-12d3-a456-426614174000",
  "user": "123e4567-e89b-12d3-a456-426614174001",
  "rating": 5,
  "title": "Great Product!",
  "comment": "This product exceeded my expectations.",
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z"
}

Get all reviews for a specific product with pagination.

Command

curl -X GET 'https://connectx-backend-4o0i.onrender.com/api/reviews/product-reviews/?product_id=123e4567-e89b-12d3-a456-426614174000' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Response

{
  "count": 2,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "product": "123e4567-e89b-12d3-a456-426614174000",
      "user": "123e4567-e89b-12d3-a456-426614174001",
      "rating": 5,
      "title": "Great Product!",
      "comment": "This product exceeded my expectations.",
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ]
}

Get comprehensive review statistics for a specific product.

Command

curl -X GET 'https://connectx-backend-4o0i.onrender.com/api/reviews/product-stats/?product_id=123e4567-e89b-12d3-a456-426614174000' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Response

{
  "total_reviews": 10,
  "average_rating": 4.5,
  "rating_distribution": {
    "1": 1,
    "2": 0,
    "3": 1,
    "4": 3,
    "5": 5
  }
}

Get both reviews and statistics for a product in a single response.

Command

curl -X GET 'https://connectx-backend-4o0i.onrender.com/api/reviews/product-summary/?product_id=123e4567-e89b-12d3-a456-426614174000&limit=5' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Response

{
  "reviews": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "product": "123e4567-e89b-12d3-a456-426614174000",
      "user": "123e4567-e89b-12d3-a456-426614174001",
      "rating": 5,
      "title": "Great Product!",
      "comment": "This product exceeded my expectations.",
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ],
  "stats": {
    "total_reviews": 10,
    "average_rating": 4.5,
    "rating_distribution": {
      "1": 1,
      "2": 0,
      "3": 1,
      "4": 3,
      "5": 5
    }
  }
}

Get all reviews created by the authenticated user.

Command

curl -X GET 'https://connectx-backend-4o0i.onrender.com/api/reviews/my_reviews/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Response

[
  {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "product": "123e4567-e89b-12d3-a456-426614174000",
    "user": "123e4567-e89b-12d3-a456-426614174001",
    "rating": 5,
    "title": "Great Product!",
    "comment": "This product exceeded my expectations.",
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
  }
]