빠른 시작
이 가이드는 첫 번째 API 요청을 보내는 과정을 안내합니다.
사전 준비
- API 키가 발급된 Headless Commerce 계정
curl 또는 HTTP 클라이언트
Step 1: API 키 확인
대시보드에서 스토어를 생성하면 두 가지 유형의 키를 받게 됩니다:
| 키 유형 | 접두사 | 용도 |
|---|
| Secret Key | sk_test_* / sk_live_* | 서버 사이드 전용. 전체 API 접근. |
| Publishable Key | pk_test_* / pk_live_* | 클라이언트 사이드 안전. Storefront API만 접근. |
Secret Key를 클라이언트 사이드 코드에 절대 노출하지 마세요. 브라우저 및 모바일 앱에서는 Publishable Key를 사용하세요.
Step 2: 상품 목록 조회
Storefront API에서 활성 상품을 조회합니다:
curl https://api.headlesscommerce.io/v1/storefront/products \
-H "Authorization: Bearer pk_test_your_key_here"
{
"data": [
{
"id": "prod_abc123",
"name": "Classic T-Shirt",
"status": "active",
"type": "physical",
"variants": [...]
}
],
"has_more": false,
"next_cursor": null
}
Step 3: 장바구니 생성
curl -X POST https://api.headlesscommerce.io/v1/storefront/carts \
-H "Authorization: Bearer pk_test_your_key_here" \
-H "Content-Type: application/json" \
-d '{"session_id": "guest-session-123"}'
Step 4: 상품 추가
curl -X POST https://api.headlesscommerce.io/v1/storefront/carts/{cart_id}/items \
-H "Authorization: Bearer pk_test_your_key_here" \
-H "Content-Type: application/json" \
-d '{"variant_id": "var_xxx", "quantity": 1}'
Step 5: 체크아웃
curl -X POST https://api.headlesscommerce.io/v1/storefront/carts/{cart_id}/checkout \
-H "Authorization: Bearer pk_test_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"payment_provider": "stripe",
"payment_method_id": "pm_xxx"
}'
다음 단계