# GET /v1/balance

获取余额

站长当前的余额：`available`为可申请结算的金额，`pending`为预估收益（AGIMone尚未最终确认的日期；最终确认前不可结算），`requested`为未结结算申请中的金额，`paid_total`为已结算的累计总额，`min_payout`为最低结算金额。所有金额均为金额字符串。数值与GET /v1/earnings响应中的`balance`字段一致。需要权限范围`publisher:read`（API密钥或网页会话）。速率限制等级：`read`。

- 所需权限范围: `publisher:read`
- 速率限制: `read` — 120 次请求/60秒窗口 每个API密钥或网页会话

## 参数

无参数。

## 响应

```
{ available: string; held: string; min_payout: string; paid_total: string; pending: string; requested: string }
```

## 错误

有速率限制的路由会返回`RateLimit-Limit`、`RateLimit-Remaining`和`RateLimit-Reset`（距窗口结束的秒数）；429响应还会带有`Retry-After`。限流器暂时不可用时，这些响应头可能缺失（此时请求会被放行）。

| 状态码 | 含义 |
|---|---|
| 401 | API密钥缺失、无效或已被撤销。 |
| 403 | 该密钥缺少所需的权限范围，或该主体无权执行此操作。 |
| 429 | 已超出速率限制；请等待`Retry-After`秒后重试。 |

## 示例

### cURL

```bash
#!/usr/bin/env bash
# GET /v1/balance: current balance (pending, available, requested, paid_total, min_payout).
# Needs: AGIMONE_API_KEY (create one at https://app.agimone.com/app/account/api-keys). Optional: AGIMONE_API_BASE.
set -euo pipefail
BASE="${AGIMONE_API_BASE:-https://app.agimone.com}"
curl -fsS -H "Authorization: Bearer $AGIMONE_API_KEY" "$BASE/v1/balance"
echo
```

### Node.js

```js
// GET /v1/balance: current balance (pending, available, requested, paid_total, min_payout). Node 18+, no dependencies.
// Needs: AGIMONE_API_KEY (create one at https://app.agimone.com/app/account/api-keys). Optional: AGIMONE_API_BASE.
const base = process.env.AGIMONE_API_BASE ?? 'https://app.agimone.com';

const res = await fetch(`${base}/v1/balance`, {
  headers: { Authorization: `Bearer ${process.env.AGIMONE_API_KEY}` },
});
if (!res.ok) {
  console.error(`HTTP ${res.status}: ${await res.text()}`);
  process.exit(1);
}
console.log(JSON.stringify(await res.json()));
```

### PHP

```php
<?php
// GET /v1/balance: current balance (pending, available, requested, paid_total, min_payout). PHP 8 with the curl extension, no other dependencies.
// Needs: AGIMONE_API_KEY (create one at https://app.agimone.com/app/account/api-keys). Optional: AGIMONE_API_BASE.
$base = getenv('AGIMONE_API_BASE') ?: 'https://app.agimone.com';

$ch = curl_init("$base/v1/balance");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('AGIMONE_API_KEY')],
    CURLOPT_TIMEOUT => 15,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
    fwrite(STDERR, "HTTP $status: " . ($body === false ? curl_error($ch) : $body) . "\n");
    exit(1);
}
curl_close($ch);
echo trim($body), "\n";
```

### Python

```python
# GET /v1/balance: current balance (pending, available, requested, paid_total, min_payout). Python 3.8+, standard library only.
# Needs: AGIMONE_API_KEY (create one at https://app.agimone.com/app/account/api-keys). Optional: AGIMONE_API_BASE.
import json
import os
import sys
import urllib.error
import urllib.request

base = os.environ.get("AGIMONE_API_BASE", "https://app.agimone.com")
req = urllib.request.Request(
    f"{base}/v1/balance",
    headers={"Authorization": f"Bearer {os.environ['AGIMONE_API_KEY']}"},
)
try:
    with urllib.request.urlopen(req, timeout=15) as res:
        print(json.dumps(json.load(res)))
except urllib.error.HTTPError as e:
    print(f"HTTP {e.code}: {e.read().decode()}", file=sys.stderr)
    sys.exit(1)
```

HTML文档: https://agimone.com/zh/developers/api/#get-balance
API 2026-10
