Files
bookhoard/bruno/analytics/Get Reading Stats.bru
T
john-okeefe 26070e4000 Refactor: rename baseUrl to base_url in .bru files
Update configuration key naming convention to use snake_case
consistently.
Applies changes recursively across all subdirectories.
2026-02-08 21:26:31 -05:00

105 lines
2.5 KiB
Plaintext

meta {
name: Get Reading Stats
type: http
seq: 4
}
get {
url: {{base_url}}/api/analytics/reading-stats
body: none
auth: inherit
}
tests {
test("status must be 200", function() {
expect(res.status).to.eql(200);
});
test("response has required stats fields", function() {
const body = JSON.parse(res.body);
expect(body).to.have.property("total_books_read");
expect(body).to.have.property("total_pages_read");
expect(body).to.have.property("total_reading_time_minutes");
expect(body).to.have.property("completion_rate");
expect(body).to.have.property("daily_reading_minutes");
});
test("daily_reading_minutes is an array", function() {
const body = JSON.parse(res.body);
expect(body.daily_reading_minutes).to.be.an("array");
});
}
settings {
encodeUrl: true
timeout: 0
}
docs {
Get overall reading statistics for the authenticated user.
**Endpoint**: GET /api/analytics/reading-stats
**Auth**: Required (Bearer token)
## Query Parameters
| Parameter | Type | Required | Description |
|-----------|------|-----------|-------------|
| start_date | string | No | Start date (ISO 8601 format) |
| end_date | string | No | End date (ISO 8601 format) |
## Response Fields
| Field | Type | Description |
|-------|------|-------------|
| total_books_read | int | Total books completed |
| total_pages_read | int | Total pages read |
| total_reading_time_minutes | int | Total reading time in minutes |
| completion_rate | float | Average book completion rate (0-1) |
| daily_reading_minutes | array | Daily reading time breakdown |
| daily_reading_minutes[].date | string | Date (ISO 8601) |
| daily_reading_minutes[].minutes | int | Minutes read on that date |
## Example Request
```
GET /api/analytics/reading-stats
```
## Example Response
```json
{
"total_books_read": 12,
"total_pages_read": 3450,
"total_reading_time_minutes": 5400,
"completion_rate": 0.78,
"daily_reading_minutes": [
{
"date": "2026-01-15",
"minutes": 45
},
{
"date": "2026-01-16",
"minutes": 60
}
]
}
```
## Error Responses
| Code | Description |
|------|-------------|
| 400 | Invalid date format |
| 401 | Unauthorized |
| 500 | Internal server error |
## Notes
- Without date parameters, returns stats for the last 30 days
- Dates must be in ISO 8601 format (YYYY-MM-DD) when provided
- Only includes reading activity from the authenticated user
- Daily data includes all days with reading activity
}