API reference
The functions you'll use, by task, in all three languages.
Encode and decode
| Task | Python | TypeScript | Java |
|---|---|---|---|
| Encode, compact | dumps(v) | stringify(v) | DocCodec.encode(v) |
| Encode, readable | encode_readable(v) | encodeReadable(v) | DocCodec.encodeLegibleKeys(v) |
| Encode, typed | dumps(v, mode="typed") | stringify(v, "typed") | FormatMode.TYPED |
| Decode anything | loads(s) | parse(s) | mapper.decode(s, Object.class), DocCodec.decode(s) |
| Files | dump(v, fp), load(fp) | encode(v, out), decode(in) | |
| Columns | to_columnar_dict(s) | toColumnar(s) | JDogoColumnarReader.read(s) |
| DataFrame | to_pandas(s) |
dumps and stringify modes: "compact" (default), "readable", "typed", "v1". loads and parse take format="auto", "doc" or "v1".
Streaming
| Task | Python | TypeScript | Java |
|---|---|---|---|
| Write rows | JDogoStreamWriter | DocStreamWriter | JDogoStreamWriter |
| Read rows | JDogoStreamReader | DocStreamReader, iterDocDecode | JDogoStreamReader |
AI
| Task | Python | TypeScript | Java |
|---|---|---|---|
| Prompt for a question | format_query_prompt(q, data) | formatQueryPrompt(q, data) | JDogoAI.formatQueryPrompt(q, data) |
| Data only, prompt layout | encode_legible_keys(data) | encodeLegibleKeys(data) | DocCodec.encodeLegibleKeys(data) |
| Route and answer | ask(q, data, llm) | ask(q, data, llm) | JDogoAI.ask(q, data, llm) |
| Evaluate a query | run_compute(expr, data) | runCompute(expr, data) | JDogoAI.runCompute(expr, data) |
| Name the rows used | run_compute(expr, data, with_refs=True) | runCompute(expr, data, { withRefs: true }) | JDogoCompute.runCompute(expr, data, true) |
| Check an answer independently | verify_result(expr, data, value) | verifyResult(expr, data, value) | JDogoCompute.verifyResult(expr, data, value) |
| Send JDogo or JSON, whichever is cheaper, with a receipt | optimize(data) | optimize(data) | JDogoOptimizer.create().optimize(data).receipt() |
| Schema card | dataframe_to_schema_card(df), CLI jdogo schemacard | generateSchemaCard(data) | JDogoCompute.generateSchemaCard(data) |
| Tool output | @jdogo_tool | createJDogoTool(opts) | McpToolOptimizer |
| Run OpenAI tool calls | providers.run_openai_tool_calls(msg, tools) | providers.runOpenAIToolCalls(msg, tools) | |
| Run Anthropic tool uses | providers.run_anthropic_tool_uses(content, tools) | providers.runAnthropicToolUses(content, tools) |
Context sync
Same text in all three languages; see Context sync.
| Task | Python (jdogo.context) | TypeScript (context) | Java |
|---|---|---|---|
| Snapshot | create_snapshot(tenant, id, state) | createSnapshot(tenant, id, state) | engine.createSnapshot(tenant, id, state) |
| What changed | diff(snapshot, new_state) | diff(snapshot, newState) | engine.diff(snapshot, newState) |
| Apply a delta | apply(snapshot, delta) | apply(snapshot, delta) | engine.apply(snapshot, delta) |
| To and from text | to_wire(), ContextSnapshot.from_wire(t) | snapshotToWire(s), snapshotFromWire(t) | toWireFormat(), fromWireFormat(t) |
| Sign and verify | encode_envelope(item, issuer, key), verify_signature(env, key) | encodeEnvelope(item, issuer, key), verifySignature(env, key) | ContextEnvelopeCodec.encodeHmac, verifySignature |
| Server-sent event | sse_event(item) | sseEvent(item) | SseEventFormatter.format(event) |
ask() options
| Option | Default | Effect |
|---|---|---|
fallback_enabled / fallbackEnabled | true | Send the rows when the model can't answer with a query |
allow_group_by / allowGroupBy | false | Accept group-by, ranking, percent, ratio and median queries |
grounded | false | Ask the model to cite row ids in row answers |
The result has answer, route ("compute" or "rows"), expression, tokens, fallback_used, fallback_reason and raw_reply (camelCase in TypeScript).
Errors
Decoders raise the language's normal parse error on bad input: ValueError in Python, Error in TypeScript, IllegalArgumentException in Java (the mapper wraps it in JDogoDeserializationException). The default readers fall back to the 1.x reader only for text that carries 1.x markers, so malformed input is always an error, never made-up values. Encoders refuse values nested deeper than 64 levels with the same error, so they never write text a decoder would reject.