API reference

AILI public API

JSON access to the Alberta K-12 curriculum as indexed by AILI (AI Learning Interface): subjects, curricula, trees, nodes, resources, hybrid search and cited answers. Every response is an object with `data` and optional `meta`, or `error` with `code` and `message`. Open access, rate limited per IP; send an `X-API-Key` header to raise the limit. Version 1.0.0. Machine readable: YAML · JSON.

GET/api/v1/subjectscurriculum

List subject areas with curriculum, course and outcome counts.

ParameterInTypeDescription
include_archivedquerybooleanInclude curricula withdrawn upstream and kept for reference (fetch_status archived-p2). Hidden by default; archived rows carry archived: true and archived_reason.

Responses: 200 Subject list.

GET/api/v1/subjects/{code}curriculum

One subject area with its child subjects, curricula and courses.

ParameterInTypeDescription
code requiredpathstringSubject area code, for example MAT.

Responses: 200 Subject detail. · 404 Unknown subject.

GET/api/v1/curriculacurriculum

List curricula, optionally filtered by subject or framework.

ParameterInTypeDescription
subjectquerystringSubject area code.
frameworkquerystring (GFC | POS | LDC | EXT)Curriculum framework.
include_archivedquerybooleanInclude curricula withdrawn upstream and kept for reference (fetch_status archived-p2). Hidden by default; archived rows carry archived: true and archived_reason.

Responses: 200 Curriculum list.

GET/api/v1/curricula/{code}curriculum

One curriculum with its courses and grades.

ParameterInTypeDescription
code requiredpathstring

Responses: 200 Curriculum detail. · 404 Unknown curriculum.

GET/api/v1/curricula/{code}/treecurriculum

Flat node rows for the explorer, each with parent_id and children_count. Pruned to level_index <= 5 by default so the tree loads in one request; pass depth=all for every knowledge, understanding and skills leaf. Clients build Map<parent_id, children[]> and treat rows whose parent is missing as roots.

ParameterInTypeDescription
code requiredpathstring
depthquerystringMaximum level_index (1 to 12) or `all`. Default 5.
coursequerystringRestrict to one course code.

Responses: 200 Tree rows. · 404 Unknown curriculum.

GET/api/v1/coursescurriculum

List courses (catalogue records plus uncatalogued K to 6 course nodes), ordered by id and cursor paged.

ParameterInTypeDescription
subjectquerystring
gradequerystringGrade code, for example 5 or K.
frameworkquerystring
curriculumquerystring
limitqueryinteger
cursorquerystringLast id of the previous page; meta carries total and next_cursor.
include_archivedquerybooleanInclude curricula withdrawn upstream and kept for reference (fetch_status archived-p2). Hidden by default; archived rows carry archived: true and archived_reason.

Responses: 200 Course list with meta {count, total, limit, next_cursor}.

GET/api/v1/gradescurriculum

List grade codes.

Responses: 200 Grade list.

GET/api/v1/nodes/{id}nodes

One curriculum node with its ancestors and AI enrichment.

ParameterInTypeDescription
id requiredpathstringNumeric id, or `curriculum_code|path`.

Responses: 200 Node detail. · 404 Unknown node.

GET/api/v1/nodes/{id}/childrennodes

Direct children of a node (used to load K/U/SP leaves on demand).

ParameterInTypeDescription
id requiredpathstring

Responses: 200 Child rows.

GET/api/v1/nodes/{id}/ancestorsnodes

Ancestors from the curriculum root down to the parent.

ParameterInTypeDescription
id requiredpathstring

Responses: 200 Ancestor rows.

GET/api/v1/nodes/{id}/resourcesnodes

Resources linked to a node.

ParameterInTypeDescription
id requiredpathstring

Responses: 200 Resource rows.

GET/api/v1/code/{code}nodes

Exact lookup by curriculum, course or outcome code (for example MAT5-OI2-GQ1-LO1).

ParameterInTypeDescription
code requiredpathstring
include_archivedquerybooleanInclude curricula withdrawn upstream and kept for reference (fetch_status archived-p2). Hidden by default; archived rows carry archived: true and archived_reason.

Responses: 200 Matching nodes, curriculum and course. · 404 Nothing carries that code.

POST/api/v1/asksearch

Cited answer as one JSON document (not streamed).

Body application/json: ["question","lang","filters"]

Responses: 200 Answer with sources, verification and trace id. · 400 Missing question. · 503 Answer pipeline not available.

POST/api/v1/findsearch

