ToAPIsToAPIs
アカウント照会

アカウント残高の取得

システムアクセストークンで自身のアカウントデータを取得

GET
/api/v1/account/balance

中国本土のユーザー向け: 中国本土のユーザーは https://toapis.cn を API エンドポイント (Base URL)としてご利用ください. 本ドキュメント内の例では https://toapis.com を https://toapis.cn に置き換えてください.

認証, ページ分割, エラーは利用ガイドを参照してください.

動作

balance_kind=account_balance は残高, subaccount_budget はサブアカウント自身の予算です. 親の残高は読み取りません. remaining_* と used_* は同じスナップショットで, credits_per_usd により換算します.

認証

Authorizationstringヘッダー必須

Bearer YOUR_SYSTEM_ACCESS_TOKEN を使用します. モデル API キーは使用できません. X-User-Id は不要です.

パラメータ

パスパラメータ, クエリパラメータ, リクエストボディは使用しません.

リクエスト例

curl --request GET \
  --url 'https://toapis.com/api/v1/account/balance' \
  --header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'
import requests

response = requests.get(
    "https://toapis.com/api/v1/account/balance",
    headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
const url = new URL("https://toapis.com/api/v1/account/balance");

const response = await fetch(url, {
  headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
  signal: AbortSignal.timeout(30_000),
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());

レスポンスフィールド

例は架空のデータで, credits_per_usd="100" を仮定しています. 実際の換算にはレスポンスの値を使用してください.

codeinteger

結果コード. 0 は成功です.

messagestring

成功時は空文字列です. エラーメッセージは翻訳されます.

dataobject

今回の照会結果オブジェクトです.

data.remaining_creditsstring

アカウントの残りの credits です. 精度を保持するため 10 進文字列で返します.

data.used_creditsstring

使用済みの credits です. 精度を保持するため 10 進文字列で返します.

data.remaining_usdstring

残額を USD に換算した値です. 精度を保持するため 10 進文字列で返します.

data.used_usdstring

使用済み額を USD に換算した値です. 精度を保持するため 10 進文字列で返します.

data.credits_per_usdstring

1 USD あたりの credits 数. 換算にはこの値を使います. 精度を保持するため 10 進文字列で返します.

data.balance_kindstring

account_balance は口座残高, subaccount_budget はサブアカウント自身の予算で親の残高は含みません.

レスポンス例

{
  "code": 0,
  "message": "",
  "data": {
    "remaining_credits": "1000",
    "remaining_usd": "10",
    "used_credits": "100",
    "used_usd": "1",
    "credits_per_usd": "100",
    "balance_kind": "account_balance"
  }
}