Saltar al contenido principal
← Referencia de la API

Inicio rápido

De una clave a un primer plan de corte en pocos minutos: consigue una clave, envía una solicitud, lee la respuesta.

1. Consigue una clave

Inicia sesión y crea una clave de prueba gratuita en el panel: 1000 llamadas al mes, nunca facturadas. Las claves live van con un plan de la Engine API. Para echar un vistazo antes, los botones «Run this example» de las guías usan una clave de demostración pública, sin cuenta.

Gestionar claves de API →

2. Envía una solicitud

Envía por POST las piezas y los tableros a /v1/optimize/2d, con la clave en la cabecera Authorization. Este es el ejemplo documentado:

curl -s https://api.cutoptim.com/v1/optimize/2d \
  -H "Authorization: Bearer $CUTOPTIM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"parts":[{"name":"Door","w":600,"h":400,"qty":4,"rotatable":true}],"stock":[{"w":2440,"h":1220,"qty":10,"price":42}],"options":{"kerf":3,"trim":{"left":10,"top":10},"minimizeCost":true,"effort":"balanced"},"engine":"heuristic","include":["cutPlan","offcuts"]}'

O con un SDK

La misma solicitud con un cliente oficial para TypeScript, Python o PHP: añade reintentos seguros y un error tipado. La instalación y todo lo demás están en la guía de SDK. Official SDKsEN

// npm install @cutoptim/engine
import { CutOptim } from '@cutoptim/engine';

const client = new CutOptim({ apiKey: process.env.CUTOPTIM_KEY });
const plan = await client.optimize2d({"parts":[{"name":"Door","w":600,"h":400,"qty":4,"rotatable":true}],"stock":[{"w":2440,"h":1220,"qty":10,"price":42}],"options":{"kerf":3,"trim":{"left":10,"top":10},"minimizeCost":true,"effort":"balanced"},"engine":"heuristic","include":["cutPlan","offcuts"]});
# pip install cutoptim
import os
from cutoptim import CutOptim

client = CutOptim(api_key=os.environ["CUTOPTIM_KEY"])
plan = client.optimize_2d({"parts":[{"name":"Door","w":600,"h":400,"qty":4,"rotatable":True}],"stock":[{"w":2440,"h":1220,"qty":10,"price":42}],"options":{"kerf":3,"trim":{"left":10,"top":10},"minimizeCost":True,"effort":"balanced"},"engine":"heuristic","include":["cutPlan","offcuts"]})
// composer require cutoptim/engine
use CutOptim\Engine\Client;

$client = new Client(getenv('CUTOPTIM_KEY'));
$plan = $client->optimize2d(json_decode('{"parts":[{"name":"Door","w":600,"h":400,"qty":4,"rotatable":true}],"stock":[{"w":2440,"h":1220,"qty":10,"price":42}],"options":{"kerf":3,"trim":{"left":10,"top":10},"minimizeCost":true,"effort":"balanced"},"engine":"heuristic","include":["cutPlan","offcuts"]}', true));

3. Lee la respuesta

sheets lista cada tablero con sus piezas colocadas (x, y, w, h, rotated) y sus retales; metrics da sheetCount y yieldPct; cutPlan es la secuencia de corte. Un trabajo que no cabe del todo sigue siendo un 200: revisa unplaced y warnings.

{
  "engine": "heuristic",
  "sheets": [
    {
      "w": 2440,
      "h": 1220,
      "price": 42,
      "parts": [
        {
          "name": "Door",
          "x": 10,
          "y": 10,
          "w": 600,
          "h": 400,
          "rotated": false
        },
        {
          "name": "Door",
          "x": 613,
          "y": 10,
          "w": 600,
          "h": 400,
          "rotated": false
        }
      ],
      "offcuts": [
        {
          "x": 2422,
          "y": 10,
          "w": 18,
          "h": 400
        }
      ]
    }
  ],
  "metrics": {
    "sheetCount": 1,
    "yieldPct": 32.25,
    "placed": 4,
    "total": 4,
    "cutLines": 5,
    "sawPasses": 5,
    "cutLength": 4030,
    "totalPrice": 42
  },
  "unplaced": [],
  "warnings": []
}

Siguiente

Comprueba una solicitud gratis con /v1/validate/2d antes de gastar una llamada, prueba 1D y madera, y mira todos los endpoints en la referencia interactiva.