계정 잔액 조회 API
인터페이스 설명
계정 잔액 조회를 통해 사용자는 자신의 API Key로 New API 계정 잔액을 확인할 수 있습니다. 이 엔드포인트는 잔액만 조회하며 생성 작업을 일으키지 않고 요금도 청구하지 않습니다.
엔드포인트: GET /api/user/balance
과금: 무료.
잔액 단위: yuan. 응답의 effective_amount는 quota_per_unit으로 사용자가 이해할 수 있는 위안 금액으로 이미 환산되어 있습니다.
요청 파라미터
Headers
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| Authorization | string | 예 | Bearer YOUR_API_KEY |
Query 파라미터
없습니다.
요청 예시
cURL
curl -X GET https://www.suno-api.io/api/user/balance \
-H "Authorization: Bearer YOUR_API_KEY"
Python
import requests
api_key = "YOUR_API_KEY"
response = requests.get(
"https://www.suno-api.io/api/user/balance",
headers={"Authorization": f"Bearer {api_key}"},
timeout=30,
)
response.raise_for_status()
result = response.json()
balance = result["data"]["balance"]
print(balance["formatted_effective_amount"])
Node.js
const apiKey = "YOUR_API_KEY";
const response = await fetch("https://www.suno-api.io/api/user/balance", {
method: "GET",
headers: {
Authorization: `Bearer ${apiKey}`,
},
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const result = await response.json();
console.log(result.data.balance.formatted_effective_amount);
PHP
<?php
$apiKey = "YOUR_API_KEY";
$ch = curl_init("https://www.suno-api.io/api/user/balance");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
curl_close($ch);
$result = json_decode($response, true);
echo $result["data"]["balance"]["formatted_effective_amount"];
?>
응답 결과
{
"success": true,
"message": "",
"data": {
"object": "user_balance",
"user": {
"id": 123,
"username": "example",
"quota": 207900000,
"used_quota": 0,
"request_count": 10,
"group": "default",
"status": 1
},
"token": {
"id": 456,
"name": "default",
"group": "default",
"status": 1,
"remain_quota": 207900000,
"used_quota": 0,
"unlimited_quota": true,
"model_limits_enabled": false,
"model_limits": {}
},
"balance": {
"user_quota": 207900000,
"token_quota": 207900000,
"effective_quota": 207900000,
"user_amount": 415.8,
"token_amount": 415.8,
"effective_amount": 415.8,
"amount_unit": "yuan",
"formatted_effective_amount": "415.80 yuan"
},
"display": {
"quota_per_unit": 500000,
"amount_unit": "yuan"
}
}
}
필드 설명
| 필드 | 타입 | 설명 |
|---|---|---|
balance.user_quota |
number | 사용자 계정의 남은 할당량 원시값 |
balance.token_quota |
number | 현재 API Key의 남은 할당량 원시값. 무제한 키는 사용자 잔액을 반환합니다 |
balance.effective_quota |
number | 현재 API Key가 실제 사용할 수 있는 할당량 원시값 |
balance.effective_amount |
number | 환산 후 실제 사용 가능한 금액 |
balance.amount_unit |
string | yuan으로 고정 |
balance.formatted_effective_amount |
string | 사용자에게 그대로 보여줄 수 있는 잔액 문자열 |
display.quota_per_unit |
number | 원시 할당량 환산 단위. 금액 = quota / quota_per_unit |
설명
- 이 엔드포인트가 사용하는 API Key는 생성 엔드포인트와 동일합니다.
- API Key의 잔액이 소진되어도 잔액 조회는 여전히 허용됩니다.
- 비활성화되었거나 만료된 API Key는 조회할 수 없습니다.
- 인터페이스는 USD, CNY,
$,¥를 반환하지 않고 항상yuan을 사용해 사용자의 오해를 막습니다.