Skip to main content

Endpoint

method
string
default:"GET"
GET
endpoint
string
/api/category
This endpoint does not require authentication. It is publicly accessible.

Response

Returns a JSON object containing all categories in the system.
code
number
HTTP status code (200 for success)
status
string
Response status (‘success’)
categories
array
Array of category objects
id
number
Category ID
name
string
Category name
created_at
string
Timestamp when the category was created
updated_at
string
Timestamp when the category was last updated

Example Request

cURL
curl -X GET http://your-domain.com/api/category

Example Response

Success Response (200)

{
  "code": 200,
  "status": "success",
  "categories": [
    {
      "id": 1,
      "name": "Technology",
      "created_at": "2024-01-15T10:30:00.000000Z",
      "updated_at": "2024-01-15T10:30:00.000000Z"
    },
    {
      "id": 2,
      "name": "Travel",
      "created_at": "2024-01-16T14:20:00.000000Z",
      "updated_at": "2024-01-16T14:20:00.000000Z"
    }
  ]
}

Implementation Details

This endpoint is defined in CategoryController.php:20 and uses Laravel’s Eloquent ORM to retrieve all categories from the database without pagination.

Build docs developers (and LLMs) love