library-rpc

List loans with optional filtering.

RPCloans.list

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

Servers

•mock: https://mock.api.selfdochub.com/rpc

Parameters

NameInTypeRequiredDescription
userIdparamsstringRestrict results to loans made by this user.
bookIdparamsstringRestrict results to loans of this book.
overdueparamsbooleanRestrict results to loans whose overdue state, evaluated at call time, matches this value.

Responses

result The loans matching the filter.

application/json

FieldTypeRequiredDescription
loansarray 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.

Errors

CodeMessageDescription
-32602Invalid params

Request example

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "loans.list",
  "params": {
    "bookId": "bookId_639",
    "overdue": true,
    "userId": "userId_375"
  }
}

Response example

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "loans": [
      {
        "bookId": "bookId_825",
        "borrowedAt": "borrowedAt_525",
        "dueAt": "dueAt_335",
        "id": "id_139",
        "overdue": true,
        "returnedAt": "returnedAt_570",
        "userId": "userId_241"
      }
    ]
  }
}