Skip to content

list_token_balances

list_token_balances(
    token_filter: TokenFilter,
    *,
    config_overrides: Optional[ManagedBlockchainQueryClientConfig] = None,
    owner_filter: Optional[OwnerFilter] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[int] = None,
) -> ListTokenBalancesOutput

This action returns the following for a given blockchain network:

  • Lists all token balances owned by an address (either a contract address or a wallet address).

  • Lists all token balances for all tokens created by a contract.

  • Lists all token balances for a given token.

You must always specify the network property of the tokenFilter when using this operation.

Parameters:

  • owner_filter (Optional[OwnerFilter], default: None ) –

    The contract or wallet address on the blockchain network by which to filter the request. You must specify the address property of the ownerFilter when listing balances of tokens owned by the address.

  • token_filter (TokenFilter) –

    The contract address or a token identifier on the blockchain network by which to filter the request. You must specify the contractAddress property of this container when listing tokens minted by a contract.

    You must always specify the network property of this container when using this operation.

  • next_token (Optional[NextToken], default: None ) –

    The pagination token that indicates the next set of results to retrieve.

  • max_results (Optional[int], default: None ) –

    The maximum number of token balances to return.

    Default: 100

    Even if additional results can be retrieved, the request can return less results than maxResults or an empty array of results.

    To retrieve the next set of results, make another request with the returned nextToken value. The value of nextToken is null when there are no more results to return

Raises:

  • AccessDeniedException –

    The Amazon Web Services account doesn’t have access to this resource.

  • InternalServerException –

    The request processing has failed because of an internal error in the service.

  • ServiceQuotaExceededException –

    The service quota has been exceeded for this resource.

  • ThrottlingException –

    The request or operation couldn't be performed because a service is throttling requests. The most common source of throttling errors is when you create resources that exceed your service limit for this resource type. Request a limit increase or delete unused resources, if possible.

  • ValidationException –

    The resource passed is invalid.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_managedblockchain_query/_services/managed_blockchain_query.py
def list_token_balances(
    self,
    token_filter: "capo_managedblockchain_query.types.token_filter.TokenFilter",
    *,
    config_overrides: Optional[ManagedBlockchainQueryClientConfig] = None,
    owner_filter: Optional[
        "capo_managedblockchain_query.types.owner_filter.OwnerFilter"
    ] = None,
    next_token: Optional[
        "capo_managedblockchain_query.types.next_token.NextToken"
    ] = None,
    max_results: Optional[int] = None,
) -> "capo_managedblockchain_query.types.list_token_balances_output.ListTokenBalancesOutput":
    """<p>This action returns the following for a given blockchain network:</p> <ul> <li> <p>Lists all token balances owned by an address (either a contract address or a wallet address).</p> </li> <li> <p>Lists all token balances for all tokens created by a contract.</p> </li> <li> <p>Lists all token balances for a given token.</p> </li> </ul> <note> <p>You must always specify the network property of the <code>tokenFilter</code> when using this operation.</p> </note>

    Args:
        owner_filter: <p>The contract or wallet address on the blockchain network by which to filter the request. You must specify the <code>address</code> property of the <code>ownerFilter</code> when listing balances of tokens owned by the address.</p>
        token_filter: <p>The contract address or a token identifier on the blockchain network by which to filter the request. You must specify the <code>contractAddress</code> property of this container when listing tokens minted by a contract.</p> <note> <p>You must always specify the network property of this container when using this operation.</p> </note>
        next_token: <p>The pagination token that indicates the next set of results to retrieve.</p>
        max_results: <p>The maximum number of token balances to return.</p> <p>Default: <code>100</code> </p> <note> <p>Even if additional results can be retrieved, the request can return less results than <code>maxResults</code> or an empty array of results.</p> <p>To retrieve the next set of results, make another request with the returned <code>nextToken</code> value. The value of <code>nextToken</code> is <code>null</code> when there are no more results to return</p> </note>

    Raises:
        capo_managedblockchain_query.errors.access_denied_exception.AccessDeniedException: <p>The Amazon Web Services account doesn’t have access to this resource. </p>
        capo_managedblockchain_query.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an internal error in the service.</p>
        capo_managedblockchain_query.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service quota has been exceeded for this resource.</p>
        capo_managedblockchain_query.errors.throttling_exception.ThrottlingException: <p>The request or operation couldn't be performed because a service is throttling requests. The most common source of throttling errors is when you create resources that exceed your service limit for this resource type. Request a limit increase or delete unused resources, if possible.</p>
        capo_managedblockchain_query.errors.validation_exception.ValidationException: <p>The resource passed is invalid.</p>
        capo_managedblockchain_query.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_managedblockchain_query.types.list_token_balances_input.ListTokenBalancesInput]",
    ) -> OperationResponse[
        "capo_managedblockchain_query.types.list_token_balances_output.ListTokenBalancesOutput"
    ]:
        import capo_managedblockchain_query._operations.tieton_chain_query_service.list_token_balances

        output, http_response = (
            capo_managedblockchain_query._operations.tieton_chain_query_service.list_token_balances.list_token_balances(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListTokenBalances")
    )
    input_: capo_managedblockchain_query.types.list_token_balances_input.ListTokenBalancesInput = {
        "token_filter": token_filter
    }
    if owner_filter is not None:
        input_["owner_filter"] = owner_filter
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output