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

`GetBookGrpc` invokes the internal `book.v1.BookGrpcService/GetBook` gRPC unary RPC on [[service|catalog-api]] to retrieve a compact commercial summary (ID, name, regular price, sale price, and stock status) for a single book. While [[service|basket-api]] and [[service|order-api]] wire client methods for this RPC, active checkout and enrichment flows use the batch [[query|GetBooksGrpc]] RPC instead.

## Overview

| Property                           | Value                                                                             |
| :--------------------------------- | :-------------------------------------------------------------------------------- |
| **Bounded Context**                | Catalog                                                                           |
| **Owner Service**                  | [[service\|catalog-api]]                                                          |
| **Protocol / Format**              | gRPC unary RPC (`book.v1.BookGrpcService/GetBook`), Protobuf `edition = "2023"`   |
| **Gateway Endpoint**               | Internal gRPC RPC `book.v1.BookGrpcService/GetBook` (not exposed via API Gateway) |
| **Authentication & Authorization** | Internal service-to-service anonymous read                                        |
| **Idempotency / Concurrency**      | Read-only and naturally idempotent                                                |
| **Rate Limit / Caching**           | Cached in L1 + Redis L2 keyed by book summary                                     |
| **Contract Version**               | `1.0.0`                                                                           |

## Request & Response Contract

### Request Message (`GetBookRequest`)

| Name      | Type              | Required | Constraints         | Description                               |
| :-------- | :---------------- | :------- | :------------------ | :---------------------------------------- |
| `book_id` | `string` (`uuid`) | Yes      | Tag `1`; valid UUID | Unique identifier of the book to retrieve |

### Success Response (`GetBookResponse`)

| Name         | Type              | Required | Constraints                                                          | Description                       |
| :----------- | :---------------- | :------- | :------------------------------------------------------------------- | :-------------------------------- |
| `id`         | `string` (`uuid`) | Yes      | Tag `1`                                                              | Book UUID                         |
| `name`       | `string`          | Yes      | Tag `2`                                                              | Book title                        |
| `price`      | `DecimalValue`    | Yes      | Tag `3` (`int64 units`, `sfixed32 nanos`)                            | Regular unit price                |
| `price_sale` | `DecimalValue`    | No       | Tag `4` (omitted when no sale applies)                               | Promotional sale price            |
| `status`     | `BookStatus`      | Yes      | Tag `5` (`BOOK_STATUS_IN_STOCK = 1`, `BOOK_STATUS_OUT_OF_STOCK = 2`) | Current stock availability status |

## Behavior & Side Effects

- **Read-through caching:** Resolves book summaries from L1/Redis L2 cache before querying PostgreSQL.
- **No state mutation:** Pure read RPC with no database writes or integration events.

:::note
Supplying a malformed `book_id` returns gRPC `Unknown` (`2`) rather than `InvalidArgument` (`3`); callers must validate UUID formatting before invoking this RPC.
:::

## Error Responses

| Status / Code        | Condition                                         | Client Recovery Action                                |
| :------------------- | :------------------------------------------------ | :---------------------------------------------------- |
| `NotFound` (`5`)     | No active book exists with the supplied `book_id` | Treat the book as unavailable; do not retry unchanged |
| `Unknown` (`2`)      | `book_id` is not a valid UUID                     | Validate UUID format 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|GetBooksGrpc]] — Preferred batch gRPC RPC used by [[service|basket-api]] and [[service|order-api]].
- [[query|GetBookDetailsGrpc]] — Full-detail gRPC RPC returning complete book metadata.

<NodeGraph />

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


 ## Raw Schema:schema.proto

edition = "2023";

package book.v1;

service BookGrpcService {
  rpc GetBook (GetBookRequest) returns (GetBookResponse);
}

message GetBookRequest {
  string book_id = 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;
}
