Entegrasyon rehberleri
DRAEVA / Public API
Python istemci rehberi
Aşağıdaki örnekler requests paketini kullanır. API anahtarı environment variable'dan okunur.
Aşağıdaki örnekler requests paketini kullanır. API anahtarı environment variable'dan okunur.
Ortak JSON çağrısı
import os
import requests
BASE_URL = "https://api.getdraeva.com"
KEY = os.environ["DRAEVA_API_KEY"]
response = requests.post(
f"{BASE_URL}/look/v1/targets",
headers={"Authorization": f"Bearer {KEY}"},
json={
"weather": {
"tempC": 10,
"windMs": 2,
"humidityPct": 60,
"condition": "clouds",
},
"met": 1.4,
},
timeout=30,
)
if not response.ok:
content_type = response.headers.get("Content-Type", "")
problem = response.json() if "application/problem+json" in content_type else {}
request_id = response.headers.get("X-Request-Id")
raise RuntimeError(
f"DRAEVA HTTP {response.status_code}; type={problem.get('type')}; requestId={request_id}"
)
result = response.json()
Taxonomy multipart
with open("garment.jpg", "rb") as image:
response = requests.post(
f"{BASE_URL}/taxonomy/v1/taxonomy",
headers={"Authorization": f"Bearer {KEY}"},
files={"image": ("garment.jpg", image, "image/jpeg")},
data={"qc": "photo", "subcategory": "tshirt"},
timeout=60,
)
response.raise_for_status()
result = response.json()
if result.get("broken") is True:
# Ask for a new photo; do not trust predicted fields.
pass
Retry
requests için retry yapılandırırken yalnız 429, 502, 503 durumlarını sınırlı sayıda tekrar deneyin. Retry-After değerine uyun; POST çağrılarında tekrarın ürün/maliyet etkisini dikkate alın.