# Get Wallet balance

This helps in getting the wallet balance with this method.&#x20;

## API Specification

## Get Wallet balance

<mark style="color:green;">`POST`</mark> `http://localhost:8889/wallet/getBalance`

Creates a new wallet under the given instance.&#x20;

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| walletId<mark style="color:red;">\*</mark> | String | wallet id   |
| chainId<mark style="color:red;">\*</mark>  | String | chainId     |

{% tabs %}
{% tab title="200: OK Success" %}
{% code overflow="wrap" %}

```javascript
{
  "Status": "SUCCESS",
  "Message": "",
  "Data": {
    "address": "xxxxxxxxxxxxxxxxx",
    "balance": 190909345505164350
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="417: Expectation Failed incorrect chain id" %}

```javascript
{
    "Status": "FAILURE",
    "Message": "mongo: no documents in result",
    "Data": null
}
```

{% endtab %}
{% endtabs %}

Take a look at how you might call this method using our official libraries, or via `curl`:

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

```bash
curl -X POST http://localhost:8889/wallet/getBalance \
-H "Content-Type: application/json" \
-d '{
  "walletId": "xxxxxxxxxxx",
  "chainId": "xxxxxxxxxxx"
}'
```

{% endtab %}

{% tab title="Node.js (Fetch)" %}

```javascript
const axios = require('axios');

const apiUrl = 'http://localhost:8889/wallet/getBalance';
const headers = {
  'Content-Type': 'application/json',
};

const requestData = {
  "walletId": "xxxxxxxxxxx",
  "chainId": "xxxxxxxxxxx"
};

axios.post(apiUrl, requestData, { headers })
  .then((response) => {
    console.log('Response:', response.data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

```

{% endtab %}

{% tab title="Python " %}

```python
import requests

url = 'http://localhost:8889/wallet/getBalance'

headers = {
    'Content-Type': 'application/json',
}

data = {
    "walletId": "xxxxxxxxxxx",
    "chainId": "xxxxxxxxxxx"
}

try:
    response = requests.post(url, json=data, headers=headers)
    response.raise_for_status()  # Raise an exception for 4xx or 5xx status codes

    print('Response:', response.json())
except requests.exceptions.RequestException as error:
    print('Error:', error)

```

{% endtab %}

{% tab title="Golang" %}

```go
package main

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

func main() {
	url := "http://localhost:8889/wallet/getBalance"
	method := "POST"  // Change method to POST

	payload := strings.NewReader(`{
		"walletId": "xxxxxxxxxxxxxxxxx",
		"chainId": "xxxx"
	}`)

	client := &http.Client{}
	req, err := http.NewRequest(method, url, payload)
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}
	req.Header.Add("Content-Type", "application/json")

	res, err := client.Do(req)
	if err != nil {
		fmt.Println("Error making request:", err)
		return
	}
	defer res.Body.Close()

	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		fmt.Println("Error reading response:", err)
		return
	}
	fmt.Println("Response:", string(body))
}

```

{% endtab %}
{% endtabs %}
