Dokumentacja dla deweloperówPierwsze kroki
Szybki start
Utwórz klucz, wyślij jedno zapytanie, odczytaj plan.
Utwórz klucz API
W konsoli deweloperskiej otwórz Klucze API i utwórz klucz. Sekret zobaczysz tylko raz.
export CARGODUO_API_KEY="cd_live_..."Utwórz zadanie
Z ?wait=60 odpowiedź zawiera gotowe zadanie, jeśli zakończy się ono w ciągu 60 s.
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())Zakończone na czas: 200, status: "succeeded", plan w result. Wciąż w toku: 202, przejdź do kroku 3.
Odpytuj aż do zakończenia
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 jobOdczytaj plan
| Pole | Zawartość |
|---|---|
result.vehicles[].placements[] | Położenie, wymiary, orientacja i step załadunku każdej pozycji |
result.unplaced[] | Pozycje, które się nie zmieściły, z reason |
cost.credits | Ile pobrano za zadanie |
pdf_url | Link, który tworzy PDF z planem załadunku |
POST /v1/estimate bezpłatnie waliduje i wycenia tę samą treść.