HTTP API & Pipeline Reference
中文 · Documentation Hub · Architecture · Back to README
The interactive local API reference generated by FastAPI includes complete request and response schemas when the API service is running.
Endpoint summary
| Workflow | Endpoints |
|---|---|
| Dataset and imports | GET/POST /api/datasets, GET /api/datasets/{id}; imports accept a list of {filename, content_base64} |
| Versions and downloads | GET /api/datasets/{id}/versions, /files?version={version_id}, /files/{file_id}/download |
| Execution | POST /api/tasks, GET /api/tasks, /api/tasks/{id}, /api/tasks/{id}/artifacts |
| Lineage | GET /api/lineage/graph?asset={id}&direction=upstream&depth=3, POST /api/lineage/events |
| Evidence | POST /api/evidence/query, GET /api/evidence/assets/{asset_id}?version_id={version_id}, POST /api/evidence/assertions/decide |
| Evidence subgraph | GET /api/lineage/graph?include_semantic=true&asset_id={id}&hops=2&max_nodes=100 |
| Catalog | GET /api/catalog/{collection}; collections: sources, tables, columns, metrics, dimensions, terms, owners; filters: limit, offset, search, parent_id, source_id |
| Table and metric | GET /api/catalog/tables/{asset_id}, GET /api/catalog/metrics/{id}, GET /api/catalog/metrics/{id}/history |
| Ask and replay | POST /api/ask, GET /api/ask/{id} |
| Catalog relationships | GET /api/catalog/neighbors?asset_id={id}, GET /api/catalog/impact?asset_id={id}&max_nodes=100 |
| Catalog subgraph | GET /api/lineage/graph?asset_id=retail_revenue&hops=2&max_nodes=30&include_catalog=true |
| Quality | GET /api/datasets/{id}/quality, PUT /api/datasets/{id}/quality/config |
| Governance | PUT /api/datasets/{id}/template, GET/PUT /metadata, GET /metadata/changes, GET /compliance |
| Agent conversations | POST/GET /api/agent/conversations, GET /api/agent/conversations/{id}, POST /api/agent/conversations/{id}/messages (SSE) |
| Agent resume | POST /api/agent/conversations/{id}/resume with {plan_id, idempotency_key} (SSE); GET /api/agent/conversations/{id}/audit exposes recovery audit |
| Controlled actions | POST /api/actions/{type}/prepare, POST /api/approvals/{plan_id}, POST /api/actions/{plan_id}/execute, GET /api/actions/runs |
| Ontology and metering | GET /api/ontology, POST /api/ontology/object-sets/evaluate, GET /api/harness/traces, GET /api/harness/costs?group_by=conversation |
| Reports and export | GET /api/datasets/{id}/report, GET /api/export?format=croissant&dataset_id={id} |
Task submission and pipelines
Task submission takes dataset_id, an idempotency_key, optional version_id, pipeline, shards and queue. Without version_id, tasks replay the imported snapshot. An explicit version consumes that immutable snapshot. A task's input list is frozen when submitted.
- Sharding: The default is one shard, so exact and approximate deduplication see the whole dataset. Explicit multi-shard execution suits independent transforms; deduplication stays local to each shard with no global reduction step.
- Queues: Queue names
cpu,io, andgpuare supported; the built-in operator set provides CPU/IO operators. - DAG validation: See the contract guide for the typed DAG JSON format and generated operator manifest. Each operator emits an event even for an empty routed batch. Invalid DAGs are rejected before entering the queue.
Evidence extraction and queries
Evidence extraction uses the run_pipeline action. Supply the preset returned by datakeel.pipeline.evidence.evidence_pipeline() as pipeline, with dataset_id and shards=1. The operator manifest lists the five evidence operators (evidence.image_phash, evidence.caption_mentions, evidence.annotation_labels, evidence.label_gap, and evidence.near_duplicate). Global near-duplicate extraction rejects multiple shards. Omitting pipeline retains the default pipeline.
Each extraction reports inputs, skipped_cached, extracted and failed, both overall and per operator. For the fresh default evidence corpus these are 5,000 inputs, 4,990 extracted and 10 image-decode failures; unchanged reruns hit cache on all 5,000 inputs and extract zero. The cache key includes actual input content, selector, extractor ID/version, schema version and both evidence-contract hashes. Changing only the caption extractor version re-extracts its 1,000 inputs, while other operators stay cached and old caption assertions are invalidated with an audit entry.
ObjectSet 1.1 query example
POST /api/evidence/query accepts a flat ObjectSet 1.1 payload plus cursor and page_size (default 50, maximum 200). Results sort by asset ID; pass next_cursor for the next page. Replace DATASET_ID with the paired dataset's ID from GET /api/datasets:
DATASET_ID="replace-with-paired-dataset-id"
curl --fail http://127.0.0.1:8765/api/evidence/query \
-H 'Content-Type: application/json' --data-binary @- <<EOF
{
"schema_version": "1.1",
"dataset_id": "${DATASET_ID}",
"split": "val",
"assertion_filters": [
{"predicate": "mentions", "concept": "person", "value": "present"},
{"predicate": "annotated_as", "concept": "person", "value": "present", "operator": "not_exists"}
],
"has_near_duplicate_in": "train",
"page_size": 20
}
EOF
not_exists means no matching annotation assertion, including unknown cases. To select confirmed gaps only, require label_gap/person=present. Legacy ObjectSet 1.0 manifests remain readable with their original serialization. Assertion filters are evaluated when preparing an action, and the resulting objects are frozen.
Semantic lineage and projection rebuild
The lineage endpoint supports include_semantic, asset_id, hops (1–3) and max_nodes (1–1,000); semantic neighbors use deterministic BFS ordered by asset type and ID. near_duplicate_of projects to the similar_to link type. Extraction events reference content-addressed knowledge bundles; assertion bodies stay outside the event table.
Rebuild the assertion/cache projection and replay review audits with:
uv run datakeel rebuild-evidence
The command reports before/after canonical hashes including PROJECTOR_VERSION, and exits nonzero if they differ. After manually clearing a disposable projection, pass its saved hash with --expected-hash to verify against the original state.
Semantic layer and metric definitions
The semantic layer separates 出货额 (ERP shipment prices, supply-chain owner), 销售额 (CRM booked invoices, finance owner), and 零售额 (completed orders at the paid price, retail owner). This abbreviated YAML illustrates the schema loaded when initializing an empty metric catalog:
metrics:
- id: retail_revenue
name: 零售额
english_name: Retail revenue
synonyms: [终端零售额, 实付零售额, 营业额]
description: Completed ecommerce orders at their paid amount, before later refunds.
owner: 零售运营负责人
version: 1
measure:
table: ecommerce/main/orders
column: ecommerce/main/orders/paid_amount
aggregation: sum
filters:
- column: ecommerce/main/orders/status
op: eq
value: completed
time:
column: ecommerce/main/orders/date
granularity: day
dimensions: [retail_region, retail_channel, retail_category]
caveats:
- Synthetic amounts in yuan; shipment, invoiced and retail amounts differ.
timeis required. Aggregations aresum,count,count_distinct,avg,min,max; filteropiseq,ne,in,gteorlte, with a list value only forin.- Dimensions bind a registered
columnand may list staticvaluesand optionalvalue_synonyms; terms usemeans: {kind: metric|dimension|column, id: ...}. Neithergrainnorvalues_sourceis accepted. - IDs use
source/schema/table[/column], withmainfor SQLite and percent-encoded separators/whitespace within segments. Missing references mark a metricunresolvedwith reasons and prevent query execution. - Owner display metadata is declared in
owners.yaml, keyed by the unchanged owner name. - Controlled metric updates use
update_metric/rollback_metric(andupdate_term/rollback_term). Changingretail_revenuefrompaid_amounttolist_amountchanges the demo Q4 question answer from4,979,475to5,255,975, recorded as a new version inGET /api/catalog/metrics/retail_revenue/history. - Catalog imports use
import_catalog/restore_catalog. Rebuild catalog projections and verify canonical hashes withuv run datakeel rebuild-catalog.
Quality, governance templates and exports
- Quality scoring: Returns five dimension objects with weights 25 (completeness), 20 (consistency), 15 (uniqueness), 25 (annotation) and 15 (distribution). Unannotated data excludes the annotation dimension by default and renormalizes the remaining weights. For example,
{"min_size_bytes":999999}lowers completeness and{"thresholds":{"excellent":99}}adjusts grade boundaries. Consistency groups by modality; distribution uses Shannon evenness. - Governance templates: Templates accept JSON Schema or a
fieldsmapping with required/enum/pattern constraints, and can be bound before completing metadata. Invalid saves are rejected atomically; accepted changes record before/after/source/reason and refresh 40/30/30 directory/naming/metadata compliance. Template references are local-only. - Standard exports:
export --format openlineageemits a JSON array where each array element is validated against the official RunEvent schema. Croissant 1.1 describes original source files and download URLs. SetDATAKEEL_BASE_URLfor CLI exports served from another address; HTTP exports derive the address from the request.
OpenTelemetry trace export
datakeel export-traces [--conversation-id ID] reads the existing trace store without migrating or writing it, then synchronously exports OTLP/HTTP protobuf spans carrying OpenTelemetry GenAI client-inference conventions (currently Development) and OpenInference attributes. Prompts, completions, tool payloads, transcripts, model-route JSON and exporter credentials are not exported; span timestamps are approximate values reconstructed from settlement time and latency.
Only HTTP 200 responses with rejected_spans=0 count as accepted, and there is no export cursor (repeating the command can create duplicate dashboard spans):
# Local OTLP collector
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4318/v1/traces \
uv run datakeel export-traces --conversation-id <id>
# Local Phoenix (OpenInference attributes are included)
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:6006/v1/traces \
uv run datakeel export-traces --conversation-id <id>
# Langfuse: generic base endpoint and credentials supplied outside the repository
export OTEL_EXPORTER_OTLP_ENDPOINT=https://cloud.langfuse.com/api/public/otel
export OTEL_EXPORTER_OTLP_HEADERS='Authorization=Basic <base64-public-key-secret-key>,x-langfuse-ingestion-version=4'
uv run datakeel export-traces --conversation-id <id>