Geliştirici dokümanlarıBaşlarken
Hızlı başlangıç
Bir anahtar oluşturun, bir istek gönderin, planı okuyun.
API anahtarı oluşturun
Geliştirici konsolunda API anahtarları bölümünü açın ve bir anahtar oluşturun. Gizli anahtar yalnızca bir kez gösterilir.
export CARGODUO_API_KEY="cd_live_..."Bir iş oluşturun
?wait=60 ile iş 60 saniye içinde biterse yanıtta tamamlanmış iş döner.
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())Zamanında biterse: 200, status: "succeeded" ve plan result içinde. Hâlâ çalışıyorsa: 202; 3. adıma geçin.
İş bitene kadar sorgulayın
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ı okuyun
| Alan | İçerik |
|---|---|
result.vehicles[].placements[] | Her öğenin konumu, boyutu, yönelimi ve yükleme adımı (step) |
result.unplaced[] | Sığmayan öğeler ve nedenleri (reason) |
cost.credits | İş için düşülen kredi |
pdf_url | Yükleme planının PDF'ini oluşturan bağlantı |
POST /v1/estimate aynı gövdeyi ücretsiz olarak doğrular ve fiyatlandırır.