跳到主要内容
开发者文档开始使用

快速入门

创建密钥,发送一个请求,读取装载方案。

创建 API 密钥

在开发者控制台中打开 API 密钥 并创建一个密钥。密钥仅显示一次。

Bash
export CARGODUO_API_KEY="cd_live_..."

创建任务

如果任务在 60 s 内结束,?wait=60 会直接返回已完成的任务。

curl -X POST "https://runner.cargoduo.com/v1/pack?wait=60" \
  -H "Authorization: Bearer $CARGODUO_API_KEY" \
  -H "Idempotency-Key: order-1042-v1" \
  -H "Content-Type: application/json" \
  -d '{
    "reference": "order-1042",
    "vehicles": [
      {
        "id": "trailer",
        "type": "trailer",
        "name": "13.6 m trailer",
        "length": 1360,
        "width": 245,
        "height": 270,
        "max_weight": 24000
      }
    ],
    "items": [
      {
        "id": "pallet-eu",
        "label": "Euro pallet",
        "length": 120,
        "width": 80,
        "height": 140,
        "weight": 450,
        "quantity": 18,
        "stackable": false
      },
      {
        "id": "carton-a",
        "label": "Carton A",
        "length": 60,
        "width": 40,
        "height": 40,
        "weight": 12,
        "quantity": 40,
        "rotation": "upright"
      }
    ],
    "options": {
      "packing_mode": "auto"
    }
  }'

按时完成:返回 200、status: "succeeded",方案位于 result 中。仍在运行:返回 202,请转到第 3 步。

轮询直到任务结束

curl "https://runner.cargoduo.com/v1/jobs/$JOB_ID?include=result" \
  -H "Authorization: Bearer $CARGODUO_API_KEY"

读取方案

字段内容
result.vehicles[].placements[]每件物品的位置、尺寸、朝向和装载 step
result.unplaced[]未能装下的物品及其 reason
cost.credits该任务的扣费
pdf_url用于生成装载方案 PDF 的链接

POST /v1/estimate 可免费校验同一请求体并估价。

相关内容