Skip to main content
GET
/
products
List Products
curl --request GET \
  --url https://api.example.com/products
{
  "200": {},
  "400": {},
  "500": {},
  "_embedded": {
    "productViewList": [
      {
        "id": 123,
        "name": "<string>",
        "description": "<string>",
        "price": 123,
        "stockQuantity": 123,
        "categories": [
          {}
        ],
        "createdAt": {},
        "updatedAt": {},
        "_links": {}
      }
    ]
  },
  "_links": {
    "self": {},
    "first": {},
    "last": {},
    "next": {},
    "prev": {}
  },
  "page": {
    "size": 123,
    "totalElements": 123,
    "totalPages": 123,
    "number": 123
  }
}

Overview

This endpoint returns a paginated collection of products with support for sorting and page navigation. The response follows the Spring HATEOAS PagedModel format with embedded links for navigation.

Query Parameters

page
integer
default:"0"
The page number to retrieve (zero-based)
size
integer
default:"20"
The number of products per page
sort
string
Sorting criteria in the format property,direction (e.g., name,asc or price,desc). Can be used multiple times for multi-field sorting.

Response

_embedded
object
productViewList
array
Array of product objects
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
stockQuantity
long
Available stock quantity
categories
array
List of category associations for this product
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
Pagination and navigation links
self
object
Link to the current page
first
object
Link to the first page
last
object
Link to the last page
next
object
Link to the next page (if available)
prev
object
Link to the previous page (if available)
page
object
Pagination metadata
size
integer
Number of items per page
totalElements
long
Total number of products across all pages
totalPages
integer
Total number of pages
number
integer
Current page number (zero-based)

Status Codes

200
OK
Products retrieved successfully
400
Bad Request
Invalid pagination parameters
500
Internal Server Error
Server error occurred while retrieving products

Examples

curl -X GET "http://localhost:8080/products?page=0&size=10&sort=name,asc" \
  -H "Accept: application/json"

Response Example

{
  "_embedded": {
    "productViewList": [
      {
        "id": 1,
        "name": "Wireless Mouse",
        "description": "Ergonomic wireless mouse with adjustable DPI",
        "price": 29.99,
        "stockQuantity": 150,
        "categories": [
          {
            "id": 1,
            "product": null,
            "category": {
              "id": 1,
              "name": "Electronics"
            }
          }
        ],
        "createdAt": "2026-01-15T10:30:00",
        "updatedAt": "2026-02-20T14:45:00",
        "_links": {
          "self": {
            "href": "http://localhost:8080/products/1"
          }
        }
      },
      {
        "id": 2,
        "name": "Mechanical Keyboard",
        "description": "RGB mechanical keyboard with cherry MX switches",
        "price": 89.99,
        "stockQuantity": 75,
        "categories": [
          {
            "id": 2,
            "product": null,
            "category": {
              "id": 1,
              "name": "Electronics"
            }
          }
        ],
        "createdAt": "2026-01-20T09:15:00",
        "updatedAt": "2026-02-25T11:20:00",
        "_links": {
          "self": {
            "href": "http://localhost:8080/products/2"
          }
        }
      }
    ]
  },
  "_links": {
    "self": {
      "href": "http://localhost:8080/products?page=0&size=10&sort=name,asc"
    },
    "next": {
      "href": "http://localhost:8080/products?page=1&size=10&sort=name,asc"
    },
    "last": {
      "href": "http://localhost:8080/products?page=4&size=10&sort=name,asc"
    }
  },
  "page": {
    "size": 10,
    "totalElements": 50,
    "totalPages": 5,
    "number": 0
  }
}
This endpoint uses Spring Data’s Pageable interface, which provides flexible pagination and sorting out of the box. The default page size is typically 20 items.

Build docs developers (and LLMs) love