Preview
Sign inSign up
ConceptsResponses

Concepts

Responses

A program that ran always gets 200. What happened is in the body: an outcome, a result per form, the output and the stats.

Status

HTTP status codes describe the request, not the program. A 4xx or 5xx means the request was turned away before or instead of running (see Errors). Otherwise the outcome is in status:

statusMeaning
okEvery form ran.
errorA form raised an error: a wrong type, an unbound variable, a call to error, and so on.
timeoutThe program ran past its wall-clock timeout and was stopped.
limit_exceededThe program hit a step, memory, integer size or complexity limit, or the source was too large.

Results

Each top-level form that finished gets a result, in source order, with its 0-based index and the line and col where it starts. When a program fails partway, the forms before the failure still have results, and error says which form failed:

200 OK · a failed program
{
  "status": "error",
  "results": [
    {"index": 0, "line": 1, "col": 1, "value": null, "json": null},
    {"index": 1, "line": 3, "col": 1, "value": "1", "json": 1}
  ],
  "stdout": "",
  "stats": {"wall_ms": 0.3, "cpu_ms": 0.01, "steps": 14, "memory_bytes": 9800},
  "error": {
    "type": "wrong_type",
    "message": "car: expected a pair, got ()",
    "index": 2, "line": 4, "col": 1
  },
  "request_id": "req_..."
}

Values and JSON

value is the printed (write) form, exact for every type, or null when the value is unspecified, as with define. json is a typed copy you can use directly, but it can lose information:

Scheme valuejsonNotes
Integers and floatsnumbersJS clients lose precision past 2^53. Use value for exact bignums.
Strings and symbolsstringsA symbol and a string with the same text look the same.
#t and #fbooleans—
'() and proper listsarraysNested lists become nested arrays.
Improper lists, procedures, unspecifiednullRead value instead.

Printed values longer than the per-result limit are cut short, and value_truncated is true.

Output

stdout holds everything written with display, write and newline. Past the output limit the rest is dropped and stdout_truncated is true. Output from forms before a failure is kept.

Stats

cpu_ms is the CPU time your program used, and it's what you're billed for, as max(1, ceil(cpu_ms)) milliseconds. wall_ms is the elapsed time. steps and memory_bytes are null when the process was killed, for example on a timeout.

All fields

EvalResponse

FieldDescription
status
string · required
One of ok, error, timeout, limit_exceeded.
results
Result[] · required
The forms that finished, in order.
stdout
string · required
—
stdout_truncated
boolean · required
—
stats
Stats · required
—
error
EvalError | null · required
—
request_id
string · required
—

Result

FieldDescription
index
integer · required
0-based position of the form in the source.
line
integer · required
—
col
integer · required
—
value
string | null · required
Printed (write) form, exact for every type. null when the value is unspecified.
value_truncated
boolean · required
—
json
any | null · required
Typed copy of the value: numbers, strings (strings and symbols), booleans, arrays (proper lists). null for improper lists, procedures and unspecified values. JS clients lose precision past 2^53; use value for exact bignums.

Stats

FieldDescription
wall_ms
number · required
—
cpu_ms
number · required
CPU time used; what's billed, as max(1, ceil(cpu_ms)).
steps
integer | null · required
null when the process was killed.
memory_bytes
integer | null · required
null when the process was killed.

EvalError

FieldDescription
type
string · required
Stable identifier to match on. One of syntax_error, unbound_variable, wrong_type, arity_mismatch, not_a_procedure, division_by_zero, arithmetic_error, user_error, timeout, step_limit, memory_limit, integer_too_large, too_complex, source_too_large, internal_error.
message
string · required
—
index
integer | null · required
The form that failed.
line
integer | null · required
—
col
integer | null · required
—
esc