Staged selection without generation. Reads intent, resolves curriculum sets and proposes a selection (stages 0 to 2 of docs/SELECTION-PIPELINE.md). Cheap (about $0.002) and cached ten minutes by normalized query and filters. Returns 503 while the selection module is unavailable. `filters` can override parts of the intent (grades, subjects, audience, scope, deliverable).

Body application/json: ["q","filters","language","deliverable"]

Responses: 200 Intent, sets and proposed selection. · 400 q missing. · 503 Selection module not available yet.

GET/api/v1/courses/{code}/outcomescurriculum

Whole-course dataset in curriculum order, as JSON or an indented outline.

ParameterInTypeDescription
code requiredpathstringCourse code, for example MAT3 or ELA9.
depthquerystring (lo | kusp)lo stops at learning outcomes; kusp includes knowledge, understanding, skills and procedures.
formatquerystring (json | outline)
downloadquerystring (1)Send as an attachment (Content-Disposition).

Responses: 200 Course dataset. JSON carries `data.set`, `data.nodes` (flat, with parent_id) and `data.tree` (nested); outline is text/markdown. · 404 Unknown course.

GET/api/v1/resources/{id}library

One resource with linked outcomes and stored assets.

ParameterInTypeDescription
id requiredpathstring

Responses: 200 Resource detail. · 404 Unknown resource.

GET/api/v1/assets/{id}library

Raw bytes of a stored asset (PDF, image) with ETag; add ?meta=1 for metadata only.

ParameterInTypeDescription
id requiredpathinteger
metaquerystring (1)Return metadata JSON instead of bytes.

Responses: 200 Bytes or metadata. · 304 Not modified. · 404 Asset not stored.

GET/api/v1/assets/{id}/pages/{n}library

Extracted text of one PDF page.

ParameterInTypeDescription
id requiredpathinteger
n requiredpathinteger

Responses: 200 Page text. · 404 Page not extracted.

GET/api/v1/statusplatform

Corpus counts, last harvest and index run, job queue, embedding coverage, loaded modules.

Responses: 200 Status.

GET/api/v1/registerplatform

Data register. What the API holds, computed live from the database and cached ten minutes.

Responses: 200 Register.

GET/api/v1/costs/summaryplatform

Platform AI cost by day, purpose, model and artifact kind.

ParameterInTypeDescription
daysqueryinteger

Responses: 200 Cost summary.

GET/api/v1/costs/mineplatform

Cost attributed to the calling session or account.

ParameterInTypeDescription
daysqueryinteger

Responses: 200 Personal usage.

GET/api/askstreaming

Server-sent events. Emits stage, sources, chunk, verification, done and error events.

ParameterInTypeDescription
q requiredquerystring
langquerystring (en | fr)
curriculumquerystring
coursequerystring
gradequerystring

Responses: 200 text/event-stream.

POST/api/askstreaming

Same pipeline as GET, returned as one JSON object (answer, sources, verification, traceId, costUsd).

Responses: 200 Answer JSON.

GET/api/ask/trace/{id}streaming

Stored trace for one answer (plan, angles, candidates, selected passages, verification, usage).

ParameterInTypeDescription
id requiredpathstring

Responses: 200 Trace. · 404 Unknown trace.

GET/api/generate/toolsstreaming

Generation tools with parameter descriptions, default tier and image support.

Responses: 200 Tool list.

POST/api/generate/startstreaming

Server-sent events. Emits stage, rag, chunk, image, validation, done and error while an artifact is generated.

Body application/json: ["kind","tier","params","nodeIds","question","language","persona"]

Responses: 200 text/event-stream.

GET/api/generate/{id}streaming

One generated artifact (markdown body, sources, assets, validation).

ParameterInTypeDescription
id requiredpathstring

Responses: 200 Artifact. · 404 Unknown artifact.

GET/api/v1/exportexport

The exportable tables with their key, since column, filters and page size.

Responses: 200 List of exports.

GET/api/v1/export/{table}export

One page of a table. Page with cursor (the last row key) until next_cursor is null. Totals ignore the cursor; total_estimated is set when the count came from the planner.

ParameterInTypeDescription
table requiredpathstring (curricula | catalogue_courses | subject_areas | grades | collections | nodes | enrichment | resources | node_resource_refs | assets | asset_refs | pdf_documents | pdf_pages | chunks | audit_results | change_log | pipeline_runs)
limitqueryintegerUp to 1000; 200 when with_embeddings=1.
cursorquerystringThe next_cursor value from the previous page: the last key for single-key tables, an encoded key tuple for pdf_pages, node_resource_refs and asset_refs.
sincequerystringOnly rows changed after this time (updated_at; last_seen_at for curricula, created_at for enrichment).
curriculumquerystringnodes, chunks: curriculum code.
coursequerystringnodes, chunks: course code.
node_typequerystringnodes.
frameworkquerystringcurricula: GFC | POS | LDC | EXT.
publishedquerybooleancurricula: content_published.
languagequerystringchunks: en | fr.
source_kindquerystringchunks.
fetch_statusquerystringassets: downloaded | gated | external_large | external_link | external_unavailable.
with_embeddingsquerybooleanchunks: include the embedding vector as an array of numbers (limit capped at 200).

