> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.alireviews.io/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Ali Reviews | Public APIs

This document describes the structure and usage of the Public API service for Ali Reviews, which includes endpoints for managing reviews, ratings, and questions.

## On this Page

* [1. Authentication](#2-1-authentication)
* [2. List Reviews](#2-2-list-reviews)
* [3. React to a Review](#2-3-react-to-a-review)
* [4. Product Ratings](#2-4-product-ratings)
* [5. List Questions](#2-5-list-questions)
* [6. React to a Question](#2-6-react-to-a-question)

| Important note:
| Base URL: https://pub.kudosi.ai
| All API requests should be made to this base URL.

## 1. Authentication

* Our API uses an API key to authenticate. You can get the API key of a shop from the App menu **Integration → API key**.
* **Bearer Token** needs to be sent in the request header.

## 2. List Reviews

**Endpoint:**
```
GET /public/reviews
```

**Request Headers**
****
* `Authorization` ( **required**) - API key provided by the app.

**Request Parameters**
****
* `limit` (optional, query) - Maximum number of reviews to retrieve.
* `cursor` (optional, query) - Cursor for pagination.
* `product_id` (optional, query) - Filter by product ID.
* `search` (optional, query) - Search term for filtering reviews.
* `sort` (optional, query) - Sort field ( `by_date`, `by_rating`, `by_content`, `by_media`).
* `direction` (optional, query) - Sort direction ( `asc` or `desc`).

**Response Example**
****
```json
{
  "status": true,
  "message": "Success",
  "data": {
    "reviews": [...],
    "cursor": ""
  }
}
```

**Curl Example**
****
```bash
curl --location 'https://pub.kudosi.ai/public/reviews?limit=2&sort=by_date&direction=asc&product_id=9476891607337' \
--header 'Authorization: Bearer api_key'
```

|| Limit: If you do not set the "limit", the system will return 15 reviews by default. The maximum number you can set for "limit" is 50.
|| Cursor: In the first request, add "cursor" and leave its value empty. The response will return a cursor value. Use that value in your next request to get the next set of reviews. Repeat this process to continue getting more reviews.

## 3. React to a Review

**Endpoint:**
```
PUT /public/reviews/:review_id/reactions
```

**Request Headers**
****
* `Authorization` ( **required**) - API key provided by the app.

**Request Parameters**
****
* `review_id` ( **required**, path) - ID of the review to react to.
* `reaction` ( **required**, body) - Type of reaction ( `like` or `dislike`).

**Response Example**
****
```json
{
  "status": true,
  "message": "",
  "data": {
    "total_likes": 10,
    "total_dislikes": 2
  }
}
```

**Curl Example**
****
```bash
curl --location --request PUT 'https://pub.kudosi.ai/public/reviews/6710b08a8df6c7ceca2cd0ff/reactions' \
--header 'Authorization: Bearer api_key' \
--header 'Content-Type: application/json' \
--data '{ "reaction": "like" }'
```

## 4. Product Ratings

**Endpoint:**
```
GET /public/products/rating
```

**&#160;Request Headers**
****
* `Authorization` ( **required**) - API key provided by the app.

#### Request Parameters

* `product_ids` ( **required**, query) - Comma-separated product IDs.

**Response Example**
****
```json
{
  "status": true,
  "data": {
    "8126036083008": {
      "average_rating": 3.03,
      "total": 63,
      "details": [
        { "star_rating": 5, "total": 12 },
        { "star_rating": 4, "total": 16 },
        { "star_rating": 3, "total": 8 },
        { "star_rating": 2, "total": 16 },
        { "star_rating": 1, "total": 11 }
      ]
    }
  }
}
```

**Curl Example**
****
```bash
curl --location --globoff 'https://pub.kudosi.ai/public/products/rating?product_ids=8126036083008' \
--header 'Authorization: Bearer api_key'
```

## 5. List Questions

**Endpoint:**
```
GET /public/questions
```

**Request Headers**
****
* `Authorization` ( **required**) - API key provided by the app.

**Request Parameters**
****
* `limit` (optional, query) - Maximum number of questions to retrieve.
* `cursor` (optional, query) - Cursor for pagination.
* `product_id` ( **required**, query) - Filter by product ID.

**Response Example**
****
```json
{
  "status": true,
  "data": {
    "questions": [...],
    "cursor": ""
  }
}
```

**Curl Example**
****
```bash
curl --location 'https://pub.kudosi.ai/public/questions?product_id=9476891607337&limit=100' \
--header 'Authorization: Bearer api_key'
```

## 6. React to a Question

**Endpoint:**
```
PUT /public/questions/:question_id/reactions
```

**Request Headers**
****
* `Authorization` ( **required**) - API key provided by the app.

**Request Parameters**

* `question_id` ( **required**, path) - The ID of the question being reacted to.
* `reaction` ( **required**, body) - The reaction type ( `like` or `dislike`).
* `type` ( **required**, body) - Type of item being reacted to ( `question` or `reply`).

**Response Example**
****
```json
{
  "status": true,
  "data": {
    "total_likes": 6,
    "total_dislikes": 1
  }
}
```

**Curl Example**
****
```bash
curl --location --request PUT 'https://pub.kudosi.ai/public/questions/66506544a94e6f15ec0b4d2e/reactions' \
--header 'Authorization: Bearer api_key' \
--header 'Content-Type: application/json' \
--data '{ "type": "question", "reaction": "like" }'
```

Hope this helps! If you have any questions, please feel free to contact us via live chat or email us at [support@alireviews.io](mailto:support@alireviews.io)