API Reference
Complete API documentation with 110+ endpoints
API Overview
Base URL: https://localhost:5001/api
Authentication: JWT Bearer Token
Content-Type: application/json
Language: Persian/Farsi (fa-IR)
Authentication
Login
Endpoint: POST /api/account/login
Request Body:
{
"userNameOrEmailAddress": "[email protected]",
"password": "1q2w3E*",
"rememberMe": true
}
Response:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"encryptedAccessToken": "...",
"expireInSeconds": 3600,
"userId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
Using the Token:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
1. Product Management (15 endpoints)
Get Product List
GET /api/app/product
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| SkipCount | int | No | Pagination offset (default: 0) |
| MaxResultCount | int | No | Items per page (default: 10, max: 100) |
| Sorting | string | No | Sort field (e.g., "Name DESC", "Price ASC") |
Response:
{
"items": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "لپ تاپ ایسوس",
"slug": "laptop-asus-x515",
"price": 15000000,
"discountPrice": 13500000,
"stockQuantity": 50,
"averageRating": 4.5,
"viewCount": 120,
"isFeatured": true,
"isActive": true,
"mainImageUrl": "/uploads/products/laptop.jpg"
}
],
"totalCount": 100
}
Get Product by ID
GET /api/app/product/{id}
Response:
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "لپ تاپ ایسوس X515",
"slug": "laptop-asus-x515",
"description": "لپ تاپ 15 اینچی با پردازنده Core i5",
"price": 15000000,
"discountPrice": 13500000,
"stockQuantity": 50,
"brand": {
"id": "...",
"name": "ایسوس"
},
"categories": [
{
"id": "...",
"name": "لپ تاپ"
}
],
"averageRating": 4.5,
"reviewCount": 25
}
Create Product (Admin)
POST /api/app/product
Admin Only
Request Body:
{
"name": "لپ تاپ جدید",
"slug": "new-laptop",
"description": "توضیحات کامل محصول",
"price": 20000000,
"stockQuantity": 100,
"brandId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"categoryIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"isFeatured": false,
"isActive": true
}
Other Product Endpoints
- PUT
/api/app/product/{id}- Update product - DELETE
/api/app/product/{id}- Delete product - POST
/api/app/product/{id}/increment-view-count- Track views - GET
/api/app/product/featured- Get featured products - GET
/api/app/product/top-selling- Get bestsellers
2. Categories (8 endpoints)
Get All Categories
GET /api/app/category
Response (Hierarchical):
{
"items": [
{
"id": "...",
"name": "الکترونیک",
"slug": "electronics",
"parentId": null,
"children": [
{
"id": "...",
"name": "لپ تاپ",
"slug": "laptops",
"parentId": "...",
"productCount": 45
}
]
}
]
}
Get Featured Categories
GET /api/app/category/featured?maxCount=10
Create Category (Admin)
POST /api/app/category
Request Body:
{
"name": "دستهبندی جدید",
"slug": "new-category",
"parentId": null,
"description": "توضیحات دستهبندی",
"iconUrl": "https://example.com/icon.png",
"displayOrder": 10
}
3. Shopping Cart (8 endpoints)
Get My Cart
GET /api/app/cart/my-cart
Response:
{
"id": "...",
"userId": "...",
"items": [
{
"id": "...",
"productId": "...",
"productName": "لپ تاپ ایسوس",
"quantity": 2,
"unitPrice": 15000000,
"totalPrice": 30000000,
"productImageUrl": "/uploads/products/laptop.jpg"
}
],
"totalAmount": 30000000,
"discountAmount": 0,
"finalAmount": 30000000,
"itemCount": 2
}
Add Item to Cart
POST /api/app/cart/add-item
Request Body:
{
"productId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"quantity": 1
}
Other Cart Endpoints
- PUT
/api/app/cart/update-quantity- Update item quantity - DELETE
/api/app/cart/remove-item/{productId}- Remove item - DELETE
/api/app/cart/clear- Clear entire cart - POST
/api/app/cart/apply-discount/{code}- Apply discount code - POST
/api/app/cart/checkout- Proceed to checkout
4. Order Management (12 endpoints)
Get My Orders
GET /api/app/order/my-orders
Response:
{
"items": [
{
"id": "...",
"orderNumber": "ORD-20250107-0001",
"status": 2,
"statusText": "در حال پردازش",
"total": 30000000,
"customerName": "علی احمدی",
"creationTime": "2025-01-07T10:30:00",
"itemCount": 2
}
]
}
Order Status Values:
| Value | Status | Description |
|---|---|---|
| 0 | Pending | در انتظار تایید |
| 1 | Confirmed | تایید شده |
| 2 | Processing | در حال پردازش |
| 3 | Shipped | ارسال شده |
| 4 | Delivered | تحویل داده شده |
| 5 | Cancelled | لغو شده |
| 6 | Refunded | بازگشت وجه |
Get Order by ID
GET /api/app/order/{id}
Cancel Order
POST /api/app/order/{id}/cancel
Request Body (Optional):
{
"reason": "دلیل لغو سفارش"
}
5. Product Reviews (8 endpoints)
Get Product Reviews
GET /api/app/product-review/by-product/{productId}
Query Parameters:
skipCount- Pagination offsetmaxResultCount- Items per pagesorting- Sort by (CreationTime DESC, Rating DESC, Helpful DESC)
Response:
{
"items": [
{
"id": "...",
"productId": "...",
"rating": 5,
"title": "محصول عالی",
"comment": "کیفیت بسیار خوب و ارسال سریع",
"customerName": "علی احمدی",
"isVerifiedPurchase": true,
"isApproved": true,
"likeCount": 15,
"dislikeCount": 2,
"creationTime": "2025-01-05T14:20:00",
"reply": {
"comment": "از خرید شما متشکریم",
"creationTime": "2025-01-06T09:00:00"
}
}
]
}
Create Review
POST /api/app/product-review
Request Body:
{
"productId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"rating": 5,
"title": "محصول عالی",
"comment": "کیفیت بسیار خوب"
}
Toggle Review Like
POST /api/app/product-review/{reviewId}/toggle-like
Request Body:
{
"isHelpful": true
}
6. Wishlist System (7 endpoints)
Get My Wishlists
GET /api/app/wishlist/my-wishlists
Add to Wishlist
POST /api/app/wishlist/add-item
Request Body:
{
"wishlistId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"productId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"priority": 2,
"notes": "خرید در ماه آینده"
}
7. Notifications (12 endpoints)
Get My Notifications
GET /api/app/notification/my-notifications
Response:
{
"items": [
{
"id": "...",
"type": 1,
"title": "سفارش ثبت شد",
"message": "سفارش شما با موفقیت ثبت شد",
"isRead": false,
"priority": 1,
"creationTime": "2025-01-07T10:30:00"
}
],
"unreadCount": 5
}
Mark as Read
PUT /api/app/notification/{id}/mark-as-read
Mark All as Read
PUT /api/app/notification/mark-all-as-read
Error Responses
Standard Error Format
{
"error": {
"code": "Validation:001",
"message": "دادههای ورودی نامعتبر است",
"details": "نام محصول الزامی است",
"validationErrors": [
{
"message": "نام محصول الزامی است",
"members": ["Name"]
}
]
}
}
HTTP Status Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Request successful |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid input data |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 500 | Internal Server Error | Server error occurred |
Rate Limiting
| User Type | Requests per Minute | Requests per Hour |
|---|---|---|
| Anonymous | 100 | 3,000 |
| Authenticated | 1,000 | 30,000 |
| Admin | Unlimited | Unlimited |
Pagination & Sorting
Pagination Parameters
SkipCount- Number of items to skip (default: 0)MaxResultCount- Maximum items to return (default: 10, max: 100)
Sorting Format
"Name"- Ascending by name"Name DESC"- Descending by name"Price ASC"- Ascending by price"CreationTime DESC"- Newest first
Example Request
GET /api/app/product?SkipCount=20&MaxResultCount=10&Sorting=Price%20ASC
Complete API Endpoint List
Products (15 endpoints)
- GET /api/app/product
- GET /api/app/product/{id}
- POST /api/app/product
- PUT /api/app/product/{id}
- DELETE /api/app/product/{id}
- GET /api/app/product/featured
- GET /api/app/product/top-selling
- POST /api/app/product/{id}/increment-view-count
- And 7 more...
Categories (8 endpoints)
- GET /api/app/category
- GET /api/app/category/{id}
- POST /api/app/category
- PUT /api/app/category/{id}
- DELETE /api/app/category/{id}
- GET /api/app/category/featured
- GET /api/app/category/tree
- GET /api/app/category/{id}/products