library-rpc
List loans with optional filtering.
RPC
loans.listReturns 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/rpcParameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| userId | params | string | Restrict results to loans made by this user. | |
| bookId | params | string | Restrict results to loans of this book. | |
| overdue | params | boolean | Restrict results to loans whose overdue state, evaluated at call time, matches this value. |
Responses
result The loans matching the filter.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| loans | 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. |
Errors
| Code | Message | Description |
|---|---|---|
| -32602 | Invalid 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"
}
]
}
}