HTTP API
The server behind the playground is also a small JSON API. Use it from any language that has no SDK, or to check results from a script.
Start it as in Running the playground. Every endpoint takes and returns JSON unless noted, accepts bodies up to 10 MB, and shares the per-client limit: a burst of 40 calls, then 10 a second. Over the limit you get 429 with Retry-After.
Encode and decode
curl -s localhost:8090/api/encode -d '{"data":[{"id":1,"city":"Paris"},{"id":2,"city":"Oslo"}],"mode":"compact"}'{"mode": "compact", "text": "@id,city\n1,Paris\n2,Oslo",
"tokensCl100k": 13, "tokensO200k": 13, "bytes": 23, "gzipBytes": 43,
"jsonTokensCl100k": 20, "jsonTokensO200k": 20, "jsonBytes": 48, "jsonGzipBytes": 56}On payloads this small, gzip adds more than it saves; the gzip figures matter from a few kilobytes up.
| Endpoint | Body | Returns |
|---|---|---|
POST /api/encode | {"data": …, "mode": "compact" | "readable" | "typed"} | The text, its tokens in cl100k and o200k, bytes and gzip bytes, and the same figures for JSON |
POST /api/compact | Raw JSON; add ?mode=typed for a typed document | The JDogo text and its size |
POST /api/decode | Raw JDogo text | The JSON value |
POST /api/columnar | Raw JSON table | rowCount, columnCount, columns (one list per column), types and the JDogo text |
Compare formats
| Endpoint | Body | Returns |
|---|---|---|
POST /api/compare | {"data": …, "title": "…"}, or {"caseId": "…"} for a benchmark case | Tokens, bytes, gzip size, round-trip check and timings for JSON, YAML, TOON and each JDogo form |
GET /api/compare/cases | The benchmark cases you can pass as caseId | |
POST /api/profile | Raw JSON | Token and cost figures for the payload |
At most seven comparisons run or wait at once; beyond that you get 503 with Retry-After. Timings on a public server are short runs; full timing runs need dev mode.
Count tokens
| Endpoint | Body | Returns |
|---|---|---|
POST /api/tokens | Raw text | Tokens in cl100k and o200k |
POST /api/tokens/batch | {"texts": ["…", …], "encoding": "cl100k" | "o200k"}, up to 2,000 texts | {"tokens": [n, …]} in the same order |
POST /api/tokens/spans | {"text": "…", "encoding": "cl100k"} | The text split into its tokens, for highlighting |
Prompts, compute and grammars
| Endpoint | Body | Returns |
|---|---|---|
POST /api/studio/prompt | {"question": "…", "data": …} | The prompt JDogo would send to a model, and its tokens |
POST /api/compute/schemacard | {"data": …} | The schema card, its tokens and the routing instruction |
POST /api/compute/eval | {"expression": "count where status = late", "data": …} | {"ok": true, "result": …} |
POST /api/compute/ask | {"question", "data", "mockResponse", "allowGroupBy"} | What ask() does with a model reply you supply: the route, the expression and the answer. No model is called |
POST /api/gbnf | Raw JSON sample | A GBNF grammar (kind is table or generic), the sample as JDogo, and its tokens |
POST /api/diff | {"base": {…}, "target": {…}} | {"delta": "…"}, the change as a context delta |
Compute errors come back as 200 with {"ok": false, "error": "…"}, so a bad expression is data, not a failed call. The expression language is in Compute expressions.
Health and evidence
| Endpoint | Returns |
|---|---|
GET /api/health | {"status":"UP"}; not rate limited, for load balancers and probes |
GET /api/studio/live | The recorded evidence behind the site's figures |
POST /api/test/suite | Runs the conformance suite on the server and reports the results |
Dev mode only
With -Djdogo.dev=true, on a trusted machine: POST /api/llm/compare (calls a model provider with a key you pass), /api/stress/million (a million-row timing run) and POST /api/studio/live (refreshes the evidence). A public server answers these with 403.
Errors
| Status | Means |
|---|---|
400 | Invalid JSON or JDogo, or a missing field; {"error": "…"} says which |
405 | Wrong method |
413 | Body over 10 MB |
429, 503 | Too many calls, or the server is busy; retry after Retry-After seconds |