Skip to main content
GET
/
categories
/
{id}
Get Category
curl --request GET \
  --url https://api.example.com/categories/{id}
{
  "200": {},
  "404": {},
  "500": {},
  "id": 123,
  "name": "<string>"
}

Description

This endpoint retrieves a single category by its unique identifier. If the category with the specified ID does not exist, a 404 error is returned.

Path Parameters

id
long
required
The unique identifier of the category to retrieve

Response

Returns a single category object.
id
long
Unique identifier for the category
name
string
The category name (unique across all categories)

HTTP Status Codes

200
OK
Successfully retrieved the category
404
Not Found
Category with the specified ID was not found
500
Internal Server Error
An error occurred while processing the request

Example Request

curl -X GET http://localhost:8080/categories/1 \
  -H "Content-Type: application/json"

Example Response

Success (200 OK)

{
  "id": 1,
  "name": "Electronics"
}

Error (404 Not Found)

{
  "timestamp": "2026-03-03T10:15:30.000+00:00",
  "status": 404,
  "error": "Not Found",
  "message": "Could not find category with id 1",
  "path": "/categories/1"
}

Build docs developers (and LLMs) love