# getBalance

## <mark style="color:blue;">範例</mark>

{% tabs %}
{% tab title="TypeScript" %}

```typescript
const balances = await akashicPay.getBalance();
```

{% endtab %}

{% tab title="PHP" %}

```php
$balances = akashicPay->getBalance();
```

{% endtab %}

{% tab title="Java" %}

```java
APBalanceResult balances = akashicPay.getBalance(l2Address);
```

{% endtab %}

{% tab title="C#" %}

```csharp
var balance = await akashicPay.GetBalanceAsync();
```

{% endtab %}

{% tab title="Go" %}

```go
bal, err := ap.GetBalance()
```

{% endtab %}
{% endtabs %}

## <mark style="color:blue;">回調範例</mark>

回調一個物件陣列 (array of objects)，每個本機貨幣一個物件 (objects)，每個有非零餘額的代幣一個物件 (objects)。在下面的範例中，呼叫者沒有 ETH 的 USDT 結餘，因此沒有該實例的物件 (objects)。

注意：對於[原生代幣](/traditional-chinese/jian-jie/shu-yu.md#huo-bi)，總是會回調一個物件 (object)。[代幣](/traditional-chinese/jian-jie/shu-yu.md#dai-bi)僅在您擁有非零數量時才會顯示。

{% tabs %}
{% tab title="TypeScript" %}

```typescript
[
  {
    "coinSymbol": APNetworkSymbol.SEP,
    "balance": "5.000000000000000000",
  },
  {
    "coinSymbol": APNetworkSymbol.TRX_SHASTA,
    "balance": "34.000000",
  },
  {
    "coinSymbol": APNetworkSymbol.TRX_SHASTA,
    "tokenSymbol": APTokenSymbol.USDT,
    "balance": "100.500000",
  },
];
```

{% endtab %}

{% tab title="PHP" %}

```php
[
  {
    "coinSymbol": NetworkSymbol::ETHEREUM_SEPOLIA,
    "balance": "5.000000000000000000"
  },
  {
    "coinSymbol": NetworkSymbol::TRON_SHASTA,
    "balance": "34.000000"
  },
  {
    "coinSymbol": NetworkSymbol::TRON_SHASTA,
    "tokenSymbol": TokenSymbol::USDT,
    "balance": "100.500000"
  },
]
```

{% endtab %}

{% tab title="Java" %}

```java
[
  {
    "coinSymbol": APNetworkSymbol.SEP,
    "balance": "5.000000000000000000"
  },
  {
    "coinSymbol": APNetworkSymbol.TRX_SHASTA,
    "balance": "34.000000"
  },
  {
    "coinSymbol": APNetworkSymbol.TRX_SHASTA,
    "tokenSymbol": APTokenSymbol.USDT,
    "balance": "100.500000"
  },
]
```

{% endtab %}

{% tab title="C#" %}

```csharp

  "Balances": [
    {
      "NetworkSymbol": EthSepNetworkSymbol,
      "TokenSymbol": ApTokenSymbol.Native,
      "Balance": "0.00123123"
    },
    {
      "NetworkSymbol": EthSepNetworkSymbol,
      "TokenSymbol": ApTokenSymbol.Usdt,
      "Balance": "150.52"
    },
    {
      "NetworkSymbol": TronShastaNetworkSymbol,
      "TokenSymbol": ApTokenSymbol.Native,
      "Balance": "1200.4"
    },
    {
      "NetworkSymbol": TronShastaNetworkSymbol,
      "TokenSymbol": ApTokenSymbol.Usdt,
      "Balance": "353.56"
    }
  ]
}
```

{% endtab %}

{% tab title="Go" %}

```go
[
  {
    NetworkSymbol: akashicpay.Ethereum_Sepolia,
    Balance: "5.000000000000000000"
  },
  {
    NetworkSymbol: akashicpay.Tron_Shasta,
    Balance: "34.000000"
  },
  {
    NetworkSymbol: akashicpay.Tron_Shasta,
    TokenSymbol: akashicpay.USDT,
    Balance: "100.500000"
  },
]
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akashicpay.com/traditional-chinese/sdk/han-shi-functions/getbalance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
