library-rest
Get a single book by id.
GET
/books/{id}Returns the book matching the given id.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | yes | The book's unique identifier. |
Responses
200 The requested book.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| data | object | yes | A single library title. |
| authorId | string | yes | The id of the Author who wrote this book. |
| createdAt | string (date-time) | yes | When the book record was created. |
| id | string | yes | Unique identifier assigned by the server, prefixed with bk_. |
| isbn | string | yes | The book's ISBN. Must be unique across the catalog. |
| publishedYear | integer | yes | The year the book was first published. Must be between 1450 and next year. |
| status | string | yes | A book's availability. borrowed means it is out on an open loan. Allowed values: available, borrowed |
| title | string | yes | The book's display title, 1–200 characters. |
| updatedAt | string (date-time) | yes | When the book record was last modified. |
| meta | object | yes | Response metadata attached to every successful response. |
| requestId | string | yes | Correlation id for this request, echoed from the X-Request-Id request header or generated if absent. Useful for tracing a request across logs. |
| total | integer | Total number of matches before pagination was applied. Present only on paginated list responses (currently GET /books). |
Errors
| Code | Message | Description |
|---|---|---|
| 401 | The request is missing a valid Authorization: Bearer <token> header. | |
| 404 | No resource exists with the given id. | |
| 500 | An unexpected error occurred. The response never leaks internal error details. |
Response example
{
"data": {
"authorId": "authorId_952",
"createdAt": "createdAt_833",
"id": "id_546",
"isbn": "isbn_830",
"publishedYear": 779,
"status": "borrowed",
"title": "title_267",
"updatedAt": "updatedAt_530"
},
"meta": {
"requestId": "requestId_122",
"total": 778
}
}