# Список балансов виртуальных валют

> Возвращает текущий баланс каждой виртуальной валюты для профиля. Если в приложении нет виртуальных валют, `data` будет пустым массивом.

## OpenAPI

```yaml
/api-specs/adapty-api.yaml get /api/v2/server-side-api/vc/balances/
openapi: 3.1.0
info:
  title: Серверный API Adapty
  version: 1.0.0
servers:
  - url: https://api.adapty.io
    description: Продакшн-сервер
paths:
  /api/v2/server-side-api/vc/balances/:
    get:
      summary: Список балансов виртуальных валют
      description: |
        Возвращает текущий баланс каждой виртуальной валюты для профиля. Если в приложении нет виртуальных валют, `data` будет пустым массивом.
      operationId: listVirtualCurrencyBalances
      tags:
        - Virtual Currency
      security:
        - apikeyAuth: []
      parameters:
        - name: adapty-customer-user-id
          in: header
          required: false
          schema:
            type: string
          description: Уникальный идентификатор пользователя в вашей системе. Необходимо указать либо `adapty-customer-user-id`, либо `adapty-profile-id`.
        - name: adapty-profile-id
          in: header
          required: false
          schema:
            type: string
          description: Уникальный идентификатор профиля в вашей системе. Предпочтительный вариант при работе с анонимными профилями. Необходимо указать либо `adapty-customer-user-id`, либо `adapty-profile-id`.
      responses:
        "200":
          description: Балансы успешно возвращены
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VirtualCurrencyBalanceListResponse"
              example:
                response_created_at: 1779791400000
                data:
                  - code: COINS
                    name: Gold Coins
                    balance: 12450
                    held: 0
                    available: 12450
                  - code: GEMS
                    name: Gems
                    balance: 3280
                    held: 0
                    available: 3280
                  - code: ENERGY
                    name: Energy
                    balance: 840
                    held: 0
                    available: 840
        "400":
          description: Некорректный запрос.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Не авторизован. API-ключ отсутствует или недействителен.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Доступ запрещён. Server API для виртуальных валют не включён для этого приложения.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Профиль не найден.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Внутренняя ошибка сервера
components:
  schemas:
    VirtualCurrencyBalanceListResponse:
      type: object
      description: Текущие балансы всех виртуальных валют профиля.
      properties:
        response_created_at:
          type: integer
          format: int64
          description: Время генерации ответа в виде Unix-временной метки в миллисекундах.
        data:
          type: array
          items:
            $ref: "#/components/schemas/VirtualCurrencyProfileBalanceItem"
      required:
        - response_created_at
        - data
    ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
                nullable: true
                description: Источник ошибки
              errors:
                type: array
                items:
                  type: string
                description: Массив сообщений об ошибках
        error_code:
          type: string
          description: Краткое название ошибки
        status_code:
          type: integer
          description: HTTP-код статуса
      required:
        - errors
        - error_code
        - status_code
    VirtualCurrencyProfileBalanceItem:
      type: object
      properties:
        code:
          type: string
          description: Уникальный код виртуальной валюты в приложении. Буквы ASCII, цифры и символ подчёркивания.
        name:
          type: string
          description: Отображаемое название виртуальной валюты.
        balance:
          type: integer
          format: int32
          minimum: 0
          description: Общий баланс, включая суммы, находящиеся в резерве.
        held:
          type: integer
          format: int32
          minimum: 0
          description: Сумма всех активных резервов (зарезервированные средства). В настоящее время всегда равна 0.
        available:
          type: integer
          format: int32
          description: Баланс, доступный для использования, вычисляется как `balance - held`.
      required:
        - code
        - name
        - balance
        - held
        - available
  securitySchemes:
    apikeyAuth:
      type: apiKey
      name: Authorization
      in: header
      default: Api-Key {Your secret API key}
      description: |
        API-запросы должны быть аутентифицированы с помощью вашего секретного API-ключа, передаваемого в заголовке **Authorization** со значением `Api-Key {your_secret_api_key}`, например `Api-Key secret_live_...`. Найдите этот ключ в дашборде Adapty -> **App Settings** -> вкладка **General** -> раздел **API keys**.
```
