Skip to content

Get Category By ID

Get a specific category by its ID with its hierarchical structure.

Endpoint

GET /v1/products/category/get-by/?id={category_id}

Authentication

Not required (public endpoint)

Query Parameters

Parameter Type Required Description
id integer Yes Category ID

Response

Success (200 OK)

Returns the category in a hierarchical tree structure:

[
  {
    "id": 1,
    "name": "Electronics",
    "image": "https://...",
    "parent_id": null,
    "children": [
      {
        "id": 2,
        "name": "Laptops",
        "image": "https://...",
        "parent_id": 1,
        "children": []
      }
    ]
  }
]

Error Responses

Category Not Found (404)

{
  "error": "Category Not Found"
}

Example Request

curl -X GET "https://api.luxmart.site/v1/products/category/get-by/?id=1"

Notes

  • Returns category with its parent and children in tree structure
  • Only returns non-deleted categories