Skip to content

curl

Windows PowerShell note: replace $CNW_API_KEY with $env:CNW_API_KEY. If jq is not installed, write the response to a file and inspect it with PowerShell or python3 -m json.tool instead of piping to jq.

Minimal solve request

{
  "sheets": [
    {
      "width": 3210,
      "height": 2250,
      "quantity": 1,
      "kerfWidth": 4
    }
  ],
  "pieces": [
    {
      "originalIndex": 0,
      "width": 800,
      "height": 600,
      "quantity": 4,
      "canRotate": true
    },
    {
      "originalIndex": 1,
      "width": 1200,
      "height": 900,
      "quantity": 2,
      "canRotate": true
    }
  ],
  "params": {
    "kerfWidth": 4
  },
  "strategy": "greedy"
}
curl -X POST https://api.cutweaver.io/api/v1/solve \
  -H "Content-Type: application/json" \
  -d @quickstart_greedy_request.json | jq .

ALNS with SVG output

{
  "sheets": [
    {
      "width": 3210,
      "height": 2250,
      "quantity": 1,
      "kerfWidth": 4,
      "marginLeft": 10,
      "marginRight": 10,
      "marginTop": 10,
      "marginBottom": 10
    }
  ],
  "pieces": [
    {
      "originalIndex": 0,
      "width": 800,
      "height": 600,
      "quantity": 8,
      "canRotate": true
    },
    {
      "originalIndex": 1,
      "width": 1200,
      "height": 900,
      "quantity": 3,
      "canRotate": true
    }
  ],
  "params": {
    "kerfWidth": 4,
    "marginLeft": 10,
    "marginRight": 10,
    "marginTop": 10,
    "marginBottom": 10
  },
  "strategy": "alns",
  "alnsConfig": {
    "maxIterations": 40,
    "timeLimitMs": 50,
    "numThreads": 1,
    "seed": 42
  },
  "includeSvg": true
}
curl -X POST https://api.cutweaver.io/api/v1/solve \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $CNW_API_KEY" \
  -d @alns_svg_request.json \
  | tee response.json

jq -r '.svg[0]' response.json > sheet0.svg

If jq is not available in a minimal Linux / WSL environment, you can extract the first SVG with:

python3 - <<'PY'
import json
from pathlib import Path

data = json.loads(Path("response.json").read_text())
Path("sheet0.svg").write_text(data["svg"][0])
PY

Health check from a script

if ! curl -fsS https://api.cutweaver.io/health > /dev/null; then
  echo "CutWeaver API is down" >&2
  exit 1
fi