Skip to main content

OpenAPI 3.1 Reference

learnalgorithms.dev API

Privacy-preserving REST API written with the Python standard library and SQLite. Stores no personal data or IP addresses. Click any endpoint below to inspect its schema or try live public requests.

https://api.learnalgorithms.devDownload openapi.yaml ↓

Public endpoints

GET/healthLiveness check

Returns 200 OK when the API container is healthy and ready to serve requests.

curl -i https://api.learnalgorithms.dev/health
200 OK — {"status":"ok"}
GET/popularMost read lessons of the last 7 days

Fetched server-to-server from Matomo and cached in memory for 15 minutes. Degrades gracefully to an empty list if Matomo is unreachable.

curl -i https://api.learnalgorithms.dev/popular
200 OK — {"pages":[{"page":"...","visits":42}]}
GET/feedback/summaryAggregated helpfulness votes for one lesson

Query parameter: page (e.g. /concepts/sorting/quicksort). Rate-limited per IP.

curl -i "https://api.learnalgorithms.dev/feedback/summary?page=/concepts/sorting/quicksort"
200 OK — {"page":"...","helpful":10,"notHelpful":1}400 Bad Request — invalid page429 Too Many Requests
POST/feedbackSubmit anonymous lesson feedbackOrigin: learnalgorithms.dev

Stores a helpful/not-helpful vote with an optional comment (max 500 chars). Protected against bots with a honeypot field, minimum time on page (1 s), and one row per page, client, and day (same-day vote/comment updates allowed).

{
  "page": "/concepts/sorting/quicksort",
  "helpful": true,
  "comment": "The partition trace made it click!",
  "elapsed": 12000,
  "website": "",
  "client": "11111111-1111-4111-8111-111111111111"
}
201 Created — stored200 OK — already voted today202 Accepted — bot check400 Bad Request403 Forbidden429 Too Many Requests
POST/eventsRecord anonymous student/usage telemetry eventsOrigin: learnalgorithms.dev

Accepts a single event or a batch (max 20 events, 4 KB body). Allowed eventType values: page_view, page_leave, lesson_complete, lesson_uncomplete, cheat_sheet_filter, cheat_sheet_compare, visualizer_interact, search, details_open, resource_click, web_vitals.

{
  "events": [
    {
      "sessionId": "11111111-1111-4111-8111-111111111111",
      "eventType": "page_leave",
      "page": "/concepts/sorting/quicksort",
      "durationMs": 45000,
      "scrollPct": 85
    }
  ]
}
201 Created — {"status":"stored","count":1}400 Bad Request403 Forbidden429 Too Many Requests
POST/surveySubmit anonymous course satisfaction survey (1–5)Origin: learnalgorithms.dev

Records four 1–5 ratings (clarity, usefulness, tools, overall) plus an optional comment. One updatable row per client and day; no personal data or IPs stored.

{
  "clarity": 5,
  "usefulness": 5,
  "tools": 4,
  "overall": 5,
  "comment": "The Cheat Sheet and Knowledge Graph are super useful.",
  "elapsed": 8000,
  "website": ""
}
201 Created — {"status":"saved"}202 Accepted — bot check400 Bad Request403 Forbidden
POST/questionsAsk an anonymous private questionOrigin: learnalgorithms.dev

Stores a question (up to 2,000 characters) with no account, contact data or IP, and returns a one-time ticket. Only a SHA-256 hash of the ticket is stored. Questions are never sent to the external LLM.

{
  "page": "/concepts/sorting/quicksort",
  "question": "Why is the pivot swapped at the end of the partition?",
  "elapsed": 8000,
  "website": ""
}
201 Created — {"status":"saved","ticket":"K7Q4-MXP2-D9RT"}202 Accepted — bot check400 Bad Request403 Forbidden
POST/questions/statusCheck the answers of your ticketsOrigin: learnalgorithms.dev

Up to 20 tickets, kept in the asker's browser. Returns the status (pending or answered) and the answer of the known ones.

{ "tickets": ["K7Q4-MXP2-D9RT"] }
200 OK — {"questions":[...]}400 Bad Request

Integrations & Webhooks

POST/webhooks/githubReceive GitHub issue eventsHMAC-SHA256

