# suix_getBalance

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://sui-mainnet.g.alchemy.com/v2/{apiKey}

Returns the total coin balance for a single coin type owned by the specified address. If no coin type is specified, defaults to the native SUI coin type.


Reference: https://www.alchemy.com/docs/chains/sui/sui-api-endpoints/suix-get-balance

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| owner | string | Yes | The owner's Sui address. |
| coin_type | string | No | Fully qualified type name of the coin. If omitted, defaults to `0x2::sui::SUI`.  |

## Result

**result** (object): The balance data for the requested coin type.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "suix_getBalance",
  "params": [
    "0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6",
    "0x2::sui::SUI"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "coinType": "0x2::sui::SUI",
    "coinObjectCount": 5,
    "totalBalance": "5000000000",
    "lockedBalance": {}
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://sui-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "suix_getBalance",
  "params": [
    "0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6",
    "0x2::sui::SUI"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'suix_getBalance',
    params: [
      '0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6',
      '0x2::sui::SUI'
    ]
  })
};

fetch('https://sui-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://sui-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "suix_getBalance",
    "params": ["0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6", "0x2::sui::SUI"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://sui-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"suix_getBalance\",\n  \"params\": [\n    \"0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6\",\n    \"0x2::sui::SUI\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://sui-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"suix_getBalance\",\n  \"params\": [\n    \"0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6\",\n    \"0x2::sui::SUI\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://sui-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"suix_getBalance\",\n  \"params\": [\n    \"0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6\",\n    \"0x2::sui::SUI\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: suix_getBalance
summary: Get the total balance for a specific coin type
description: |
  Returns the total coin balance for a single coin type owned by the specified address. If no coin type is specified, defaults to the native SUI coin type.
params:
  - name: owner
    required: true
    description: The owner's Sui address.
    schema:
      type: string
  - name: coin_type
    required: false
    description: |
      Fully qualified type name of the coin. If omitted, defaults to `0x2::sui::SUI`.
    schema:
      type: string
result:
  name: result
  description: The balance data for the requested coin type.
  schema:
    type: object
    properties:
      coinType:
        type: string
        description: The coin type queried.
      coinObjectCount:
        type: integer
        description: Number of coin objects owned of the specified type.
      totalBalance:
        type: string
        description: Total balance in base units of the coin.
      lockedBalance:
        type: object
        description: Object describing any locked funds, if applicable.
examples:
  - name: Get balance for SUI coin
    params:
      - name: owner
        value: '0xe883a1df96561884e46d8e29cfb4e127bb6fd2719c33af1c16239a25a469e0a6'
      - name: coin_type
        value: 0x2::sui::SUI
    result:
      name: result
      value:
        coinType: 0x2::sui::SUI
        coinObjectCount: 5
        totalBalance: '5000000000'
        lockedBalance: {}
```
