EntwicklerdokumentationErste Schritte
Schnellstart
Schlüssel erstellen, eine Anfrage senden, den Plan lesen.
API-Schlüssel erstellen
Öffnen Sie in der Entwicklerkonsole API-Schlüssel und erstellen Sie einen Schlüssel. Der Schlüssel wird nur einmal angezeigt.
export CARGODUO_API_KEY="cd_live_..."Job erstellen
Mit ?wait=60 antwortet die API mit dem fertigen Job, sofern er innerhalb von 60 s abgeschlossen ist.
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"
}
}'const res = await fetch("https://runner.cargoduo.com/v1/pack?wait=60", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CARGODUO_API_KEY}`,
"Idempotency-Key": "order-1042-v1",
"Content-Type": "application/json",
},
body: JSON.stringify({
"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"
}
}),
});
const data = await res.json();
console.log(res.status, data);import os
import requests
response = requests.post(
"https://runner.cargoduo.com/v1/pack",
headers={"Authorization": f"Bearer {os.environ['CARGODUO_API_KEY']}", "Idempotency-Key": "order-1042-v1"},
params={
"wait": 60,
},
json={
"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",
},
},
)
print(response.status_code, response.json())Rechtzeitig fertig: 200, status: "succeeded", der Plan steht in result. Läuft noch: 202, weiter mit Schritt 3.
Abfragen, bis der Job endet
curl "https://runner.cargoduo.com/v1/jobs/$JOB_ID?include=result" \
-H "Authorization: Bearer $CARGODUO_API_KEY"async function waitForJob(job) {
while (job.status === "queued" || job.status === "running") {
await new Promise((r) => setTimeout(r, 2000));
const res = await fetch(`https://runner.cargoduo.com/v1/jobs/${job.id}?include=result`, {
headers: { Authorization: `Bearer ${process.env.CARGODUO_API_KEY}` },
});
job = await res.json();
}
return job;
}import os, time, requests
def wait_for_job(job):
headers = {"Authorization": f"Bearer {os.environ['CARGODUO_API_KEY']}"}
while job["status"] in ("queued", "running"):
time.sleep(2)
job = requests.get(f"https://runner.cargoduo.com/v1/jobs/{job['id']}", params={"include": "result"}, headers=headers).json()
return jobPlan auslesen
| Feld | Inhalt |
|---|---|
result.vehicles[].placements[] | Position, Größe, Ausrichtung und Ladeschritt (step) jedes Artikels |
result.unplaced[] | Artikel, die nicht gepasst haben, mit reason |
cost.credits | Was der Job gekostet hat |
pdf_url | Ein Link, der das PDF des Ladeplans erzeugt |
POST /v1/estimate validiert denselben Body kostenlos und nennt den Preis.