Get a book by ID
Returns a books object that contains only the book specified by the id parameter, if it exists.
Endpoint
{server_url}/books/{id}
Parameters
| Name | Type | Value | Description |
|---|---|---|---|
id | path | number | The record ID of the book resource to return |
Request headers
| Header | Value | Required |
|---|---|---|
Accept | application/json | No |
Authorization | Bearer {token} | Yes |
Request body
None
Response body
Returns a books resource
Examples
GET example request
curl -G -H "Accept: application/json" \
--url "http://localhost:3000/books/2"
GET example response
{
"id": 2,
"title": "Verity",
"author": "Collen Hoover",
"genre": "Thriller",
"readingStatus": "70 %",
"rating": "5"
}
Response status
| HTTP status value | Description |
|---|---|
| 200 | Success: Requested data returned successfully |
| 400 | Bad request — the request was malformed or contains invalid parameters |
| 401 | Unauthorized — authentication is required or credentials are invalid |
| 403 | Forbidden — the authenticated user does not have permission |
| 404 | Not found — the requested resource was not found |
| 429 | Too many requests — rate limit exceeded |
| 500 | Internal server error — an unexpected server error occurred |
| ECONNREFUSED | Service is offline. Start, or restart the service and try again. |