# Skill: Manage Your Balance on APIHub

> Check your credit balance, monitor spending, and understand your usage.

## Fastest: `@apihubio/cli`

```bash
npx @apihubio/cli balance
```

Prints your current credit balance (and warns if it's running low).

## Check balance via API

```
GET https://api.apihub.io/v1/credits/balance
Authorization: Bearer ahk_your_key
```

Response:
```json
{
  "ok": true,
  "data": {
    "credit_balance_microdollars": 4500000,
    "credit_balance_display": "$4.5000"
  }
}
```

## Check balance with full stats

```
GET https://api.apihub.io/v1/wallet/balance
Authorization: Bearer ahk_your_key
```

Response:
```json
{
  "ok": true,
  "data": {
    "agent_id": "01ABC...",
    "credit_balance_microdollars": 4500000,
    "total_spent_microdollars": 500000,
    "total_requests": 423,
    "rate_limit": {
      "requests_this_minute": 3,
      "limit_per_minute": 100,
      "remaining": 97
    }
  }
}
```

## Check balance via MCP

If connected via MCP, use the balance tool:

```json
{
  "tool": "apihub_balance",
  "arguments": {}
}
```

## View credit transaction history

```
GET https://api.apihub.io/v1/credits/history?limit=20
Authorization: Bearer ahk_your_key
```

Response:
```json
{
  "ok": true,
  "data": {
    "transactions": [
      {
        "id": "01DEF...",
        "amount_microdollars": 1000,
        "type": "debit",
        "balance_after": 4499000,
        "created_at": "2026-04-21T14:30:00Z"
      },
      {
        "id": "01GHI...",
        "amount_microdollars": 5000000,
        "type": "purchase",
        "payment_reference": "0xabc123...",
        "balance_after": 5000000,
        "created_at": "2026-04-21T12:00:00Z"
      }
    ]
  }
}
```

Transaction types:
| Type | Meaning |
|------|---------|
| purchase | Credits added via USDC payment |
| debit | Credits spent on an API call |
| refund | Credits returned (admin action) |

## Understanding pricing

All prices are in **microdollars** (1 USD = 1,000,000 microdollars).

| Microdollars | USD |
|-------------|-----|
| 1,000 | $0.001 |
| 10,000 | $0.01 |
| 100,000 | $0.10 |
| 1,000,000 | $1.00 |

Endpoint prices are set by providers. Check pricing before calling:
```
GET https://api.apihub.io/v1/services/{slug}
```

## Rate limits

- Free tier: 100 requests per minute per API key
- Paid tier (credit balance > 0): 1,000 requests per minute per API key

Rate limit headers on every response:
| Header | Description |
|--------|-------------|
| X-RateLimit-Limit | Max requests per minute |
| X-RateLimit-Remaining | Requests left this minute |
| Retry-After | Seconds to wait (only on 429) |

## Low balance strategy

To avoid running out of credits mid-task:

1. Check balance before starting a batch of calls
2. Estimate total cost: `number_of_calls * price_per_request`
3. If balance is insufficient, purchase more credits first
4. Monitor balance after each call via the X-APIHub-Credit-Balance-Remaining response header

## Dashboard

For human operators, the web dashboard provides:
- Balance overview: https://apihub.io/agents/dashboard
- Credit purchase: https://apihub.io/agents/credits
- Transaction history: https://apihub.io/agents/transactions

## Related skills

- Purchase credits: https://apihub.io/skills/purchase-credits.md
- Make API calls: https://apihub.io/skills/make-api-call.md
