Skip to main content

Endpoint

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

Path Parameters

id
number
required
The ID of the category to retrieve

Response

Returns a JSON object containing the requested category or an error if not found.

Success Response

code
number
HTTP status code (200 for success)
status
string
Response status (‘success’)
category
object
The category object
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

Error Response

code
number
HTTP status code (404 for not found)
status
string
Response status (‘error’)
message
string
Error message describing what went wrong

Example Request

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

Example Responses

Success Response (200)

{
  "code": 200,
  "status": "success",
  "category": {
    "id": 1,
    "name": "Technology",
    "created_at": "2024-01-15T10:30:00.000000Z",
    "updated_at": "2024-01-15T10:30:00.000000Z"
  }
}

Error Response (404)

{
  "code": 404,
  "status": "error",
  "message": "La categoria no existe."
}

Implementation Details

This endpoint is defined in CategoryController.php:30 and uses Laravel’s find() method to retrieve a category by its ID. If the category is not found, it returns a 404 error with a Spanish message.

Build docs developers (and LLMs) love