---
id: GetBooksGrpc
name: Get books over gRPC
version: 1.0.0
badges:
  - content: Catalog Management
    backgroundColor: green
    textColor: green
summary: Returns multiple Catalog books by identifier through the book.v1 gRPC contract.
owners:
  - catalog-experience-team
schemaPath: schema.proto
sidebar:
  badge: "gRPC"
---

`GetBooksGrpc` invokes the internal `book.v1.BookGrpcService/GetBooks` gRPC unary RPC on [[service|catalog-api]] to fetch compact commercial summaries (ID, name, price, sale price, and stock status) for multiple books in a single round trip. [[service|basket-api]] calls this RPC to enrich basket items on read, and [[service|order-api]] calls it during checkout and order detail enrichment.

## Overview

| Property                           | Value                                                                                                        |
| :--------------------------------- | :----------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Catalog                                                                                                      |
| **Owner Service**                  | [[service\|catalog-api]]                                                                                     |
| **Protocol / Format**              | gRPC unary RPC (`book.v1.BookGrpcService/GetBooks`), Protobuf `edition = "2023"`                             |
| **Gateway Endpoint**               | Internal gRPC RPC `book.v1.BookGrpcService/GetBooks` (not exposed via API Gateway)                           |
| **Authentication & Authorization** | Internal service-to-service anonymous read                                                                   |
| **Idempotency / Concurrency**      | Read-only and naturally idempotent                                                                           |
| **Rate Limit / Caching**           | Deduplicates `book_ids`, resolves hits per ID in L1 + Redis L2, and batch-queries PostgreSQL only for misses |
| **Contract Version**               | `1.0.0`                                                                                                      |

:::note
`GetBooks` silently omits unknown book IDs rather than returning `NotFound`, and returns an empty `GetBooksResponse` when `book_ids` is empty. Callers must reconcile returned `books` against requested `book_ids`.
:::

## Request & Response Contract

### Request Message (`GetBooksRequest`)

| Name       | Type                  | Required | Constraints                       | Description                                            |
| :--------- | :-------------------- | :------- | :-------------------------------- | :----------------------------------------------------- |
| `book_ids` | `string[]` (`uuid[]`) | Yes      | Tag `1` (`repeated`); valid UUIDs | List of book UUIDs to fetch (deduplicated server-side) |

### Success Response (`GetBooksResponse`)

| Name                 | Type                | Required | Constraints                                                          | Description                                          |
| :------------------- | :------------------ | :------- | :------------------------------------------------------------------- | :--------------------------------------------------- |
| `books`              | `GetBookResponse[]` | Yes      | Tag `1` (`repeated`)                                                 | Matched book summaries in deduplicated request order |
| `books[].id`         | `string` (`uuid`)   | Yes      | Tag `1`                                                              | Book UUID                                            |
| `books[].name`       | `string`            | Yes      | Tag `2`                                                              | Book title                                           |
| `books[].price`      | `DecimalValue`      | Yes      | Tag `3` (`int64 units`, `sfixed32 nanos`)                            | Regular unit price                                   |
| `books[].price_sale` | `DecimalValue`      | No       | Tag `4` (omitted when no sale applies)                               | Promotional sale price                               |
| `books[].status`     | `BookStatus`        | Yes      | Tag `5` (`BOOK_STATUS_IN_STOCK = 1`, `BOOK_STATUS_OUT_OF_STOCK = 2`) | Current stock availability status                    |

## Behavior & Side Effects

- **Per-ID cache batching:** Resolves cached book summaries first and batch-queries PostgreSQL only for cache misses, populating cache entries for subsequent reads.
- **No state mutation:** Pure read RPC with no database writes or integration events.

## Error Responses

| Status / Code        | Condition                                   | Client Recovery Action                      |
| :------------------- | :------------------------------------------ | :------------------------------------------ |
| `Unknown` (`2`)      | Any entry in `book_ids` is not a valid UUID | Validate all UUIDs before calling           |
| `Unavailable` (`14`) | Catalog API is unreachable                  | Retry within the budgeted resilience policy |

## Related Documentation

- [[service|catalog-api]] — Service overview, persistence, and gRPC services.
- [[entity|book]] — Book entity model.
- [[query|GetBasket]] — Basket API endpoint that enriches items via `GetBooks`.
- [[query|GetOrder]] — Ordering API endpoint that enriches order line-item names via `GetBooks`.
- [[query|GetBookGrpc]] — Single-book compact gRPC RPC.

<NodeGraph />

<SchemaViewer
	file="schema.proto"
	title="Get books over gRPC schema"
	maxHeight="500"
	search="true"
/>


 ## Raw Schema:schema.proto

edition = "2023";

package book.v1;

service BookGrpcService {
  rpc GetBooks (GetBooksRequest) returns (GetBooksResponse);
}

message GetBooksRequest {
  repeated string book_ids = 1;
}

message GetBooksResponse {
  repeated GetBookResponse books = 1;
}

message GetBookResponse {
  string id = 1;
  string name = 2;
  DecimalValue price = 3;
  DecimalValue price_sale = 4;
  BookStatus status = 5;
}

enum BookStatus {
  BOOK_STATUS_UNSPECIFIED = 0;
  BOOK_STATUS_IN_STOCK = 1;
  BOOK_STATUS_OUT_OF_STOCK = 2;
}

message DecimalValue {
  int64 units = 1;
  sfixed32 nanos = 2;
}
