diff --git a/backend/main.py b/backend/main.py index 7747747..6b14d90 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1325,7 +1325,8 @@ async def create_share(request: Request, note_path: str, data: dict = None): @api_router.get("/share/{note_path:path}") -async def get_share_status(note_path: str, request: Request): +@limiter.limit("120/minute") +async def get_share_status(request: Request, note_path: str): """ Get the share status for a note. Returns whether the note is shared and its share URL if so. @@ -1350,7 +1351,8 @@ async def get_share_status(note_path: str, request: Request): @api_router.get("/shared-notes") -async def list_shared_notes(): +@limiter.limit("60/minute") +async def list_shared_notes(request: Request): """ Get a list of all currently shared note paths. Used for displaying share indicators in the UI. diff --git a/documentation/API.md b/documentation/API.md index adde9a3..c8003c0 100644 --- a/documentation/API.md +++ b/documentation/API.md @@ -430,6 +430,75 @@ Creates a new note from a template with placeholder replacement. --- +## 🔗 Sharing + +Share notes publicly without requiring authentication. + +### Create Share Link +```http +POST /api/share/{note_path} +Content-Type: application/json + +{ + "theme": "dracula" +} +``` +Creates a share token for the note. The `theme` is optional (defaults to "light"). + +**Response:** +```json +{ + "success": true, + "token": "LRFEo86oSVeJ3Gju", + "url": "http://localhost:8000/share/LRFEo86oSVeJ3Gju", + "note_path": "folder/note.md" +} +``` + +### Get Share Status +```http +GET /api/share/{note_path} +``` +Check if a note is currently shared. + +**Response:** +```json +{ + "shared": true, + "token": "LRFEo86oSVeJ3Gju", + "url": "http://localhost:8000/share/LRFEo86oSVeJ3Gju", + "theme": "dracula", + "created": "2026-01-15T10:30:00+00:00" +} +``` + +### Revoke Share +```http +DELETE /api/share/{note_path} +``` +Removes public access to the note. + +### List Shared Notes +```http +GET /api/shared-notes +``` +Returns paths of all currently shared notes. + +**Response:** +```json +{ + "paths": ["folder/note.md", "another.md"] +} +``` + +### View Shared Note (Public) +```http +GET /share/{token} +``` +Public endpoint - no authentication required. Returns the note as a standalone HTML page with the theme set when sharing was created. + +--- + ## 📝 Response Format All endpoints return JSON responses: