cURL · Virtual Try-On API
Virtual Try-On API mit cURL
Der schnellste Weg, eine API zu verstehen, ist der Aufruf über die Shell. Die Photta-Dokumentation ist gezielt cURL-first — alles auf dieser Seite läuft direkt im Terminal, ohne Node oder Python.
Kurz zusammengefasst
Exportieren Sie `PHOTTA_API_KEY`, senden Sie einen POST an `https://ai.photta.app/api/v1/tryon/apparel` mit dem passenden JSON-Body, speichern Sie die Generations-ID und loopen Sie `curl … /tryon/apparel/:id` alle 3 Sekunden bis `data.status` auf `completed` wechselt — typischerweise in 1.5 bis 4 Minuten. Nutzen Sie `jq`, um die Output-URL zu extrahieren.
Aktualisiert · 2026-04-19
Ihr erster Request
# Submit a try-on job. The API returns 202 Accepted + a generation ID.
JOB=$(curl -s -X POST "$PHOTTA_BASE_URL/tryon/apparel" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{
"product_type": "dress",
"product_images": ["https://example.com/dress.jpg"],
"mannequin_id": "mnq_athena_ts",
"pose_id": "pose_standing_front",
"resolution": "2K",
"aspect_ratio": "3:4"
}')
ID=$(echo "$JOB" | jq -r '.data.id')
echo "Generation $ID queued"
# Poll every 3 seconds until the job completes (max 6 minutes).
for i in $(seq 1 120); do
RESULT=$(curl -s "$PHOTTA_BASE_URL/tryon/apparel/$ID" -H "$AUTH_HEADER")
STATUS=$(echo "$RESULT" | jq -r '.data.status')
if [ "$STATUS" = "completed" ]; then
echo "$RESULT" | jq -r '.data.output_url'
break
fi
if [ "$STATUS" = "failed" ]; then
echo "$RESULT" | jq -r '.data.error_message' >&2
exit 1
fi
sleep 3
doneWas Sie erwartet
Typical completion
1.5–4min
2K / 4K credits
5 / 7
Jewelry types
4
Close-up mannequins
built-in
Funktionsweise
Virtual Try-On API mit cURL
Fünf Shell-Schritte, null Abhängigkeiten außer curl und jq.
- 01
Schritt 1
Registrieren und Key generieren
Gehen Sie zu ai.photta.app, öffnen Sie den Developers-Tab und generieren Sie einen API-Key. Live-Keys beginnen mit `photta_live_`.
- 02
Schritt 2
Key exportieren
Setzen Sie `export PHOTTA_API_KEY="photta_live_xxx"` in Ihrem Shell-Profil oder einer `.envrc`, damit jeder curl-Aufruf ihn automatisch verwendet.
- 03
Schritt 3
Base-URL festlegen
`export PHOTTA_BASE_URL="https://ai.photta.app/api/v1"` hält curl-Befehle kurz und erleichtert den späteren Wechsel zu einer Sandbox-URL.
- 04
Schritt 4
Senden und pollen
POST an `$PHOTTA_BASE_URL/tryon/apparel`, um eine ID zu erhalten, dann loopen Sie `curl $PHOTTA_BASE_URL/tryon/apparel/$ID` alle 3 Sekunden. Leiten Sie die Antwort an jq weiter, um `.data.status` sauber zu extrahieren.
- 05
Schritt 5
Ergebnis persistieren
Sobald der Job fertig ist, ziehen Sie `.data.output_url` mit jq heraus und nutzen Sie `curl -o`, um die Daten lokal zu speichern — bereit für den nächsten Schritt in Ihrer Pipeline.
Code, End-to-End
Copy, paste, done.
Four snippets — install prerequisites, wrap the REST call, submit + poll, then handle the errors that actually happen in production.
# Verify curl is available
curl --version
# Export your API key so the rest of the calls can reference it
export PHOTTA_API_KEY="photta_live_xxxxx"# Pin the base URL in a shell variable so every call is a one-liner.
export PHOTTA_BASE_URL="https://ai.photta.app/api/v1"
# Reusable auth header — every request needs it.
AUTH_HEADER="Authorization: Bearer $PHOTTA_API_KEY"# Submit a try-on job. The API returns 202 Accepted + a generation ID.
JOB=$(curl -s -X POST "$PHOTTA_BASE_URL/tryon/apparel" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{
"product_type": "dress",
"product_images": ["https://example.com/dress.jpg"],
"mannequin_id": "mnq_athena_ts",
"pose_id": "pose_standing_front",
"resolution": "2K",
"aspect_ratio": "3:4"
}')
ID=$(echo "$JOB" | jq -r '.data.id')
echo "Generation $ID queued"
# Poll every 3 seconds until the job completes (max 6 minutes).
for i in $(seq 1 120); do
RESULT=$(curl -s "$PHOTTA_BASE_URL/tryon/apparel/$ID" -H "$AUTH_HEADER")
STATUS=$(echo "$RESULT" | jq -r '.data.status')
if [ "$STATUS" = "completed" ]; then
echo "$RESULT" | jq -r '.data.output_url'
break
fi
if [ "$STATUS" = "failed" ]; then
echo "$RESULT" | jq -r '.data.error_message' >&2
exit 1
fi
sleep 3
done# -w pulls out the HTTP status without polluting the JSON body.
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$PHOTTA_BASE_URL/tryon/apparel" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{ "product_type": "dress" }')
BODY=$(echo "$RESPONSE" | sed '$d')
STATUS=$(echo "$RESPONSE" | tail -1)
case "$STATUS" in
200|202)
echo "$BODY" | jq '.data' ;;
402)
echo "Out of credits" ; echo "$BODY" | jq '.error' ;;
429)
RETRY=$(echo "$BODY" | jq -r '.error.retry_after')
echo "Rate limited — retry in ${RETRY}s" ;;
*)
echo "Error $STATUS" ; echo "$BODY" | jq '.error' ;;
esacWarum diese Struktur
Warum cURL immer noch der schnellste Weg zum Verifizieren einer API ist
- Zero install — cURL ships with every major OS
- Pairs with `jq` for scripted pipelines (CI, cron, bash hooks)
- Ideal for smoke-testing endpoints before wiring them into code
- All code in this page copy-pastes into any POSIX shell
Was es nicht kann
Honest caveats
- cURL's polling loop blocks your terminal — move to Node/Python for parallel workers
- No streaming parser for the result; you fetch the final URL when the job is done
- Windows Command Prompt users should run WSL or PowerShell's curl.exe wrapper
Fragen anderer Entwickler
Questions other developers ask
Gibt es ein Photta CLI-Tool?+
Noch nicht — aber cURL plus ein 15-zeiliger Bash-Wrapper erledigt fast alles. Wir priorisieren cURL-Beispiele, da jede Sprache Subprozesse ausführen kann und die Shell der kleinste gemeinsame Nenner in CI-Pipelines ist.
Benötige ich jq für die API?+
Nicht zwingend — aber automatisierte Pipelines sind damit viel einfacher. Mit jq extrahieren Sie `.data.id`, `.data.status` und `.data.output_url` aus dem JSON, ohne es manuell parsen zu müssen. Installation via `brew install jq` (macOS) oder `apt install jq` (Debian/Ubuntu).
Wie authentifiziere ich mich mit curl?+
Fügen Sie `-H "Authorization: Bearer $PHOTTA_API_KEY"` zu jedem Request hinzu. Halten Sie den Key in einer Umgebungsvariable, niemals direkt im Skript. `curl --oauth2-bearer` funktioniert ebenfalls, aber die explizite Header-Form ist in Logs und Dokumentationen klarer.
Kann ich curl-Skripte in Produktion einsetzen?+
Für einmalige Batch-Backfills und Cron-Jobs: ja — tausende Teams erledigen Katalog-Updates so. Für langlebige Applikationen ist eine echte Programmiersprache besser (Fehlerbehandlung, Retries, Observability). Die curl-Beispiele bleiben jedoch als Referenz für die Request-Struktur gültig.
Wie polle ich in einer Bash-Schleife?+
Nutzen Sie `for i in $(seq 1 120); do … ; sleep 3; done` mit dem Status-Check im Schleifenkörper. Brechen Sie ab, wenn `.data.status` auf `completed` oder `failed` steht. Das Code-Beispiel zeigt das exakte Muster inklusive Limit, damit das Skript nicht ewig hängt.
Wie lese ich Fehlerantworten in curl?+
Nutzen Sie `curl -w "\n%{http_code}"`, um den HTTP-Statuscode zusammen mit dem JSON-Body zu erhalten. Reagieren Sie auf den Status: 402 für fehlende Credits, 429 für Rate-Limits (Retry-After beachten), 5xx für temporäre Serverfehler. Der Error-Body enthält immer `error.code` und `error.message`.
cURL · Virtual Try-On API
Account erstellen und API-Key erhalten
Exportieren Sie `PHOTTA_API_KEY`, senden Sie einen POST an `https://ai.photta.app/api/v1/tryon/apparel` mit dem passenden JSON-Body, speichern Sie die Generations-ID und loopen Sie `curl … /tryon/apparel/:id` alle 3 Sekunden bis `data.status` auf `completed` wechselt — typischerweise in 1.5 bis 4 Minuten. Nutzen Sie `jq`, um die Output-URL zu extrahieren.