Top Selling API
Category Sales Percentage API Documentation
Actions
1. Get Category Sales Percentage
Endpoint: api/v1/best_seller/category-sales-percent/
Method: GET
Permissions: IsAuthenticated
Description
This API endpoint provides the percentage breakdown of sales and quantities by product categories for a vendor, allowing for analysis over daily, weekly, or monthly periods.
Request
Headers:
| Key | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Required. Only authenticated vendors or users with the 'Dashboard Management' role can access this endpoint. |
are considered. |
Query Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
filter_type |
string | No | ime period for sales data: daily, weekly, monthly (default: daily) |
Example Request:
- Get Category Sales Percentage (Daily)
GET /api/v1/best_seller/category-sales-percent/?filter_type=daily
- Get Category Sales Percentage (Weekly)
GET /api/v1/best_seller/category-sales-percent/?filter_type=weekly
- Get Category Sales Percentage (Monthly)
GET /api/v1/best_seller/category-sales-percentage/?filter_type=monthly
Response
On Success:
Body:
{
"filter_type": "weekly",
"date_range": {
"start_date": "2023-10-02",
"end_date": "2023-10-08"
},
"total_sales": 5000,
"total_quantity": 200,
"category_breakdown": [
{
"category": "Electronics",
"total_quantity": 120,
"quantity_percentage": 60.0,
"total_sales": 3000,
"sales_percentage": 60.0
},
{
"category": "Clothing",
"total_quantity": 80,
"quantity_percentage": 40.0,
"total_sales": 2000,
"sales_percentage": 40.0
}
]
}
On Error:
error 1
{
"error": "Only vendors or Vendor Roles are authorized to view category sales percentage."
}
error 2
{
"error": "Filter type must be 'daily', 'weekly', or 'monthly'"
}
error 3
{
"error": "Vendor shop does not exist or is not assigned properly"
}