# Bitquery's Balance API

**URL:** <https://community.bitquery.io/t/bitquerys-balance-api/860>\
**Category:** GraphQL Tutorials\
**Created:** [February 23, 2022, 10:31am UTC](https://community.bitquery.io/t/bitquerys-balance-api/860 "2022-02-23T10:31:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbajpai](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@mbajpai](https://community.bitquery.io/u/mbajpai)\
**Post date:** [February 23, 2022, 10:31am UTC](https://community.bitquery.io/t/bitquerys-balance-api/860/1 "2022-02-23T10:31:07Z")

</div>

Bitquery’s tools and widgets allow you to query the token balance for Smart contract chains like Ethereum, Binance, Tron, Matic Bitcoin and Dogecoin, and other Bitcoin Platform Explorers like Bitcoin mainnet and Dogecoin etc.

In this tutorial we’ll explore some examples of how to get the token balances for the various different addresses with the queries and outputs.

First of all, we’ll take a look at the examples from the bitcoin platform explorers, i.e., the layer-1 blockchains such as Bitcoin, Dogecoin, Litecoin etc. Layer-1 scaling solutions augment the base layer of the blockchain protocol itself in order to improve scalability.

_Bitcoin Network_

Let’s see the query for the bitcoin network to get the balance for the address “bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh” .

```auto
{
  bitcoin(network: bitcoin) {
    inputs(inputAddress: {is: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"}) {
      value
      count
 
    }
    outputs(outputAddress: {is: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"}) {
      value
      count
     
    }
  }
}

```

You can even get this query here:

> **[Bitcoin address balance](https://graphql.bitquery.io/ide/Bitcoin-address-balance)**
>
> Bitquery is analytical engine for blockchains

_Dogecoin Network_

The query to get the balance of an address on another layer-1 blockchain network, Dogecoin can be written in a similar way, take a look!

```auto
{
  bitcoin(network: dogecoin) {
    inputs(inputAddress: {is: "DBs4WcRE7eysKwRxHNX88XZVCQ9M6QSUSz"}) {
      count
      value
      min_date: minimum(of: date)
      max_date: maximum(of: date)
    }
    outputs(outputAddress: {is: "DBs4WcRE7eysKwRxHNX88XZVCQ9M6QSUSz"}) {
      count
      value
      min_date: minimum(of: date)
      max_date: maximum(of: date)
 
    }
   
  }
 
}

```

You can get this query using the following link:

> **[Dogecoin address balance](https://graphql.bitquery.io/ide/Dogecoin-address-balance)**
>
> Bitquery is analytical engine for blockchains

Moving on, now we’ll take examples from the smart contract platform explorers. These are often called the Layer-2 networks. It refers to a network or technology that operates on top of an underlying blockchain protocol to improve its scalability and efficiency.

_Binance Smart Chain Network_

Let’s look at a query to get the balance of an address on the Binance network now.

```auto
{
  ethereum(network: bsc) {
    address(address: {is: "0x30cc0553f6fa1faf6d7847891b9b36eb559dc618"}) {
      balances {
        currency {
      	symbol
      	address
        }
        value
      }
    }
  }
}

```

_Ethereum Network_

We can get the balance for an address on the Ethereum network in a similar way.

```auto
{
  ethereum(network: ethereum) {
	address(address: {is: "0x2a20380dca5bc24d052acfbf79ba23e988ad0050"}) {
  	balances {
    	currency {
      	symbol
      	address
    	}
    	value
  	}
	}
  }
}

```

> **[Ethereum address balance](https://graphql.bitquery.io/ide/Ethereum-address-balance)**
>
> Bitquery is analytical engine for blockchains

As you can see, the queries to get the balance for a specific address on the Ethereum and bsc network different from those used to get the balances of addresses on the Bitcoin and Dogecoin etc. networks.

_Balances and History (Ethereum)_

You can even get the transfer history and balance of an address till a particular block. Let’s consider an example from the Ethereum network for the same. Here the address whose balance history we’re fetching is “0x30cc0553f6fa1faf6d7847891b9b36eb559dc618”

```auto
{
  ethereum(network: bsc) {
    address(address: {is: "0x30cc0553f6fa1faf6d7847891b9b36eb559dc618"}) {
      balances {
        currency {
      	address
      	symbol
      	tokenType
      	name
        }
        value
        history {
          timestamp
      	block
      	transferAmount
        }
      }
    }
  }
}

```

> **[Balance history for bsc address](https://graphql.bitquery.io/ide/Balance-history-for-bsc-address)**
>
> Bitquery is analytical engine for blockchains

_Polygon Matic Network_

Moving on with the smart contract platform explorers, let’s take a look at the Polygon matic network next for the address “0xfc5b1921938d5a2208b73bce72abb53d2aa215eb”

```auto
{
  ethereum(network: matic) {
    address(address: {is: "0xfc5b1921938d5a2208b73bce72abb53d2aa215eb"}) {
      balances {
        currency {
      	symbol
        }
        value
      }
    }
  }
}

```

Here the query is again similar to the ones that we have discussed for other networks like Bitcoin etc.

_Tron Network_

The query to get the balances of addresses on the tron network are a bit different. Let’s take the address “TKzDm2ZvmjgZipJxLesRkdtaJMJdu5VjzH” for example

```auto
{
  tron {
    fees: smartContractCalls(txFrom: {is: "TKzDm2ZvmjgZipJxLesRkdtaJMJdu5VjzH"}) {
      count
      fee
    }
    in: transfers(
      receiver: {is: "TKzDm2ZvmjgZipJxLesRkdtaJMJdu5VjzH"}
      currency: {is: "TRX"}
    ) {
      count
      amount
      currency {
        name
      }
    }
    out: transfers(sender: {is: "TKzDm2ZvmjgZipJxLesRkdtaJMJdu5VjzH"}, currency: {is: "TRX"}) {
      count
      amount
      currency {
        name
      }
    }
  }
}

```

_Avalanche Balance and History_

For the Avalanche network, we’ll try to find the balance and history for the address “0x28c65dcb3a5f0d456624aff91ca03e4e315bee49”.

```auto
{
  balance_of_avalanche: ethereum(network: avalanche){
    address(address: {is: "0x28c65dcb3a5f0d456624aff91ca03e4e315bee49"}){
      balances{
        value
        currency{
      	symbol
        }
      }
    }
  }
  balance_history_of_avalanche: ethereum(network: avalanche){
    address(address: {is: "0x28c65dcb3a5f0d456624aff91ca03e4e315bee49"}){
      balances{
        value
        currency{
      	symbol
        }
        history{
      	transferAmount
      	value
      	timestamp
        }
      }
    }
  }
}

```

You can get this query here:

[Avalanche balance and history (bitquery.io)](https://graphql.bitquery.io/ide/Avalanche-balance-and-history)

_Conclusion_

Bitquery’s Balance API supports various blockchains like Ethereum,Binance smart chain, Avalanche, Tron, Polygon Matic etc. You can easily calculate the balance of any address on various blockchains by simply using our Balance API.As you can see, the basic structure of the queries remains the same i.e.,

```auto
{
          	Blockchain(network: $network){
                         	Inputs(inputAddress:{is:$address}){
                                       	value
                         	}
                         	outputs(outputAddress: {is: $address}){
                                       	value
                         	}
          	}
}

```

To calculate the balance, you just need to add one line in the code of your webapp/ terminal

balance: subtract(outputs.value, inputs.value)

This is how easy it is to get balances of any given addresses across a plethora of blockchain networks using Bitquery.

Our Other DEX APIs are comprehensive and available for a number of blockchain networks are of great help in case you want to build DEX related tools or fetch data related to the DEXs.[Check out our APIs](https://graphql.bitquery.io/) today!!

If you have questions, you can also [contact us](https://bitquery.io/forms/api).

_Also Read_

· [Ethereum DEX GraphQL APIs with Examples - Bitquery](https://bitquery.io/blog/ethereum-dex-graphql-api)

· [Bitquery API integration with TradingView Technical Analysis Charts (DEX APIs)](https://community.bitquery.io/t/bitquery-api-integration-with-tradingview-technical-analysis-charts-dex-apis/244)

· [PancakeSwap - Querying DEXs on Binance Smart Chain using GraphQL APIs](https://bitquery.io/blog/pancake-swap-dex-apis)

· [Price Index for DEX Tokens - Bitquery](https://bitquery.io/blog/dex-price-index)

· [How to get started with Bitquery’s Blockchain GraphQL APIs? 1](https://community.bitquery.io/t/how-to-get-started-with-bitquerys-blockchain-graphql-apis/13)

_About Bitquery_

Bitquery is a set of software tools that parse, index, access, search, and use information across blockchain networks in a unified way. We are crossing the ‘chain-chasm’ by delivering set of products that can work across blockchains. Our products include:

[Coinpath](https://bitquery.io/products/coinpath?utm_source=blog) APIs provide blockchain [money flow](https://blog.bitquery.io/coinpath-blockchain-money-flow-apis) analysis for more than 24 blockchains. With Coinpath’s APIs, you can monitor blockchain transactions, investigate crypto crimes such as bitcoin money laundering, and create crypto forensics tools. You can refer to this article to get started with [Coinpath](https://blog.bitquery.io/coinpath-api-get-start)

[Digital Assets API](https://bitquery.io/products/digital_assets?utm_source=blog&utm_medium=about) provides index information related to all major cryptocurrencies, coins, and tokens.

[DEX API](https://bitquery.io/products/dex?utm_source=blog&utm_medium=about) provides real-time deposits and transactions, trades, and other related data on different DEX protocols like Uniswap, SushiSwap, Kyber Network, Airswap, Matching Network, etc.

If you have any questions about our products, ask them on our [Telegram channel](https://t.me/Bloxy_info) or email us at [hello@bitquery.io](mailto:hello@bitquery.io) . Also, subscribe to our newsletter and stay updated about the latest in the cryptocurrency world.
