feat: new documentation

This commit is contained in:
swve
2026-03-14 12:39:57 +01:00
parent c6ffd76538
commit c0d8d90ec4
168 changed files with 11830 additions and 11996 deletions

View File

@@ -0,0 +1,5 @@
{
"index": "Overview",
"authentication": "Authentication",
"endpoints": "Endpoints"
}

View File

@@ -0,0 +1,47 @@
import { Callout } from 'nextra/components'
# API Authentication
The LearnHouse API supports **JWT cookies** for browser sessions and **API tokens** for programmatic access.
## JWT Authentication
Login to receive a JWT access token (HS256, expires in 8 hours):
```bash
curl -X POST http://localhost:1338/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "you@example.com", "password": "your-password"}'
```
Then authenticate requests via the `Authorization` header:
```bash
curl http://localhost:1338/api/v1/users/me \
-H "Authorization: Bearer <access_token>"
```
The token is also set as an `access_token_cookie` for browser-based sessions. Use `/api/v1/auth/refresh` to renew expired tokens within the 30-day refresh window.
## API Tokens
<Callout type="info">
API tokens are available on the **Pro plan**. Create and manage them in organization settings.
</Callout>
For programmatic access, use API tokens (prefixed with `lh_`):
```bash
curl http://localhost:1338/api/v1/users/me \
-H "Authorization: Bearer lh_your_api_token_here"
```
## Auth Endpoints
| Method | Endpoint | Description |
| --- | --- | --- |
| `POST` | `/api/v1/auth/login` | Login and receive a JWT |
| `GET` | `/api/v1/auth/refresh` | Refresh an expired token |
| `DELETE` | `/api/v1/auth/logout` | Invalidate the session |
| `POST` | `/api/v1/auth/oauth` | Google OAuth login |
| `POST` | `/api/v1/auth/verify-email` | Verify email address |

View File

@@ -0,0 +1,186 @@
import { Callout } from 'nextra/components'
# API Endpoints
This page provides an overview of all API endpoint groups available in LearnHouse. All endpoints are prefixed with `/api/v1/`. For the full interactive reference with request and response schemas, visit the Swagger UI at `/docs` on a development instance.
<Callout type="info">
The complete, interactive API documentation is available at [http://localhost:1338/docs](http://localhost:1338/docs) in development mode only. It includes every endpoint, parameter, and response schema.
</Callout>
## Core Endpoint Groups
### Authentication
Login, logout, token refresh, OAuth, and email verification.
```bash
# Login
curl -X POST http://localhost:1338/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password"}'
```
See [Authentication](/developers/api/authentication) for full details.
### Users
User CRUD, profile management, session info, and password reset.
```bash
# Get current user profile
curl http://localhost:1338/api/v1/users/me \
-H "Authorization: Bearer <token>"
```
### Organizations
Organization CRUD, user management, roles, invites, configuration, SEO settings, branding, API tokens, and custom domains.
```bash
# Get organization details
curl http://localhost:1338/api/v1/orgs/{org_slug} \
-H "Authorization: Bearer <token>"
```
### Courses
Course CRUD, cloning, export/import, and contributor management.
```bash
# List courses in an organization
curl http://localhost:1338/api/v1/courses \
-H "Authorization: Bearer <token>"
# Create a new course
curl -X POST http://localhost:1338/api/v1/courses \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Introduction to Python",
"description": "A beginner-friendly Python course"
}'
```
### Chapters
Chapter CRUD and ordering within courses.
```bash
# List chapters in a course
curl http://localhost:1338/api/v1/chapters \
-H "Authorization: Bearer <token>"
```
### Activities
Activity CRUD -- individual content units within chapters (pages, videos, documents).
```bash
# Get activities
curl http://localhost:1338/api/v1/activities \
-H "Authorization: Bearer <token>"
```
### Blocks
Block CRUD -- content blocks within activities.
### Collections
Collections group related courses together for organization and discovery.
```bash
# List collections
curl http://localhost:1338/api/v1/collections \
-H "Authorization: Bearer <token>"
```
### Assignments
Assignment CRUD for course assessments.
### AI
AI-powered features including an assistant, magic blocks, course planning, and RAG (Retrieval-Augmented Generation).
```bash
# AI endpoints vary by configuration
curl http://localhost:1338/api/v1/ai/chat \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message": "Explain this concept"}'
```
### Analytics
Course analytics and usage tracking.
### Search
Full-text search across courses and content.
### Code Execution
Code execution endpoints powered by Judge0.
### Learning Trails
Learning trail management and progress tracking.
### Video Streaming
Video streaming and delivery endpoints.
## Community Features (Standard Plan)
### Communities
Community forums for organizations.
### Discussions
Discussion threads within communities.
### User Groups
User group management for organizing learners.
## Pro Features (Pro Plan)
### Certifications
Certificate generation and management for course completion.
### Boards
Collaborative whiteboards for interactive learning.
### Playgrounds
AI-generated interactive elements for hands-on learning.
### Podcasts
Podcast and episode CRUD for audio content delivery.
## Infrastructure Endpoints
| Method | Endpoint | Description |
| --- | --- | --- |
| `GET` | `/api/v1/health` | Health check |
| `GET` | `/api/v1/instance/info` | Public instance information |
| `GET` | `/api/v1/content/...` | Content delivery (filesystem or S3) |
| `GET` | `/openapi.json` | OpenAPI spec (dev mode only) |
## Common Patterns
- All endpoints are prefixed with `/api/v1/`.
- Resources follow standard REST conventions: `GET` to list or retrieve, `POST` to create, `PUT` to update, `DELETE` to remove.
- Authenticated endpoints require either the `Authorization: Bearer <token>` header or the `access_token_cookie` cookie.
- Programmatic access uses API tokens with the `lh_` prefix (Pro plan).
- Responses are returned as JSON.
<Callout type="info">
Endpoint paths and request/response schemas may evolve between versions. Always refer to the interactive `/docs` endpoint on a development instance for the most up-to-date reference.
</Callout>

View File

@@ -0,0 +1,50 @@
import { Callout } from 'nextra/components'
# API Reference
The LearnHouse API is a RESTful service built with **FastAPI**. It powers all platform operations, from user authentication to course management and AI features. All endpoints are prefixed with `/api/v1/`.
## Interactive Documentation
<Callout type="warning">
The interactive API documentation is only available when running in **development mode**. Production instances do not expose Swagger UI or the OpenAPI spec.
</Callout>
When running the development environment, auto-generated interactive API documentation is available:
- **Swagger UI** -- Available at `/docs` (e.g., [http://localhost:1338/docs](http://localhost:1338/docs))
These interfaces let you explore all available endpoints, view request and response schemas, and test API calls directly from your browser.
## Base URL
In local development, the API is available at:
```
http://localhost:1338/api/v1/
```
In production, the API is served behind a reverse proxy and is accessible at the root domain under `/api/v1/`.
## Response Format
All API responses are returned as JSON. Successful responses typically include the requested data directly, while error responses follow this structure:
```json
{
"detail": "Description of the error"
}
```
## Sections
- **[Authentication](/developers/api/authentication)** -- How to obtain and use authentication tokens.
- **[Endpoints](/developers/api/endpoints)** -- Overview of the key API endpoint groups.
## OpenAPI Specification
Since the API is built with FastAPI, a machine-readable OpenAPI specification is available at `/openapi.json` on development instances. This can be used to generate client libraries or import into API testing tools.
<Callout type="info">
The OpenAPI spec at `/openapi.json` is only served in development mode.
</Callout>