Skip to main content
GET
/
products
/
{id}
Get Product
curl --request GET \
  --url https://api.example.com/products/{id}
{
  "200": {},
  "400": {},
  "404": {},
  "500": {},
  "id": 123,
  "name": "<string>",
  "description": "<string>",
  "price": 123,
  "stockQuantity": 123,
  "categories": [
    {
      "id": 123,
      "category": {
        "id": 123,
        "name": "<string>"
      }
    }
  ],
  "createdAt": {},
  "updatedAt": {},
  "_links": {
    "self": {},
    "products": {}
  }
}

Overview

This endpoint returns comprehensive details for a single product, including its categories, pricing, stock information, and timestamps. The response follows the Spring HATEOAS EntityModel format with embedded navigation links.

Path Parameters

id
long
required
The unique identifier of the product to retrieve

Response

id
long
Unique identifier for the product
name
string
Product name
description
string
Detailed description of the product
price
decimal
Product price in the base currency (BigDecimal format)
stockQuantity
long
Current available stock quantity
categories
array
List of category associations for this product
id
long
Product-category association ID
category
object
id
long
Category ID
name
string
Category name
createdAt
datetime
Timestamp when the product was created (ISO 8601 format)
updatedAt
datetime
Timestamp when the product was last updated (ISO 8601 format)
HATEOAS links for navigation
self
object
Link to this product resource
products
object
Link to the products collection

Status Codes

200
OK
Product retrieved successfully
404
Not Found
Product with the specified ID does not exist
400
Bad Request
Invalid product ID format (must be a valid long integer)
500
Internal Server Error
Server error occurred while retrieving the product

Examples

curl -X GET "http://localhost:8080/products/1" \
  -H "Accept: application/json"

Success Response Example

{
  "id": 1,
  "name": "Wireless Mouse",
  "description": "Ergonomic wireless mouse with adjustable DPI settings, 6 programmable buttons, and long battery life",
  "price": 29.99,
  "stockQuantity": 150,
  "categories": [
    {
      "id": 1,
      "product": null,
      "category": {
        "id": 1,
        "name": "Electronics"
      }
    },
    {
      "id": 5,
      "product": null,
      "category": {
        "id": 3,
        "name": "Computer Accessories"
      }
    }
  ],
  "createdAt": "2026-01-15T10:30:00",
  "updatedAt": "2026-02-20T14:45:00",
  "_links": {
    "self": {
      "href": "http://localhost:8080/products/1"
    },
    "products": {
      "href": "http://localhost:8080/products"
    }
  }
}

Error Response Example (404)

{
  "timestamp": "2026-03-03T10:30:00",
  "status": 404,
  "error": "Not Found",
  "message": "Could not find product 999",
  "path": "/products/999"
}
The ProductNotFoundException is thrown when a product with the specified ID cannot be found. This is handled by Spring’s exception handling mechanism to return a 404 status code.
Make sure to validate the product ID on the client side before making the request to avoid unnecessary 400 Bad Request errors from invalid ID formats.

Build docs developers (and LLMs) love