cURL · 가상 피팅 API

cURL 가상 피팅 API

API를 이해하는 가장 빠른 방법은 쉘에서 호출해보는 것입니다. Photta 문서는 cURL 우선으로 설계되어 Node나 Python 없이도 터미널 한 곳에서 모든 기능을 실행할 수 있습니다.

요약

`PHOTTA_API_KEY`를 내보내고(export), 올바른 JSON 본문과 함께 `https://ai.photta.app/api/v1/tryon/apparel`로 POST 요청을 보내 생성 ID를 확보하세요. 그 후 3초마다 `curl … /tryon/apparel/:id`를 반복 호출하여 `data.status`가 `completed`가 될 때까지 확인하세요. 최종 응답에서 출력 URL을 추출할 때는 `jq`를 사용하면 편리합니다.

업데이트됨 · 2026-04-19

첫 번째 요청

cURLNode.jsPythoncURL
# 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

기대 효과

Typical completion

1.5–4min

2K / 4K credits

5 / 7

Jewelry types

4

Close-up mannequins

built-in

작동 원리

cURL 가상 피팅 API

5단계 쉘 명령, curl과 jq 외 의존성 없음.

  1. 01

    단계 1

    가입 및 키 생성

    ai.photta.app으로 가서 개발자 탭을 열고 API 키를 생성하세요. 라이브 키는 `photta_live_`로 시작합니다.

  2. 02

    단계 2

    키 내보내기

    쉘 프로필이나 `.envrc` 파일에 `export PHOTTA_API_KEY="photta_live_xxx"`를 추가하면 이후 모든 curl 명령에서 자동으로 키를 참조합니다.

  3. 03

    단계 3

    Base URL 고정

    `export PHOTTA_BASE_URL="https://ai.photta.app/api/v1"`을 설정하면 curl 명령어를 짧게 유지할 수 있고, 추후 샌드박스 URL로 전환하기도 쉽습니다.

  4. 04

    단계 4

    제출 및 폴링

    ID를 얻기 위해 `$PHOTTA_BASE_URL/tryon/apparel`로 POST한 뒤, `curl $PHOTTA_BASE_URL/tryon/apparel/$ID`를 3초 간격으로 반복 실행하세요. 응답을 jq로 파이프 연결하면 `.data.status`만 깔끔하게 추출할 수 있습니다.

  5. 05

    단계 5

    결과 저장

    작업이 완료되면 jq를 사용하여 `.data.output_url`을 추출하고, `curl -o` 명령어로 바이트 데이터를 로컬 저장소에 저장하여 다음 파이프라인 단계에서 사용하세요.

전체 코드

Copy, paste, done.

Four snippets — install prerequisites, wrap the REST call, submit + poll, then handle the errors that actually happen in production.

01cURL is already installed on macOS, Linux, WSL and modern Windows
bash
# 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"
02Set the base URL + auth header once
bash
# 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"
03Submit and poll in one script
bash
# 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
04Read the status code + error body instead of silently failing
bash
# -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' ;;
esac

구조 설계 이유

cURL이 여전히 API 검증에 가장 빠른 이유

  • 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

제외된 기능

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

개발자 자주 묻는 질문

Questions other developers ask

Photta CLI 도구가 있나요?+

아직은 없지만, cURL과 15줄 정도의 bash 래퍼만으로도 거의 모든 기능을 구현할 수 있습니다. 모든 언어에서 서브프로세스를 실행할 수 있고 쉘은 CI 파이프라인의 공통 분모이기 때문에 cURL 예제를 우선적으로 제공합니다.

API 사용 시 jq가 꼭 필요한가요?+

필수는 아니지만 스크립트 기반 파이프라인을 짤 때는 매우 유용합니다. jq를 쓰면 JSON 응답에서 `.data.id`, `.data.status`, `.data.output_url` 등을 수동 파싱 없이 바로 추출할 수 있습니다. macOS에서는 `brew install jq`, Debian/Ubuntu에서는 `apt install jq`로 설치하세요.

curl에서 인증은 어떻게 하나요?+

모든 요청에 `-H "Authorization: Bearer $PHOTTA_API_KEY"`를 추가하세요. 키는 항상 환경 변수에 보관하고 스크립트에 직접 적지 마세요. `curl --oauth2-bearer`도 작동하지만, 문서와 로그에서의 가독성을 위해 명시적인 헤더 형태를 권장합니다.

curl 기반 스크립트를 실제 서비스에 써도 되나요?+

일회성 배치 백필이나 크론 작업에는 충분하며, 실제로 많은 팀이 이 방식으로 카탈로그를 관리합니다. 다만 규모가 큰 애플리케이션이라면 에러 처리, 재시도 로직, 관측성을 위해 실제 프로그래밍 언어를 쓰는 것이 좋습니다. curl 예제는 Node나 Python으로 포팅한 후에도 요청 구조가 동일하므로 유용한 참조가 됩니다.

bash 루프에서 폴링은 어떻게 하나요?+

루프 안에서 상태 체크를 수행하는 `for i in $(seq 1 120); do … ; sleep 3; done` 구문을 사용하세요. `.data.status`가 `completed` 또는 `failed`가 되면 루프를 탈출(break)하도록 구성합니다. 이 페이지의 코드 샘플은 작업이 멈춰 스크립트가 무한 대기하지 않도록 하는 안전 장치를 포함하고 있습니다.

curl에서 에러 응답은 어떻게 확인하나요?+

`curl -w "\n%{http_code}"`를 사용하면 JSON 본문과 함께 HTTP 상태 코드를 캡처할 수 있습니다. 크레딧 부족 시 402, rate limits 시 429(Retry-After 값 준수), 일시적 서버 에러 시 5xx 등으로 분기 처리하세요. 에러 본문에는 항상 `error.code`와 `error.message` 필드가 포함됩니다.

cURL · 가상 피팅 API

계정 생성 및 API 키 발급

`PHOTTA_API_KEY`를 내보내고(export), 올바른 JSON 본문과 함께 `https://ai.photta.app/api/v1/tryon/apparel`로 POST 요청을 보내 생성 ID를 확보하세요. 그 후 3초마다 `curl … /tryon/apparel/:id`를 반복 호출하여 `data.status`가 `completed`가 될 때까지 확인하세요. 최종 응답에서 출력 URL을 추출할 때는 `jq`를 사용하면 편리합니다.

cURL용 가상 피팅 API — Photta | Photta