ListTokenBalances
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.
Note
You must always specify the network property of
the tokenFilter when using this operation.
Request Syntax
POST /list-token-balances HTTP/1.1
Content-type: application/json
{
"maxResults": number,
"nextToken": "string",
"ownerFilter": {
"address": "string"
},
"tokenFilter": {
"contractAddress": "string",
"network": "string",
"tokenId": "string"
}
}
URI Request Parameters
The request does not use any URI parameters.
Request Body
The request accepts the following data in JSON format.
- maxResults
-
The maximum number of token balances to return.
Default:
100Note
Even if additional results can be retrieved, the request can return less results than
maxResultsor an empty array of results.To retrieve the next set of results, make another request with the returned
nextTokenvalue. The value ofnextTokenisnullwhen there are no more results to returnType: Integer
Valid Range: Minimum value of 1. Maximum value of 250.
Required: No
- nextToken
-
The pagination token that indicates the next set of results to retrieve.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 131070.
Required: No
- ownerFilter
-
The contract or wallet address on the blockchain network by which to filter the request. You must specify the
addressproperty of theownerFilterwhen listing balances of tokens owned by the address.Type: OwnerFilter object
Required: No
- tokenFilter
-
The contract address or a token identifier on the blockchain network by which to filter the request. You must specify the
contractAddressproperty of this container when listing tokens minted by a contract.Note
You must always specify the network property of this container when using this operation.
Type: TokenFilter object
Required: Yes
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"nextToken": "string",
"tokenBalances": [
{
"atBlockchainInstant": {
"time": number
},
"balance": "string",
"lastUpdatedTime": {
"time": number
},
"ownerIdentifier": {
"address": "string"
},
"tokenIdentifier": {
"contractAddress": "string",
"network": "string",
"tokenId": "string"
}
}
]
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- nextToken
-
The pagination token that indicates the next set of results to retrieve.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 131070.
- tokenBalances
-
An array of
TokenBalanceobjects. Each object contains details about the token balance.Type: Array of TokenBalance objects
Array Members: Minimum number of 0 items. Maximum number of 250 items.
Errors
For information about the errors that are common to all actions, see Common Errors.
- AccessDeniedException
-
The AWS account doesn’t have access to this resource.
- message
-
The container for the exception message.
HTTP Status Code: 403
- InternalServerException
-
The request processing has failed because of an internal error in the service.
- message
-
The container for the exception message.
- retryAfterSeconds
-
Specifies the
retryAfterSecondsvalue.
HTTP Status Code: 500
- ServiceQuotaExceededException
-
The service quota has been exceeded for this resource.
- message
-
The container for the exception message.
- quotaCode
-
The container for the
quotaCode. - resourceId
-
The
resourceIdof the resource that caused the exception. - resourceType
-
The
resourceTypeof the resource that caused the exception. - serviceCode
-
The container for the
serviceCode.
HTTP Status Code: 402
- 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.
- message
-
The container for the exception message.
- quotaCode
-
The container for the
quotaCode. - retryAfterSeconds
-
The container of the
retryAfterSecondsvalue. - serviceCode
-
The container for the
serviceCode.
HTTP Status Code: 429
- ValidationException
-
The resource passed is invalid.
- fieldList
-
The container for the
fieldListof the exception. - message
-
The container for the exception message.
- reason
-
The container for the reason for the exception
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: