library-rest
Get a user's profile, including their loans.
GET
/users/{id}/profileReturns the user matching the given id, together with their currently open loans (currentLoans) and their closed/returned loans (loanHistory).
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | yes | The user's unique identifier. |
Responses
200 The requested user profile.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| data | object | yes | A user together with their current and historical loans. |
| currentLoans | array of object | yes | The user's currently open loans (not yet returned). |
| 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. |
| loanHistory | array of object | yes | The user's closed (returned) loans. |
| 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. |
| user | object | yes | A library member who can borrow books. |
| string (email) | yes | The user's contact email address. | |
| id | string | yes | Unique identifier assigned by the server, prefixed with us_. |
| name | string | yes | The user's full name. |
| registeredAt | string (date-time) | yes | When the user joined the library. |
| 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 |
|---|---|---|
| 401 | The request is missing a valid Authorization: Bearer <token> header. | |
| 404 | No resource exists with the given id. | |
| 500 | An unexpected error occurred. The response never leaks internal error details. |
Response example
{
"data": {
"currentLoans": [
{
"bookId": "bookId_435",
"borrowedAt": "borrowedAt_360",
"dueAt": "dueAt_679",
"id": "id_342",
"overdue": true,
"returnedAt": "returnedAt_914",
"userId": "userId_571"
}
],
"loanHistory": [
{
"bookId": "bookId_288",
"borrowedAt": "borrowedAt_864",
"dueAt": "dueAt_818",
"id": "id_954",
"overdue": true,
"returnedAt": "returnedAt_190",
"userId": "userId_730"
}
],
"user": {
"email": "email_885",
"id": "id_893",
"name": "name_538",
"registeredAt": "registeredAt_327"
}
},
"meta": {
"requestId": "requestId_120",
"total": 217
}
}