Skip to main content
GET
/
api
/
content
/
admin
/
all
List All Content (Admin)
curl --request GET \
  --url https://api.example.com/api/content/admin/all
{
  "content": [
    {
      "_id": "<string>",
      "title": "<string>",
      "description": "<string>",
      "type": "<string>",
      "category": "<string>",
      "price": 123,
      "fileUrl": "<string>",
      "filePublicId": "<string>",
      "thumbnailUrl": "<string>",
      "thumbnailPublicId": "<string>",
      "duration": 123,
      "fileSize": 123,
      "status": "<string>",
      "tags": [
        {}
      ],
      "createdBy": {
        "_id": "<string>",
        "name": "<string>",
        "email": "<string>"
      },
      "createdAt": "<string>",
      "updatedAt": "<string>"
    }
  ],
  "totalPages": 123,
  "currentPage": 123,
  "totalContent": 123
}

Overview

Admin endpoint to retrieve all content in the system, including draft and published content. This endpoint supports pagination and filtering by status, category, and type.

Authentication

This endpoint requires admin authentication. Include a valid admin access token in the Authorization header.
Authorization: Bearer <admin_access_token>

Query Parameters

page
number
default:"1"
Page number for pagination
limit
number
default:"10"
Number of items per page
status
string
Filter by content status: "draft" or "published"
category
string
Filter by category ID
type
string
Filter by content type: "pdf", "video", or "audio"

Request

cURL
curl -X GET "https://api.vaniykempire.com/api/content/admin/all?page=1&limit=10" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
Filter by Status
curl -X GET "https://api.vaniykempire.com/api/content/admin/all?status=draft&page=1&limit=20" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
JavaScript
const response = await fetch(
  'https://api.vaniykempire.com/api/content/admin/all?page=1&limit=10',
  {
    headers: {
      'Authorization': `Bearer ${adminAccessToken}`
    }
  }
);

const data = await response.json();
console.log(`Total content: ${data.totalContent}`);
console.log(`Content items:`, data.content);
Python
import requests

response = requests.get(
    'https://api.vaniykempire.com/api/content/admin/all',
    headers={'Authorization': f'Bearer {admin_access_token}'},
    params={
        'page': 1,
        'limit': 10,
        'status': 'draft'
    }
)

data = response.json()
print(f"Total content: {data['totalContent']}")

Response

content
array
Array of content objects, sorted by creation date (newest first)
totalPages
number
Total number of pages available
currentPage
number
Current page number
totalContent
number
Total number of content items matching the filters

Success Response

{
  "content": [
    {
      "_id": "65f7b3c8e1234567890abcde",
      "title": "Advanced JavaScript Course",
      "description": "Learn modern JavaScript",
      "type": "video",
      "category": "programming",
      "price": 49.99,
      "fileUrl": "https://res.cloudinary.com/demo/video/upload/v1234567890/content/video.mp4",
      "filePublicId": "content/video",
      "thumbnailUrl": "https://res.cloudinary.com/demo/image/upload/v1234567890/thumbnails/thumb.jpg",
      "thumbnailPublicId": "thumbnails/thumb",
      "duration": 3600,
      "fileSize": 524288000,
      "status": "published",
      "tags": ["javascript", "programming", "web-development"],
      "createdBy": {
        "_id": "65f7b3c8e1234567890abc00",
        "name": "Admin User",
        "email": "[email protected]"
      },
      "createdAt": "2024-03-15T10:30:00.000Z",
      "updatedAt": "2024-03-15T10:30:00.000Z"
    }
  ],
  "totalPages": 5,
  "currentPage": 1,
  "totalContent": 47
}

Error Responses

401 Unauthorized

Invalid or missing access token.
{
  "error": "Invalid token"
}

403 Forbidden

User is not an admin.
{
  "error": "Admin access required"
}

500 Internal Server Error

{
  "error": "Internal server error message"
}

Notes

This endpoint returns the fileUrl and filePublicId fields which are hidden from public endpoints. Only use this endpoint for admin dashboards.
Unlike the public /api/content endpoint, this returns both draft and published content. Use the status query parameter to filter.
Use pagination to efficiently load large content libraries in admin dashboards.

Build docs developers (and LLMs) love