Statistics

This page contains the documentation for the statistics endpoints.

The statistics endpoints allow you to get the statistics of the users, products and orders. These metrics give you insights to the number of users, the most ordered items, and the status of the different orders.

Get User Stats

get
/stats/dashboard

This endpoint provides a summary of key metrics for the users shown in the admin dashboard, including:

  • Total orders and their statuses (pending, delivery, and completed).
  • Total users and total products. Each metric includes a text label, count, and a link for further details.
Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired

Provide your API key.

Responses
200

Successful response. Returns a summary of dashboard statistics.

application/json
get
/stats/dashboard
GET /stats/dashboard HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
[
  {
    "text": "All orders",
    "count": 49,
    "link": "orders"
  },
  {
    "text": "Pending orders",
    "count": 22,
    "link": "orders/pending"
  },
  {
    "text": "Delivered orders",
    "count": 12,
    "link": "orders/delivery"
  },
  {
    "text": "Completed orders",
    "count": 15,
    "link": "orders/completed"
  },
  {
    "text": "Total users",
    "count": 58,
    "link": "users"
  },
  {
    "text": "Total products",
    "count": 8,
    "link": "products"
  }
]

Get Product Stats

get
/stats/productTable/{page}

This endpoint retrieves product statistics for the specified page, including:

  • Total products sold (soldCount).
  • Breakdown of product orders by status (pending, delivery, completed) with counts and total quantities.
Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired

Provide your API key.

Path parameters
pageinteger · min: 1Required

The page number for paginated product statistics.

Responses
200

Successful response. Returns a paginated list of product statistics.

application/json
get
/stats/productTable/{page}
GET /stats/productTable/{page} HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
[
  {
    "product": "6555a1f49feeac7dccd9b1ee",
    "name": "brown tablede",
    "soldCount": 90,
    "counts": {
      "delivery": {
        "count": 6,
        "totalQuantity": 12
      },
      "completed": {
        "count": 7,
        "totalQuantity": 30
      },
      "pending": {
        "count": 13,
        "totalQuantity": 74
      }
    }
  },
  {
    "product": "655ff05e60b5a0bcc0a9314e",
    "name": "Regular table",
    "soldCount": 31,
    "counts": {
      "delivery": {
        "count": 1,
        "totalQuantity": 1
      },
      "completed": {
        "count": 2,
        "totalQuantity": 2
      },
      "pending": {
        "count": 4,
        "totalQuantity": 11
      }
    }
  }
]

Get Order Stats

get
/stats/orders/all/{page}

This endpoint retrieves order statistics for the specified page.

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired

Provide your API key.

Path parameters
pageintegerRequired

The page number for pagination.

Example: 1
Responses
200

A list of orders.

application/json
get
/stats/orders/all/{page}
GET /stats/orders/all/{page} HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
{
  "totalOrders": 49,
  "orders": [
    {
      "_id": "674b37b8dc3d9360b4c32e72",
      "user": {
        "_id": "672050a27def4d23ffcb5166",
        "email": "[email protected]"
      },
      "items": [
        {
          "product": {
            "_id": "6555a1f49feeac7dccd9b1ee",
            "name": "brown tablede",
            "price": 30
          },
          "quantity": 4,
          "shipping": "Regular",
          "_id": "674b37b8dc3d9360b4c32e73"
        }
      ],
      "status": "pending",
      "address": "Tester Dr, Blackwood SA 5051, Australia",
      "createdAt": "30 Nov 2024",
      "__v": 0
    }
  ]
}

Last updated