# Token Holdings and Balance

{% hint style="warning" %}
Remember, for a given call to check the account holdings or an individual balance you need to be aware whether an account ID is valid for a given environment. As an example, the amount of accounts on testnet far exceeds that of mainnet, thus you may receive errors if you try to pass an incorrect accounts into different environments.
{% endhint %}

This returns back to Balance for a given token that belongs to a given account, you can use this as an alternative to balance lookups on mirror nodes, if balance requests are critical.

## Get Token Balance

<mark style="color:blue;">`GET`</mark> `https://hedera-serverless-consensus.vercel.app/api/account/:id/:token_id`

This endpoint allows you to get the token balance of a given account for a particular environment.

#### Path Parameters

| Name                                        | Type   | Description                |
| ------------------------------------------- | ------ | -------------------------- |
| <mark style="color:red;">\*</mark>          | String | account id in 0.0.x format |
| token\_id<mark style="color:red;">\*</mark> | String | token id in 0.0.x format   |

#### Query Parameters

| Name     | Type   | Description                         |
| -------- | ------ | ----------------------------------- |
| decimals | Number | Set the number of expected decimals |

{% tabs %}
{% tab title="200 Account balance response" %}

```
{
    "data": {
        "balance": "10000"
    }
}
```

{% endtab %}

{% tab title="401 Will ask to include a api-key, if invalid will return with "Unable to validate with the supplied 'x-api-key'"" %}

```
{
    "reason": "Please set \"x-api-key\" in your header"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Known issue: Account ID is not valid" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

Perhaps you just want to know whether an account holds particular tokens, this could be helpful if you are a building service that requires one or many tokens (like NFTs) to be held to unlock access to particular feature of your service.

## Get Account Holdings

<mark style="color:blue;">`GET`</mark> `https://hedera-serverless-consensus.vercel.app/api/account/:id/holdings/:token_ids`

This endpoint allows you to know if a given account holds many different tokens or NFTS.

#### Path Parameters

| Name                                         | Type   | Description                          |
| -------------------------------------------- | ------ | ------------------------------------ |
| <mark style="color:red;">\*</mark>           | String | account id in 0.0.x format           |
| token\_ids<mark style="color:red;">\*</mark> | String | token id in 0.0.x,0.0.y,0.0.z format |

{% tabs %}
{% tab title="200 Account balance response" %}

```
{
    "data": {
        "balance": "10000"
    }
}
```

{% endtab %}

{% tab title="401 Will ask to include a api-key, if invalid will return with "Unable to validate with the supplied 'x-api-key'"" %}

```
{
    "reason": "Please set \"x-api-key\" in your header"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Known issue: Account ID is not valid" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}
