API Documentation

Back
Contents

API Documentation

This page documents the wiki's JSON HTTP API: available endpoints, expected requests and responses, and authentication notes.

All API endpoints are rooted under /api and return JSON (or appropriate HTTP status codes). The API is intentionally small and mirrors the actions available in the web UI.

Authentication

Examples (using curl and a cookie jar):

# Log in (interactive web form also works). Replace credentials as appropriate.
curl -c cookies.txt -d "username=alice" -d "password=secret" -X POST https://example.org/login

# Use the saved cookie for API calls
curl -b cookies.txt https://example.org/api/pages

Endpoints

GET /api/pages

Return a list of available page base names.

Response example

{ "pages": ["Home", "About", "Linux_Router_HOWTO"] }

GET /api/pages/

Return JSON with name, markdown (source if present) and html (rendered HTML if present). name should be a URL-encoded page name (page filenames use underscores; the API accepts either underscored or spaced names if URL-encoded).

Success: 200

Example response

{
  "name": "Linux_Router_HOWTO",
  "markdown": "# Router howto\n...",
  "html": "<h1 id=\"router-howto\">Router howto</h1>..."
}

If the page doesn't exist the endpoint returns 404 and a JSON error object.

POST /api/pages

Create a new page. Requires an authenticated session.

Request body: JSON with the following fields

Headers: Content-Type: application/json

Success: 201 Created

Response example

{ "name": "My_Page" }

Errors:

PUT /api/pages/

Update an existing page or create it if missing. Requires an authenticated session.

Request body: JSON

Success: 200 with { "name": "<safe_name>" }

Errors:

Example (update):

curl -b cookies.txt -H "Content-Type: application/json" -X PUT \
  -d '{"content": "# Updated\nNew content..."}' \
  https://example.org/api/pages/My_Page

DELETE /api/pages/

Delete a page. Requires the user to be logged in and to have admin privileges (is_admin).

Success: 204 No Content (empty body)

Errors:

Example:

curl -b cookies.txt -X DELETE https://example.org/api/pages/My_Page

Notes and behavior details

Troubleshooting

Last modified: 2025-12-19 16:17 UTC by jake
Change history (2) — View full history