Deriver API

HTTP/JSON reference — Introduction, Ontology, Inference, Deriver helpers.

info deriver.app HTTP API

Overview

deriver.app exposes small, purpose-built HTTP endpoints for the ontology UI and for rule inference. Server logic is implemented in PHP; structured responses use JSON (Content-Type: application/json; charset=utf-8). The Deriver and triple-list pages use JavaScript (fetch) to call these endpoints in the browser. Authentication follows the same session rules as the main app (signed-in admin vs. public knowledge bases where applicable).

info Languages & data formats

Languages & data formats

  • PHP — request handlers in triple-list.php, rule-evaluate.php, deriver.php.
  • JSON — request bodies (POST with php://input) and JSON responses for APIs below.
  • JavaScript — client-side calls from js/deriver-session.js, js/rule-network-viz.js, and inline scripts in the triple editor (e.g. predicate lookup modal).
  • HTML forms — triple and rule editors still use classic form posts for saves; those are not listed here as separate JSON APIs.
get triple-list.php

Flag preview

All ontology JSON helpers are on triple-list.php. Pass the active knowledge base with kb=<slug> (and session as required). Responses are JSON.

Resolves a flag image URL for language/locale cell l (editor preview).

Parameters (query)

  • kb — knowledge base slug (required).
  • triple_list_flag_preview=1
  • l — locale/language code (e.g. en).
GET triple-list.php?kb=my-kb&triple_list_flag_preview=1&l=en
// Example response
{"src":"…/flags/…svg"}
get triple-list.php

Enum lookup

Editor support for enumerated values (requires admin session and valid KB).

Parameters (query)

  • kb
  • triple_enum_lookup=1
  • attr
  • editor_l (optional)
GET triple-list.php?kb=my-kb&triple_enum_lookup=1&attr=…&editor_l=…
// Error / empty
{"ok":false,"message":"Nicht berechtigt"}
get triple-list.php

Predicate lookup

Returns predicate suggestions from the ontology for the triple editor (requires admin session).

GET triple-list.php?kb=my-kb&triple_p_lookup=1
// Shape (simplified)
{"ok":true,"values":[…]}
post rule-evaluate.php

rule-evaluate.php (primary JSON API)

Method: POST only. Body: JSON. Evaluates a rule’s if_condition and processes then_action / else_action branches, returns prompts (ask, value), missing variables, or sync_all_if / admin actions.

POST rule-evaluate.php
Content-Type: application/json

{
  "kb": "my-kb",
  "rule_id": 42,
  "variables": { "pages": "12", "SomeRule": "TRUE" },
  "ui_lang": "en"
}
// Alternative: select by name
{ "kb": "my-kb", "rule_name": "My rule", "variables": {} }
post rule-evaluate.php

sync_all_if

Jacobi-style IF sync over all rules in the KB (client sends current variables):

{ "kb": "my-kb", "action": "sync_all_if", "variables": { … } }
post rule-evaluate.php

recompute_use_counts

Admin-only maintenance (recompute IF use counts):

{ "kb": "my-kb", "action": "recompute_use_counts" }
info then_action / else_action

then_action / else_action — supported constructs

Action text is line-oriented (separated by newlines or ;). The engine recognises the following. Anything else on a line is currently ignored by the line processor (there is no send_mail() or similar in the codebase today).

  • set(varName, value) — assigns a variable. value may be a quoted string with $otherVar$ placeholders, a variable name, a number, or a numeric expression using variable names (e.g. counter+1).
  • age(argument)argument is a date string (Y-m-d) or a variable holding such a date. Sets age_valid (TRUE/FALSE), age_years, age_months, age_days.
  • http_status(url) — resolves url (literal or variable), performs an HTTP HEAD request, sets http_status (numeric code or empty), http_status_type, and http_status_description.
  • ask(…) — handled by the evaluator (interactive prompts, optional scale / assign variable). Not executed as a simple assignment line.
  • value("…") — first value("…") in the chosen branch supplies free-text capture (ask_value flow in JSON).
set(score, counter+1);
age($birthdate$);
http_status("https://example.com/api/health");
get deriver.php

search_rules

These use query parameters on deriver.php (same KB context as the Deriver page).

Search rules (GET, JSON):

GET deriver.php?kb=my-kb&action=search_rules&q=invoice
// { "ok": true, "rules": [ { "id": "1", "name": "…" }, … ] }
post deriver.php

deriver_save_session

Save Deriver session (POST, JSON body, admin):

POST deriver.php?kb=my-kb&action=deriver_save_session
{ "session_json": "{…}" }
get deriver.php

deriver_load_last_session

Load last saved session (GET, admin):

GET deriver.php?kb=my-kb&action=deriver_load_last_session
// { "ok": true, "session_json": "…" } or null