Preview
Sign inSign up
API/v1/eval

API

Evaluate a program

POSThttps://api.cons.stneto.dev/v1/evalBearer key

Request

Needs an API key as a bearer token. See Authentication.

Body EvalRequest · application/json

FieldDescription
source
string · required
Scheme source. At most 64 KB on the API, 4 KB on the demo.
timeout_ms
integer · optional
Wall-clock limit. API default 1000, max 5000. The demo uses 500 and allows at most 500.

Responses

StatusMeaning
200The program ran. Check status for the outcome.
Headers: RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset
400The body isn't valid JSON (invalid_json).
401Missing, malformed, unknown or revoked key (unauthorized).
413Source over the limit (source_too_large) or body over 1 MB (request_too_large).
422Missing or non-string source, or bad timeout_ms (invalid_request).
429Per-key rate limit (rate_limited, 60/min), too many concurrent evals for the account (too_many_in_flight, 4), or the monthly CPU quota is used up (cpu_quota_exceeded).
Headers: Retry-After
503Every evaluation slot is taken (busy). Retry shortly.

Response body 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
—

Example

request
curl -sS https://api.cons.stneto.dev/v1/eval \
  -H "Authorization: Bearer $CONS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"source": "(+ 1 2)"}'
200 OK · application/json
{
  "status": "ok",
  "results": [
    {"index": 0, "line": 1, "col": 1, "value": null, "json": null},
    {"index": 1, "line": 2, "col": 1, "value": "(1 4 9)", "json": [1, 4, 9]}
  ],
  "stdout": "",
  "stats": {"wall_ms": 0.21, "cpu_ms": 0.02, "steps": 25},
  "error": null,
  "request_id": "req_8k2j4h5g6f7d8s9a0p1o"
}
esc