Skip to content

Admin Dashboard API ​

/api/admin/dashboard/* powers the homepage of the admin console, exposing site-wide aggregates. All endpoints require Admin; on failure they return {success, message}.

Endpoint index ​

EndpointMethodAuthDescription
/api/admin/dashboard/overviewGETAdminKPI overview (users / resources / quota / revenue)
/api/admin/dashboard/chartsGETAdminSite-wide day × model aggregates ([]LogStatistic)
/api/admin/dashboard/top-usersGETAdminActive-user leaderboard

1. KPI Overview ​

Endpoint: GET /api/admin/dashboard/overview

Auth: Admin

Query parameters:

ParameterTypeDescription
rangestringTime window. One of today / 7d / 30d / all. Default 7d.

Response:

json
{
  "success": true,
  "message": "",
  "data": {
    "users": {
      "total": 1024,
      "enabled": 900,
      "disabled": 80,
      "deleted": 44,
      "new_today": 5,
      "new_7d": 30,
      "new_30d": 120,
      "active_7d": 210
    },
    "tokens": { "total": 3200, "enabled": 2800 },
    "channels": { "total": 18, "enabled": 15 },
    "plans": { "total": 5, "enabled": 4 },
    "redemptions": { "total": 500, "used": 200, "unused": 300 },
    "subscriptions": { "total": 220, "active": 180, "expired": 40 },
    "quota": { "today": 120000, "week": 900000, "month": 3600000, "total": 12000000 },
    "revenue": {
      "total": 19999.50,
      "topup": 8000.00,
      "subscription": 11999.50,
      "refund": 0.00
    },
    "range": "7d",
    "generated_at": 1718000000
  }
}

Fields:

FieldTypeDescription
users.totalint64All users (including disabled/deleted)
users.enabledint64Users with status=enabled
users.disabledint64Manually disabled users
users.deletedint64Soft-deleted users
users.new_today / new_7d / new_30dint64New users in the today / 7d / 30d window
users.active_7dint64Users who had a consume log in the past 7 days AND request_count > 0
tokens.total / enabledint64Token count / enabled tokens
channels.total / enabledint64Channel count / enabled channels
plans.total / enabledint64Plan count / listed plans
redemptions.total / used / unusedint64Redemption code count / used / unused
subscriptions.total / active / expiredint64User-plan count / active / expired
quota.today / week / month / totalint64Sum of quota from consume logs in each window
revenue.total / topup / subscriptionfloat64Total revenue / topup / subscription (CNY)
revenue.refundfloat64Refund total (CNY)
rangestringActual window used
generated_atint64Server-side generation timestamp

Revenue is filtered by orders.pay_time in the range window with status=1 (paid) and status=3 (refunded).

2. Site-wide Chart Data ​

Endpoint: GET /api/admin/dashboard/charts

Auth: Admin

Query parameters:

ParameterTypeDescription
rangestringTime window. One of today / 7d / 30d / all. Default 7d. all is capped to the last 30 days.

Response:

json
{
  "success": true,
  "message": "",
  "data": [
    {
      "day": "2026-09-10",
      "model_name": "gpt-4o",
      "request_count": 120,
      "quota": 250000,
      "prompt_tokens": 80000,
      "completion_tokens": 50000
    },
    {
      "day": "2026-09-10",
      "model_name": "claude-3-5-sonnet",
      "request_count": 35,
      "quota": 70000,
      "prompt_tokens": 22000,
      "completion_tokens": 14000
    }
  ]
}

Fields:

FieldTypeDescription
daystringDay bucket (YYYY-MM-DD, UTC day boundary)
model_namestringModel name
request_countintRequests for that model on that day
quotaintTotal quota consumed for that model on that day
prompt_tokensintSum of input tokens
completion_tokensintSum of output tokens

The response shape matches model.SearchLogsByDayAndModel (i.e. GET /api/user/dashboard), so the frontend can reuse the same chart-building logic.

3. Active-User Leaderboard ​

Endpoint: GET /api/admin/dashboard/top-users

Auth: Admin

Query parameters:

ParameterTypeDescription
rangestringTime window. One of today / 7d / 30d / all. Default 7d.
limitintRows to return, 1-200, default 20

Response:

json
{
  "success": true,
  "message": "",
  "data": {
    "range": "7d",
    "items": [
      {
        "id": 12,
        "username": "alice",
        "email": "alice@example.com",
        "request_count": 1230,
        "quota": 800000,
        "balance": 5000000,
        "current_plan_name": "Pro Plan"
      }
    ]
  }
}

Fields:

FieldTypeDescription
idintUser ID
usernamestringUsername
emailstringEmail
request_countint64Requests in the window
quotaint64Quota consumed in the window
balanceint64Current remaining quota on the account
current_plan_namestringName of the earliest-expiring active subscription, if any

Sort order: request_count DESC, then window quota DESC. Only users with status != deleted and request_count > 0 are included.