library-rest

List loans with optional filtering.

GET/loans

Returns loans matching the given filters, ordered by id. All filters are optional and combine with logical AND. This endpoint is not paginated.

Parameters

NameInTypeRequiredDescription
userIdquerystringRestrict results to loans made by this user.
bookIdquerystringRestrict results to loans of this book.
overduequerybooleanRestrict results to loans whose overdue state, evaluated at request time, matches this value.

Responses

200 The loans matching the filter.

application/json

FieldTypeRequiredDescription
dataarray of objectyes
bookIdstringyesThe id of the borrowed Book.
borrowedAtstring (date-time)yesWhen the loan started.
dueAtstring (date-time)yesWhen the book is expected back.
idstringyesUnique identifier assigned by the server, prefixed with ln_.
overduebooleanyesComputed at response time: true if the loan is still open and past its dueAt. Never stored, so it never goes stale.
returnedAtstring (date-time)When the book was actually returned, or null while the loan is still open.
userIdstringyesThe id of the User who borrowed the book.
metaobjectyesResponse metadata attached to every successful response.
requestIdstringyesCorrelation id for this request, echoed from the X-Request-Id request header or generated if absent. Useful for tracing a request across logs.
totalintegerTotal number of matches before pagination was applied. Present only on paginated list responses (currently GET /books).

Errors

CodeMessageDescription
400overdue could not be parsed as a boolean.
401The request is missing a valid Authorization: Bearer <token> header.
500An 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
  }
}