API 레퍼런스초보자업데이트
GET/v1/user/balance

API 콘솔

GET/v1/user/balance
키 보기

입력한 키로 실제 요청을 보내며 일반 API 요금이 적용됩니다.

잔액 조회 API

API 키로 계정 잔액과 요금제 사용량을 조회할 수 있습니다. 자체 스크립트나 모니터링 시스템에 연동하기에 적합합니다.

엔드포인트 및 인증

text
GET https://api.icodeeasy.cc/v1/user/balance

/v1 접두사가 없는 https://api.icodeeasy.cc/user/balance도 사용할 수 있습니다.

본인의 API 키로 인증하며, 다음 세 가지 헤더 중 하나를 사용하세요:

text
Authorization: Bearer <내 API 키>
X-Api-Key: <내 API 키>
x-goog-api-key: <내 API 키>

응답 필드

필드타입설명
is_activeboolean계정 활성화 여부
balancenumber사용 가능한 잔액
unitstring잔액 및 한도의 통화. 항상 CNY(위안)
plan_typestring종량제는 paygo. 월정액 값은 monthly_로 시작함(예: monthly_2, monthly_limit_5, monthly_gpt_5)
daily_limitnumber월정액 일일 한도
daily_usednumber오늘 사용한 월정액 한도
daily_remainingnumber유효한 월정액의 오늘 남은 한도. 유효한 월정액이 없으면 0
plan_expires_atstring/null요금제 만료 시간(ISO 8601). 월정액이 없으면 null

요청 예시

curl:

bash
curl https://api.icodeeasy.cc/v1/user/balance \
  -H "Authorization: Bearer <내 API 키>"

응답 예시:

json
{
  "is_active": true,
  "balance": 80.28,
  "unit": "CNY",
  "plan_type": "paygo",
  "daily_limit": 0,
  "daily_used": 0,
  "daily_remaining": 0,
  "plan_expires_at": null
}

Python:

python
import requests

resp = requests.get(
    "https://api.icodeeasy.cc/v1/user/balance",
    headers={"Authorization": "Bearer <내 API 키>"},
    timeout=10,
)
resp.raise_for_status()
data = resp.json()
print(f"잔액: ¥{data['balance']:.2f} ({data['unit']})")

참고

조회는 한도를 소모하지 않으며 잔액이 0이어도 가능합니다. 월정액 적용 범위 밖의 요청은 계정 잔액에서 차감될 수 있습니다.

HTTP 401은 API 키가 없거나 유효하지 않다는 뜻입니다. 연결 문제가 있으면 연결 점검을 참고하세요.