# Marten Get By Id

> Adds a new GET operation to fetch a single resource by ID. Handles 404s, caching, and localization.

- Skill: `majiayu000/marten-get-by-id` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/marten-get-by-id`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/marten-get-by-id/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/marten-get-by-id

---


Follow this guide to implement a **Get By ID** endpoint in the ApiService.

1.  **Prerequisites**
    -   Ensure the Projection exists (`/marten__single_stream_projection` or similar).

2.  **Create Endpoint**
    -   Create/Update `src/BookStore.ApiService/Endpoints/{Resource}Endpoints.cs`
    -   **Method**: `MapGet`
    -   **Logic**: `GetOrCreateLocalizedAsync` -> `LoadAsync` -> Map to DTO
    -   **Template**: `templates/GetByIdEndpoint.cs`

3.  **Client Integration**
    -   Create `IGet{Resource}Endpoint.cs` in Client project.

## Related Skills
- `/marten__list_query`: For fetching lists of resources.

