Preview
Sign inSign up
Getting startedIntroduction

Getting started

Introduction

cons evaluates Scheme over HTTP. Send source to one endpoint and get back the value of every top-level form, stdout, CPU-time stats and structured errors.

Every request runs in a fresh sandbox with time, step and memory limits, and is billed by the CPU time it used. Each account gets 600 CPU-seconds a month for free. This page takes you from nothing to a first response.

1. Get a key

Create an account, then create a key on the API keys page. Keys start with cons_ and are shown once. Put yours in an environment variable:

shell
export CONS_KEY=cons_...

2. Send a program

POST /v1/eval takes a JSON body with the Scheme source and an optional timeout_ms. The source can hold any number of top-level forms.

shell
curl -sS https://api.cons.stneto.dev/v1/eval \
  -H "Authorization: Bearer $CONS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"source": "(define (sq x) (* x x))\n(map sq (list 1 2 3))"}'

3. Read the response

Each top-level form that finished gets a result, in order. value is the printed form and json is a typed copy you can use directly.

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"
}

HTTP status describes the request, not the program

A program that ran always comes back as 200, even when it failed. Check status for the outcome: ok, error, timeout or limit_exceeded.

Next steps

esc