library-rest
List loans with optional filtering.
GET
/loansReturns loans matching the given filters, ordered by id. All filters are optional and combine with logical AND. This endpoint is not paginated.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| userId | query | string | Restrict results to loans made by this user. | |
| bookId | query | string | Restrict results to loans of this book. | |
| overdue | query | boolean | Restrict results to loans whose overdue state, evaluated at request time, matches this value. |
Responses
200 The loans matching the filter.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| data | array of object | yes | |
| bookId | string | yes | The id of the borrowed Book. |
| borrowedAt | string (date-time) | yes | When the loan started. |
| dueAt | string (date-time) | yes | When the book is expected back. |
| id | string | yes | Unique identifier assigned by the server, prefixed with ln_. |
| overdue | boolean | yes | Computed at response time: true if the loan is still open and past its dueAt. Never stored, so it never goes stale. |
| returnedAt | string (date-time) | When the book was actually returned, or null while the loan is still open. | |
| userId | string | yes | The id of the User who borrowed the book. |
| 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 |
|---|---|---|
| 400 | overdue could not be parsed as a boolean. | |
| 401 | The request is missing a valid Authorization: Bearer <token> header. | |
| 500 | An unexpected error occurred. The response never leaks internal error details. |
Response example
{
"data": [
{
"bookId": "bookId_946",
"borrowedAt": "borrowedAt_7",
"dueAt": "dueAt_451",
"id": "id_341",
"overdue": true,
"returnedAt": "returnedAt_602",
"userId": "userId_105"
}
],
"meta": {
"requestId": "requestId_309",
"total": 611
}
}