Skip to content

API Documentation

LibrisLog provides a full REST API with interactive documentation.

Interactive API Docs

Two documentation interfaces are available when the backend is running:

  • Swagger UI: http://localhost:8000/api/docs
  • ReDoc: http://localhost:8000/api/redoc

The OpenAPI schema is also available at:

  • JSON: http://localhost:8000/api/openapi.json

Authentication

All API endpoints (except health check and documentation) require authentication via an API key.

Creating an API Key

  1. Log in to the web application
  2. Go to your Profile page
  3. Scroll to the "API Keys" section
  4. Click "Create API Key"
  5. Enter a description (optional)
  6. Copy the key immediately — it is shown only once

API Keys

Using an API Key

Include the key in the X-API-Key header with every request:

bash
curl -H "X-API-Key: YOUR_KEY_HERE" http://localhost:8000/api/books

Example Request

bash
# List all books
curl -H "X-API-Key: YOUR_KEY_HERE" \
  http://localhost:8000/api/books

# Create a new book
curl -X POST \
  -H "X-API-Key: YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"title": "The Great Gatsby", "author": "F. Scott Fitzgerald"}' \
  http://localhost:8000/api/books

# Update reading status
curl -X POST \
  -H "X-API-Key: YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"new_status": "read"}' \
  http://localhost:8000/api/books/1/transition-status

Key Endpoints

Books

MethodEndpointDescription
GET/api/booksList all books
POST/api/booksCreate a book
GET/api/books/{id}Get book details
PUT/api/books/{id}Update book
DELETE/api/books/{id}Delete book
POST/api/books/{id}/transition-statusChange reading status

Progress

MethodEndpointDescription
GET/api/books/{id}/progressList progress entries
POST/api/books/{id}/progressAdd progress entry
PATCH/api/books/{id}/progress/{entry_id}Update progress date
DELETE/api/books/{id}/progress/{entry_id}Delete progress entry

Statistics

MethodEndpointDescription
GET/api/statisticsFull statistics
GET/api/statistics/pages-per-dayDaily page breakdown

Data Import/Export

MethodEndpointDescription
POST/api/data/exportExport data
POST/api/data/import/parseParse import file
POST/api/data/import/validateValidate import
POST/api/data/import/executeExecute import

Book Import (External Sources)

MethodEndpointDescription
GET/api/import/searchSearch external sources
GET/api/import/search/streamStream search progress
POST/api/importImport a candidate

Authentication

MethodEndpointDescription
POST/api/auth/setupCreate first admin (only when no admin exists)
POST/api/auth/loginLog in with email and password
POST/api/auth/logoutLog out (clear session)
GET/api/auth/meGet current user
GET/api/auth/csrfGet CSRF token
POST/api/auth/forgot-passwordRequest a password reset email (always returns 200)
POST/api/auth/reset-passwordReset password using a token from the reset email
Password Reset Endpoints

These endpoints do not require an API key or session — they are public.

Forgot Password

bash
curl -X POST http://localhost:8000/api/auth/forgot-password \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "locale": "en"}'

Always returns 200 with {"message": "If the email is registered, a reset link has been sent"} to prevent user enumeration. The locale field is optional (defaults to en) and controls the email language.

Reset Password

bash
curl -X POST http://localhost:8000/api/auth/reset-password \
  -H "Content-Type: application/json" \
  -d '{"token": "token-from-email", "password": "new-secure-password"}'

Returns 200 on success, 400 if the token is invalid/expired or the password doesn't meet complexity requirements. After a successful reset, all existing sessions for that user are invalidated.

Error Handling

The API returns standard HTTP status codes:

  • 200 — Success
  • 201 — Created
  • 204 — No content (delete success)
  • 400 — Bad request
  • 401 — Unauthorized (missing or invalid API key)
  • 404 — Not found
  • 409 — Conflict (e.g., duplicate ISBN)
  • 422 — Validation error

Error responses include a JSON body with details:

json
{
  "detail": "Book not found"
}

Released under the MIT License.