Skip to main content

Get Products

GET /api/admin/products?search=premium&category=digital&limit=10&page=1
Retrieves a paginated list of products with optional filtering by search query and category. Authentication: Admin access required

Query Parameters

Search products by name or description (case-insensitive)
category
string
Filter products by category
limit
number
default:"10"
Number of products to return per page (minimum 1)
page
number
default:"1"
Page number for pagination (minimum 1)

Response

success
boolean
Indicates if the request was successful
products
array
Array of product objects sorted by creation date (newest first)
pagination
object

Response Example

{
  "success": true,
  "products": [
    {
      "_id": "prod123",
      "name": "Premium Package",
      "description": "Access to premium features and content",
      "price": 299.99,
      "category": "digital",
      "stock": 100,
      "image": "https://example.com/images/premium.jpg",
      "isActive": true,
      "createdAt": "2025-12-01T10:00:00.000Z",
      "updatedAt": "2026-01-15T14:30:00.000Z"
    },
    {
      "_id": "prod456",
      "name": "Starter Package",
      "description": "Basic access for beginners",
      "price": 99.99,
      "category": "digital",
      "stock": 250,
      "image": "https://example.com/images/starter.jpg",
      "isActive": true,
      "createdAt": "2025-11-20T09:00:00.000Z",
      "updatedAt": "2025-12-10T11:20:00.000Z"
    }
  ],
  "pagination": {
    "total": 45,
    "page": 1,
    "pages": 5,
    "limit": 10
  }
}

Error Response

{
  "error": "Error message"
}

Notes

  • The search parameter performs a case-insensitive regex search on both product name and description
  • If both search and category are provided, products must match both criteria
  • Invalid limit or page values (less than 1) are automatically adjusted to 1
  • Products are always sorted by creation date in descending order (newest first)

Build docs developers (and LLMs) love