# Categories API ## Available Fields | Field | Type | Description | |---|---|---| | `id` | int | Category ID | | `title` | string | Category name | | `slug` | string | URL slug (auto-generated if empty) | | `description` | string | Short description of the category | | `color` | string | Hex color for the category label/badge (e.g. `#FF5733`) | | `parent_id` | int | Parent category ID (`0` = top-level) | | `category_top` | int | `1` = show in top navigation bar, `0` = hide | | `top_menu_position` | int | Sort order in top navigation (lower number = first) | | `hamburger_menu_position` | int | Sort order in mobile/hamburger menu | | `user_id` | int | ID of the user who created the category | | `approved` | int | `1` = approved, `0` = pending review | | `status` | int | `1` = Private, `2` = Registered only, `3` = Public | | `total_views` | int | View count | | `created_at` | datetime | Creation date | | `updated_at` | datetime | Last update date | --- ## Get All Categories ```json { "resource": "category", "action": "get", "filters": { "parent_id": 0, "status": 3, "approved": 1, "search": "science" }, "fields": ["id", "title", "slug", "color", "category_top", "top_menu_position", "status"], "limit": 20, "offset": 0, "order_by": "top_menu_position ASC" } ``` | Filter | Description | |---|---| | `search` | Searches in title and slug | | `parent_id` | `0` = top-level categories only | | `status` | `1` = Private, `2` = Registered only, `3` = Public | | `approved` | `1` = approved only | --- ## Get Single Category ```json { "resource": "category", "action": "get", "id": 2 } ``` --- ## Add Category ```json { "resource": "category", "action": "add", "title": "Technology", "slug": "technology", "color": "#FF5733", "description": "Tech news and updates", "category_top": 1, "top_menu_position": 5, "hamburger_menu_position": 1, "user_id": 1, "parent_id": 0, "approved": 1, "status": 3 } ``` | Field | Required | Notes | |---|---|---| | `title` | Yes | Category name | | `slug` | No | Auto-generated if empty. No spaces allowed | | `color` | No | Hex color for badge/label | | `description` | No | Short description | | `category_top` | No | `1` = show in top nav, `0` = hide | | `top_menu_position` | No | Sort order in top nav (lower = first) | | `hamburger_menu_position` | No | Sort order in mobile menu | | `user_id` | Yes | ID of the user creating the category | | `parent_id` | No | `0` = top-level, or ID of parent category | | `approved` | No | `1` = approved, `0` = pending | | `status` | No | `1` = Private, `2` = Registered only, `3` = Public | --- ## Edit Category All fields are optional except `id`. Only fields included in the request are updated. ```json { "resource": "category", "action": "edit", "id": 116, "title": "Tech & Science", "slug": "tech-science", "color": "#00FF00", "description": "Updated description", "category_top": 1, "top_menu_position": 2, "hamburger_menu_position": 2, "parent_id": 0, "approved": 1, "status": 3 } ``` --- ## Delete Category ```json { "resource": "category", "action": "delete", "id": 121 } ``` > Note: Deleting a category moves all its articles to the default category and detaches any sub-categories.