:doc:`ManagedBlockchainQuery <../../managedblockchain-query>` / Client / batch_get_token_balance

***********************
batch_get_token_balance
***********************



.. py:method:: ManagedBlockchainQuery.Client.batch_get_token_balance(**kwargs)

  

  Gets the token balance for a batch of tokens by using the ``BatchGetTokenBalance`` action for every token in the request.

   

  .. note::

    

    Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/managedblockchain-query-2023-05-04/BatchGetTokenBalance>`_  


  **Request Syntax**
  ::

    response = client.batch_get_token_balance(
        getTokenBalanceInputs=[
            {
                'tokenIdentifier': {
                    'network': 'ETHEREUM_MAINNET'|'ETHEREUM_SEPOLIA_TESTNET'|'BITCOIN_MAINNET'|'BITCOIN_TESTNET',
                    'contractAddress': 'string',
                    'tokenId': 'string'
                },
                'ownerIdentifier': {
                    'address': 'string'
                },
                'atBlockchainInstant': {
                    'time': datetime(2015, 1, 1)
                }
            },
        ]
    )
    
  :type getTokenBalanceInputs: list
  :param getTokenBalanceInputs: 

    An array of ``BatchGetTokenBalanceInputItem`` objects whose balance is being requested.

    

  
    - *(dict) --* 

      The container for the input for getting a token balance.

      

    
      - **tokenIdentifier** *(dict) --* **[REQUIRED]** 

        The container for the identifier for the token including the unique token ID and its blockchain network.

         

        .. note::

          

          Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.

          

        

      
        - **network** *(string) --* **[REQUIRED]** 

          The blockchain network of the token.

          

        
        - **contractAddress** *(string) --* 

          This is the token's contract address.

          

        
        - **tokenId** *(string) --* 

          The unique identifier of the token.

           

          .. note::

            

            For native tokens, use the 3 character abbreviation that best matches your token. For example, btc for Bitcoin, eth for Ether, etc. For all other token types you must specify the ``tokenId`` in the 64 character hexadecimal ``tokenid`` format.

            

          

        
      
      - **ownerIdentifier** *(dict) --* **[REQUIRED]** 

        The container for the owner identifier.

        

      
        - **address** *(string) --* **[REQUIRED]** 

          The contract or wallet address for the owner.

          

        
      
      - **atBlockchainInstant** *(dict) --* 

        The container for time.

        

      
        - **time** *(datetime) --* 

          The container of the ``Timestamp`` of the blockchain instant.

           

          .. note::

            

            This ``timestamp`` will only be recorded up to the second.

            

          

        
      
    

  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'tokenBalances': [
              {
                  'ownerIdentifier': {
                      'address': 'string'
                  },
                  'tokenIdentifier': {
                      'network': 'ETHEREUM_MAINNET'|'ETHEREUM_SEPOLIA_TESTNET'|'BITCOIN_MAINNET'|'BITCOIN_TESTNET',
                      'contractAddress': 'string',
                      'tokenId': 'string'
                  },
                  'balance': 'string',
                  'atBlockchainInstant': {
                      'time': datetime(2015, 1, 1)
                  },
                  'lastUpdatedTime': {
                      'time': datetime(2015, 1, 1)
                  }
              },
          ],
          'errors': [
              {
                  'tokenIdentifier': {
                      'network': 'ETHEREUM_MAINNET'|'ETHEREUM_SEPOLIA_TESTNET'|'BITCOIN_MAINNET'|'BITCOIN_TESTNET',
                      'contractAddress': 'string',
                      'tokenId': 'string'
                  },
                  'ownerIdentifier': {
                      'address': 'string'
                  },
                  'atBlockchainInstant': {
                      'time': datetime(2015, 1, 1)
                  },
                  'errorCode': 'string',
                  'errorMessage': 'string',
                  'errorType': 'VALIDATION_EXCEPTION'|'RESOURCE_NOT_FOUND_EXCEPTION'
              },
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **tokenBalances** *(list) --* 

        An array of ``BatchGetTokenBalanceOutputItem`` objects returned by the response.

        
        

        - *(dict) --* 

          The container for the properties of a token balance output.

          
          

          - **ownerIdentifier** *(dict) --* 

            The container for the owner identifier.

            
            

            - **address** *(string) --* 

              The contract or wallet address for the owner.

              
        
          

          - **tokenIdentifier** *(dict) --* 

            The container for the identifier for the token including the unique token ID and its blockchain network.

             

            .. note::

              

              Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.

              

            
            

            - **network** *(string) --* 

              The blockchain network of the token.

              
            

            - **contractAddress** *(string) --* 

              This is the token's contract address.

              
            

            - **tokenId** *(string) --* 

              The unique identifier of the token.

               

              .. note::

                

                For native tokens, use the 3 character abbreviation that best matches your token. For example, btc for Bitcoin, eth for Ether, etc. For all other token types you must specify the ``tokenId`` in the 64 character hexadecimal ``tokenid`` format.

                

              
        
          

          - **balance** *(string) --* 

            The container for the token balance.

            
          

          - **atBlockchainInstant** *(dict) --* 

            The container for time.

            
            

            - **time** *(datetime) --* 

              The container of the ``Timestamp`` of the blockchain instant.

               

              .. note::

                

                This ``timestamp`` will only be recorded up to the second.

                

              
        
          

          - **lastUpdatedTime** *(dict) --* 

            The container for time.

            
            

            - **time** *(datetime) --* 

              The container of the ``Timestamp`` of the blockchain instant.

               

              .. note::

                

                This ``timestamp`` will only be recorded up to the second.

                

              
        
      
    
      

      - **errors** *(list) --* 

        An array of ``BatchGetTokenBalanceErrorItem`` objects returned from the request.

        
        

        - *(dict) --* 

          Error generated from a failed ``BatchGetTokenBalance`` request.

          
          

          - **tokenIdentifier** *(dict) --* 

            The container for the identifier for the token including the unique token ID and its blockchain network.

             

            .. note::

              

              Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.

              

            
            

            - **network** *(string) --* 

              The blockchain network of the token.

              
            

            - **contractAddress** *(string) --* 

              This is the token's contract address.

              
            

            - **tokenId** *(string) --* 

              The unique identifier of the token.

               

              .. note::

                

                For native tokens, use the 3 character abbreviation that best matches your token. For example, btc for Bitcoin, eth for Ether, etc. For all other token types you must specify the ``tokenId`` in the 64 character hexadecimal ``tokenid`` format.

                

              
        
          

          - **ownerIdentifier** *(dict) --* 

            The container for the owner identifier.

            
            

            - **address** *(string) --* 

              The contract or wallet address for the owner.

              
        
          

          - **atBlockchainInstant** *(dict) --* 

            The container for time.

            
            

            - **time** *(datetime) --* 

              The container of the ``Timestamp`` of the blockchain instant.

               

              .. note::

                

                This ``timestamp`` will only be recorded up to the second.

                

              
        
          

          - **errorCode** *(string) --* 

            The error code associated with the error.

            
          

          - **errorMessage** *(string) --* 

            The message associated with the error.

            
          

          - **errorType** *(string) --* 

            The type of error.

            
      
    
  
  **Exceptions**
  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ThrottlingException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ValidationException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.InternalServerException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ServiceQuotaExceededException`

  