# Thông tin Ví (API Nâng cao)

Use your **Account Permission Key** to query the current personal account's wallet funds breakdown, historical consumption, referral commission stats, per-model discounts, and recharge/ledger history.

> [!IMPORTANT]
> - **Base URL**: `https://ai.artsmcp.com/api/open/v1`
> - **Auth Header (Choose One)**: `Authorization: Bearer <your_account_key>`, `X-Account-Api-Key: <your_account_key>`, or `X-Api-Key: <your_account_key>`
> - **Available Funds**: `available_funds` combines cash `balance`, `gift_balance`, and `credit_limit`; when `balance + credit_limit < 0`, `cash_in_arrears` is `true`

---

### 1. Get Wallet Balance & Commission Stats

Query real-time wallet balances, cumulative consumption, referral commission balance and invited count, active per-model exclusive discounts, and billing currency.

* **Path**: `GET /api/open/v1/wallet`
* **Query Parameters**: None
* **Example (Curl)**:

```bash
curl -s "https://ai.artsmcp.com/api/open/v1/wallet" \
  -H "Authorization: Bearer <your_account_key>"
```

* **Response Example**:

```json
{
  "balance": 500.0,
  "gift_balance": 20.0,
  "credit_limit": 0.0,
  "available_funds": 520.0,
  "cash_in_arrears": false,
  "total_consumption": 133.5,
  "used_quota": 128.5,
  "gift_used_quota": 5.0,
  "commission_balance": 35.2,
  "total_referred": 6,
  "marketing_enabled": true,
  "commission_ratio": 0.1,
  "commission_basis": "consumption",
  "discounted_models": [],
  "currency": "CNY",
  "currency_symbol": "¥",
  "currency_unit": "CNY"
}
```

* **Response Fields**:

| Field | Type | Description |
| :--- | :--- | :--- |
| `balance` | `number` | Cash wallet balance |
| `gift_balance` | `number` | Gift wallet balance |
| `credit_limit` | `number` | Account credit overdraft limit |
| `available_funds` | `number` | Combined available funds (`balance + gift_balance + credit_limit`; negative when cash is in arrears) |
| `cash_in_arrears` | `boolean` | Whether cash balance is in arrears (`true` when `balance + credit_limit < 0`) |
| `total_consumption` | `number` | Cumulative total spend (`used_quota + gift_used_quota`) |
| `used_quota` | `number` | Cumulative cash wallet spend |
| `gift_used_quota` | `number` | Cumulative gift wallet spend |
| `commission_balance` | `number` | Current referral commission wallet balance |
| `total_referred` | `integer` | Total referred users registered |
| `marketing_enabled` | `boolean` | Whether referral commission is enabled for the current user tier |
| `commission_ratio` | `number` | Referral commission ratio (e.g., `0.1` for 10%) |
| `commission_basis` | `string` | Commission calculation basis (`consumption` or `recharge`) |
| `discounted_models` | `array` | Active per-model exclusive discounts configured for the current account |
| `currency` / `currency_symbol` / `currency_unit` | `string` | Site billing currency code, symbol, and unit |

---

### 2. List Wallet Recharge & Ledger History

Paginated query of online recharge orders, redemption entries, and wallet ledger records (timestamps formatted in the site operating timezone).

* **Path**: `GET /api/open/v1/wallet/recharges`
* **Query Parameters**:

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `page` | `integer` | `1` | Page number (starting from `1`) |
| `per_page` | `integer` | `20` | Items per page (`1..100`) |
| `wallet_type` | `string` | All | Filter by wallet type: `system` (cash) or `gift` (gift wallet) |
| `recharge_type` | `string` | All | Filter by credit type (e.g., `alipay`, `wechat`, `stripe`, `redemption`, `transfer`) |

* **Example (Curl)**:

```bash
curl -s "https://ai.artsmcp.com/api/open/v1/wallet/recharges?page=1&per_page=20" \
  -H "Authorization: Bearer <your_account_key>"
```

* **Response Example**:

```json
{
  "data": [
    {
      "amount": 100.0,
      "recharge_type": "stripe",
      "wallet_type": "system",
      "order_no": "ORD202611292015001234",
      "fee_amount": 0.0,
      "remark": "Online Recharge",
      "created_at": "2026-11-29 20:15:08 (UTC+8)"
    }
  ],
  "total": 1,
  "page": 1,
  "per_page": 20
}
```

* **Response Fields**:

| Field | Type | Description |
| :--- | :--- | :--- |
| `data` | `array` | Recharge and ledger records on the current page |
| `data[].amount` | `number` | Amount credited (positive) or deducted (negative) |
| `data[].recharge_type` | `string` | Credit type (e.g., `alipay`, `wechat`, `stripe`, `redemption`, `transfer`) |
| `data[].wallet_type` | `string` | Wallet type: `system` (cash) or `gift` (gift wallet) |
| `data[].order_no` | `string` | Associated payment order number (present for online recharges; omitted otherwise) |
| `data[].fee_amount` | `number` | Payment processing fee for online recharges (`0` for non-online entries) |
| `data[].remark` | `string` | Ledger note (omitted if empty) |
| `data[].created_at` | `string` | Record creation timestamp in site operating timezone |
| `total` | `integer` | Total matching records |
| `page` / `per_page` | `integer` | Current page number and items per page |
