# GET /v1/balance

Баланс

Текущий баланс паблишера: `available` — сумма, которую можно запросить к выплате, `pending` — ориентировочный доход (дни, которые AGIMone ещё не завершил; к выплате недоступен до финализации), `requested` — сумма в открытых запросах на выплату, `paid_total` — всего уже выплачено, `min_payout` — минимальная сумма выплаты. Все суммы — денежные строки. Те же числа, что в поле `balance` ответа GET /v1/earnings. Требуется область `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/ru/developers/api/#get-balance
API 2026-10