Responses: 200 One page. · 404 Unknown table. · 429 Rate limited.

Schemas

Intent

Stage 0 reading of the request.

FieldTypeDescription
audiencestring, nullableparent | teacher | student | developer | unknown
gradesarray
subjectsarray
coursesarray
topicsarray
scopestringwhole-course | topic | outcome | question
deliverablestringoverview | lesson | quiz | homework | presentation | answer | unknown
languagestring

CurriculumSet

One resolved course (stage 1).

FieldTypeDescription
course_codestring, nullable
curriculum_codestring, nullable
gradestring, nullable
namestring, nullable
frameworkstring, nullable
countsobject
root_node_idinteger, nullable
tree_urlstring, nullable
emptybooleanTrue when the subject has no course for the grade.
reasonstring, nullable

Selection

Stage 2 proposal as returned by find(). Nodes live in `selected`, grouped by `set_index`; `budget` is the token limit for the deliverable.

FieldTypeDescription
scopestring, nullable
deliverablestring, nullable
modestring, nullablefull | fragment | outcome | question
omitted_countinteger, nullable
tokensinteger, nullable
budgetinteger, nullableToken budget for the deliverable.
merged_from_setsinteger, nullable
by_setarray, nullable
selectedarray, nullable
resourcesarray, nullable
usageobject, nullable

FindResult

FieldTypeDescription
intentIntent
setsarray
selectionSelection

Register

Counts of what is available through the API.

FieldTypeDescription
computed_atstring
curriculaobject
coursesobject
elementsobject
resourcesobject
documentsobject
chunksobject
enrichmentobject
last_harvestobject, nullable
last_auditobject, nullable
content_licenceobject

OutlineNode

FieldTypeDescription
idinteger
parent_idinteger, nullable
node_codestring
node_typestring
level_indexinteger
labelstring, nullable
textstring, nullable
urlstring
childrenarrayPresent in `tree` only.

TreeNode

One row of a curriculum tree.

FieldTypeDescription
idinteger
parent_idinteger, nullableNull for roots or when the parent was pruned.
node_codestring
node_typestringCOURSE, OI, GQ, LO, KUSP, K, U, SP, TOPIC, GENERAL_OUTCOME, SPECIFIC_OUTCOME, OVERVIEW and others.
level_indexintegerPortable depth, 1 course to 7 K/U/SP leaf.
labelstring, nullableTitle (English, French fallback).
headingstring, nullableFirst 160 characters of the content.
breadcrumbstringAncestor labels joined by a right-pointing chevron.
grade_codesarray, nullable
course_codestring, nullable
children_countinteger
has_contentboolean

Node

A curriculum element with bilingual text.

FieldTypeDescription
idinteger
curriculum_codestring
frameworkstring
node_codestring
node_typestring
level_indexinteger
pathstringAncestor codes joined by `>`.
course_codestring, nullable
grade_codesarray, nullable
title_enstring, nullable
title_frstring, nullable
content_enstring, nullable
content_frstring, nullable
content_en_mdstring, nullableNormalised markdown.
image_urlsarray, nullable
ancestorsarray
enrichmentobject, nullableAI summary, plain-language gloss, keywords, topics.
descendant_countinteger

SearchResult

FieldTypeDescription
chunk_idinteger, nullable
node_idinteger, nullable
asset_idinteger, nullable
page_numinteger, nullable
kindstringnode, pdf_page, resource or overview.
node_typestring, nullable
headingstring, nullable
breadcrumbstring, nullable
snippetstring, nullableMatching text with <mark> around hits.
scorenumber, nullable
urlstring, nullableIn-app link (/explore/node/:id or /library/pdf/:id?page=n).

Answer

FieldTypeDescription
answerstringMarkdown with [S#] citations.
sourcesarray
verificationarrayPer-claim supported, partial or unsupported verdicts.
traceIdstring, nullable
costUsdnumber, nullable

Status

FieldTypeDescription
countsobjectsubjects, curricula, courses, nodes, outcomes, assets, pdf_pages, chunks, chunks_embedded, embedding_coverage_pct and more.
last_harvestobject, nullable
last_indexobject, nullable
index_jobsarray
auditsarray
modulesobjectWhich optional modules are loaded.