Verifies X-Hub-Signature-256 in constant time using GITHUB_WEBHOOK_SECRET and stores issue events idempotently by X-GitHub-Delivery.

200 OK — ping202 Accepted — ignored204 No Content — stored400 Bad Request401 Unauthorized

Admin & Teaching Innovation Analytics

GET/admin/statsAggregated learning analytics summaryBearer Token

Query parameter: days (1–365, default 30). Returns totals (events, sessions, activeDays), events by type, top pages with average duration and scroll depth, lesson completions, and daily activity.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/stats?days=30"
200 OK — JSON report400 Bad Request401 Unauthorized
GET/admin/eventsExport anonymized telemetry events (JSON or CSV)Bearer Token

Query parameters: days (1–365, default 30), limit (1–5000, default 500), format (json | csv). With format=csv downloads learnalgorithms-events.csv ready for Excel, R, SPSS, or Python.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/events?days=30&format=csv" -o learnalgorithms-events.csv
200 OK — application/json or text/csv400 Bad Request401 Unauthorized
GET/admin/feedbackLatest qualitative feedback votes and commentsBearer Token

Returns the latest 200 feedback entries stored in SQLite with Cache-Control: no-store.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/feedback"
200 OK — {"feedback":[...]}401 Unauthorized
GET/admin/issuesLatest GitHub issue webhook eventsBearer Token

Returns the latest 200 GitHub issue events recorded via POST /webhooks/github.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/issues"
200 OK — {"issues":[...]}401 Unauthorized
GET/admin/surveyAggregated course satisfaction survey resultsBearer Token

Query parameter: days (0 = all time, 1–3650, default 30). Returns total responses, 1–5 averages, score distribution, and recent comments.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/survey?days=30"
200 OK — JSON summary401 Unauthorized
GET/admin/questionsAnonymous questions inboxBearer Token

Query parameter: status (all | pending | answered). POST /admin/questions/{id}/answer answers one privately (only the holder of the ticket sees it); DELETE /admin/questions/{id} removes it.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/questions?status=pending"
200 OK — {"questions":[...]}401 Unauthorized
GET/admin/tasksTeacher's private to-do listBearer Token

POST /admin/tasks creates one task (or several with {"tasks": [...]}); POST /admin/tasks/{id} updates fields; DELETE /admin/tasks/{id} removes it. Fields: title, description, due (optional deadline, YYYY-MM-DD), priority (1 high, 2 medium, 3 low), done; the entry date is set automatically, and tasks done more than 10 days ago are deleted.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/tasks"
200 OK — {"tasks":[...]}401 Unauthorized
GET/admin/docs/{name}Private Markdown documents (e.g. the roadmap)Bearer Token

Returns the current content and the list of saved versions. POST /admin/docs/{name} with {"content": "..."} saves a new version (unchanged content is not duplicated; the last 100 versions are kept); GET /admin/docs/{name}/versions/{id} returns one version.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/docs/roadmap"
200 OK — {"content":"...","versions":[...]}401 Unauthorized
GET/admin/reportConsolidated ETL teaching report (JSON or Markdown)Bearer Token

Query parameters: days (0–3650, default 30), format (json | md). Consolidates telemetry, daily activity, devices, Matomo, NLP, feedback, survey, Core Web Vitals, and Green Software (SWDM).

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/report?days=30&format=md"
200 OK — JSON or text/markdown401 Unauthorized
POST/admin/report/interpretAI-assisted pedagogical interpretation of the ETL reportBearer Token

Query parameters: days (0–3650), lang (en | es), detail (brief | detailed). Protected with OWASP LLM guardrails (PII redaction, indirect prompt-injection sanitization, dedicated rate limit).

curl -X POST -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/report/interpret?days=30&lang=en&detail=detailed"
200 OK — {"analysis":"...","model":"..."}401 Unauthorized429 Too Many Requests502/503 Upstream/Config error
GET/admin/metricsPrometheus text exposition metrics (0.0.4)Bearer Token

Live process uptime, HTTP request count, SQLite DB size, all-time telemetry/feedback totals, and rolling 30-day Web Vitals p95.

curl -H "Authorization: Bearer <ADMIN_TOKEN>" "https://api.learnalgorithms.dev/admin/metrics"
200 OK — text/plain; version=0.0.4401 Unauthorized