---
id: ListBooks
name: List books
version: 1.0.0
badges:
  - content: Catalog Management
    backgroundColor: green
    textColor: green
summary: Returns a filterable collection of books with pricing, availability, relationships, and rating summaries.
owners:
  - catalog-experience-team
schemaPath: schema.json
operation:
  method: QUERY
  path: /api/v1/books
  statusCodes: ["200", "400"]
sidebar:
  badge: "QUERY"
---

`ListBooks` queries [[service|catalog-api]] (`QUERY /catalog/api/v1/books`) with an optional JSON request body to search, filter, sort, and paginate catalog books. The endpoint is publicly readable, uses hybrid vector search when `search` is supplied, caches results, and emits total counts and navigation links in HTTP response headers.

## Overview

| Property                           | Value                                                                                                                                                                                     |
| :--------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Catalog                                                                                                                                                                                   |
| **Owner Service**                  | [[service\|catalog-api]]                                                                                                                                                                  |
| **Protocol / Format**              | HTTP `QUERY`, `application/json` request and response                                                                                                                                     |
| **Gateway Endpoint**               | `QUERY /catalog/api/v1/books` (service path `/api/v1/books`)                                                                                                                              |
| **Authentication & Authorization** | None required (public read endpoint)                                                                                                                                                      |
| **Idempotency / Concurrency**      | Read-only and naturally idempotent                                                                                                                                                        |
| **Rate Limit / Caching**           | Global concurrency (`100`), per-IP fixed-window (`30 req/min`), and per-user token bucket (`30` limit, `20` per `10s`, queue `5`); caches search IDs (`5 min`) and filtered pages (`60s`) |
| **Contract Version**               | `1.0.0` (`ApiVersions.V1`)                                                                                                                                                                |

## Request & Response Contract

### Request Body (`application/json`, optional)

Omitting the request body applies all defaults below.

| Name           | Type               | Required | Constraints                                                                               | Description                                                                                     |
| :------------- | :----------------- | :------- | :---------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- |
| `pageIndex`    | `integer`          | No       | Default `1`; must be `> 0`                                                                | 1-based page number to retrieve                                                                 |
| `pageSize`     | `integer`          | No       | Default `20`; must be `> 0`                                                               | Maximum number of books per page (also caps vector search candidate count)                      |
| `orderBy`      | `string \| null`   | No       | Default `"Name"`; supports `Name`, `Price.OriginalPrice`, `Price.DiscountPrice`, `Status` | Field used to sort results (unknown values fall back to `Name`; ties ordered by ID)             |
| `isDescending` | `boolean`          | No       | Default `false`                                                                           | Sorts descending when `true` and ascending when `false`                                         |
| `search`       | `string \| null`   | No       | Trimmed, lowercased for cache key                                                         | Free-text query executed via hybrid vector search; returns empty page if zero vector hits match |
| `minPrice`     | `number \| null`   | No       | Decimal                                                                                   | Inclusive minimum price filter                                                                  |
| `maxPrice`     | `number \| null`   | No       | Decimal                                                                                   | Inclusive maximum price filter                                                                  |
| `categoryId`   | `string[] \| null` | No       | Array of UUIDs                                                                            | Restricts results to books matching any supplied category ID                                    |
| `publisherId`  | `string[] \| null` | No       | Array of UUIDs                                                                            | Restricts results to books matching any supplied publisher ID                                   |
| `authorIds`    | `string[] \| null` | No       | Array of UUIDs                                                                            | Restricts results to books associated with any supplied author ID                               |

### Response Headers (`200 OK`)

| Name               | Type     | Required | Constraints                               | Description                                                                                 |
| :----------------- | :------- | :------- | :---------------------------------------- | :------------------------------------------------------------------------------------------ |
| `Pagination-Count` | `string` | Yes      | Integer string (e.g., `84`)               | Total number of books matching the active filters across all pages                          |
| `Link`             | `string` | Yes      | Comma-separated `<uri>;rel=<rel>` entries | Navigation URIs with `first`, `self`, `last`, and conditional `previous` / `next` relations |

### Success Response (`200 OK`)

Returns a JSON array of book objects (`[]` when no books match). Each item matches the response schema documented in [[query|GetBook]].

## Behavior & Side Effects

- **Hybrid vector search:** When `search` is non-empty, executes a hybrid vector search against Qdrant and filters matching book IDs from PostgreSQL.
- **Two-tier caching:** Caches vector search ID lists for 5 minutes and filtered page results for 60 seconds; invalidated on catalog mutations.
- **No state mutation:** Pure read query with no database writes or integration events.

## Error Responses

| Status / Code           | Condition                                                                                   | Client Recovery Action                              |
| :---------------------- | :------------------------------------------------------------------------------------------ | :-------------------------------------------------- |
| `400 Bad Request`       | `pageIndex <= 0`, `pageSize <= 0`, malformed UUID in filter arrays, or invalid JSON payload | Fix request body values; do not retry unchanged     |
| `429 Too Many Requests` | Rate limit quota exceeded (`Retry-After` header included)                                   | Wait for the `Retry-After` duration before retrying |

## Related Documentation

- [[service|catalog-api]] — Service overview, persistence, and endpoints.
- [[entity|book]] — Book entity model.
- [[query|GetBook]] — Retrieve a single book projection by ID.
- [[query|ListBooksGrpc]] — Internal gRPC book search endpoint used by MCP Tools.

<NodeGraph />

<SchemaViewer file="schema.json" title="List books schema" maxHeight="500" search="true" />


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "ListBooksResponse",
	"description": "Book collection returned by the Catalog API.",
	"type": "array",
	"items": {
		"type": "object",
		"additionalProperties": false,
		"required": [
			"id",
			"name",
			"description",
			"imageUrl",
			"price",
			"priceSale",
			"status",
			"category",
			"publisher",
			"authors",
			"averageRating",
			"totalReviews"
		],
		"properties": {
			"id": {
				"type": "string",
				"format": "uuid",
				"description": "A UUID identifying the resource."
			},
			"name": {
				"type": ["string", "null"]
			},
			"description": {
				"type": ["string", "null"]
			},
			"imageUrl": {
				"type": ["string", "null"],
				"format": "uri"
			},
			"price": {
				"type": "number"
			},
			"priceSale": {
				"type": ["number", "null"]
			},
			"status": {
				"type": "string",
				"enum": ["InStock", "OutOfStock"]
			},
			"category": {
				"type": ["object", "null"],
				"properties": {
					"id": {
						"type": "string",
						"format": "uuid",
						"description": "A UUID identifying the resource."
					},
					"name": {
						"type": ["string", "null"]
					}
				},
				"required": ["id", "name"]
			},
			"publisher": {
				"type": ["object", "null"],
				"properties": {
					"id": {
						"type": "string",
						"format": "uuid",
						"description": "A UUID identifying the resource."
					},
					"name": {
						"type": ["string", "null"]
					}
				},
				"required": ["id", "name"]
			},
			"authors": {
				"type": "array",
				"items": {
					"type": "object",
					"properties": {
						"id": {
							"type": "string",
							"format": "uuid",
							"description": "A UUID identifying the resource."
						},
						"name": {
							"type": ["string", "null"]
						}
					},
					"required": ["id", "name"]
				}
			},
			"averageRating": {
				"type": "number",
				"minimum": 0
			},
			"totalReviews": {
				"type": "integer",
				"minimum": 0
			}
		}
	}
}
