Data Filters
Some read operations require additional parameters to filter the data returned from the network. Since the classes that define these parameters are auto-generated, they may not have the most idiomatic Kotlin names. To help with this, the SDK provides DSL-style builder functions to make it easier to create these parameter objects.
For example, to fetch fungible asset metadata, a FungibleAssetMetadataFilter object is required. You can create this
object using the fungibleAssetMetadataFilter builder function:
val filter = fungibleAssetMetadataFilter { assetType = stringFilter { eq = "0x1::aptos_coin::AptosCoin" }}This creates a filter that matches the AptosCoin asset type. You can then use this filter when calling the
getFungibleAssetMetadata method:
val metadata = aptos.getFungibleAssetMetadata(filter)The remainder of this document provides a comprehensive overview of the Domain-Specific Language (DSL) functions available for building type-safe where (filter) and order_by clauses for Aptos Indexer GraphQL queries.
Filter DSL Functions
Section titled “Filter DSL Functions”These functions are used to construct the where argument in a GraphQL query, allowing you to specify conditions for the data you want to retrieve.
Comparison Expression Builders
Section titled “Comparison Expression Builders”These are the fundamental building blocks used within entity filters. They create comparison expressions for primitive types like strings, integers, and booleans.
For Numeric and Timestamp Types
Section titled “For Numeric and Timestamp Types”The following builders share a common set of comparison operators for numeric and time-based values.
-
bigintFilter -
numericFilter -
intFilter -
timestampFilter -
Purpose: To create a comparison expression for
bigint,numeric,int, andtimestampfields, respectively. -
Parameters: Each function takes a lambda block where you can set the following comparison operators:
eq: Equal to.neq: Not equal to.gt: Greater than.gte: Greater than or equal to.lt: Less than.lte: Less than or equal to.inList: The value must be in the provided list.nin: The value must not be in the provided list.isNull:trueif the field should be null,falseotherwise.
For String Types
Section titled “For String Types”stringFilter- Purpose: Creates a rich comparison expression for
Stringfields. - Parameters: In addition to the common operators (
eq,neq,gt,gte,lt,lte,inList,nin,isNull), it supports advanced pattern matching: like: Case-sensitive pattern match (e.g.,_like: "aptos%").nlike: Case-sensitive negative pattern match.ilike: Case-insensitive pattern match.nilike: Case-insensitive negative pattern match.similar: SQLSIMILAR TOpattern match.nsimilar: SQLNOT SIMILAR TOpattern match.regex: POSIX regular expression match.nregex: POSIX negative regular expression match.iregex: Case-insensitive POSIX regular expression match.niregex: Case-insensitive negative POSIX regular expression match.
- Purpose: Creates a rich comparison expression for
For Boolean Types
Section titled “For Boolean Types”booleanFilter- Purpose: Creates a comparison expression for
Booleanfields. - Parameters: A lambda block where you can set the following simple operators:
eq: Equal to (trueorfalse).neq: Not equal to.isNull:trueif the field should be null.
- Purpose: Creates a comparison expression for
For JSON Types
Section titled “For JSON Types”jsonbFilter- Purpose: Creates a comparison expression for fields with the
jsonbtype, often used for unstructured properties. - Parameters: A lambda block with JSON-specific operators:
contains: Checks if the JSONB value contains the specified JSONB.containedIn: Checks if the JSONB value is contained within the specified JSONB.hasKey: Checks if the JSONB value has a specific top-level key.hasKeysAny: Checks if the JSONB value has any of the keys in the provided list.hasKeysAll: Checks if the JSONB value has all of the keys in the provided list.- Also supports common operators:
eq,neq,gt,gte,lt,lte,inList,nin,isNull.
- Purpose: Creates a comparison expression for fields with the
Entity Filter Builders
Section titled “Entity Filter Builders”These functions create filters for specific tables or views in the indexer. They all support and, or, and not functions to build complex logical queries.
authKeyAccountAddressesFilter: Filtersauth_key_account_addresses.- Fields:
accountAddress,authKey,isAuthKeyUsed,lastTransactionVersion.
- Fields:
currentAptosNamesFilter: Filterscurrent_aptos_names.- Fields:
domain,domainExpirationTimestamp,domainWithSuffix,expirationTimestamp,isActive,isPrimary,lastTransactionVersion,ownerAddress,registeredAddress,subdomain,subdomainExpirationPolicy,tokenName,tokenStandard.
- Fields:
currentCollectionsV2Filter: Filterscurrent_collections_v2.- Fields:
collectionId,collectionName,collectionProperties,creatorAddress,currentSupply,description,lastTransactionTimestamp,lastTransactionVersion,maxSupply,mutableDescription,mutableUri,tableHandleV1,tokenStandard,totalMintedV2,uri.
- Fields:
currentCollectionOwnershipV2ViewFilter: Filters thecurrent_collection_ownership_v2_view.- Fields:
collectionId,collectionName,collectionUri,creatorAddress,distinctTokens,lastTransactionVersion,ownerAddress,singleTokenUri.
- Fields:
currentFungibleAssetBalancesFilter: Filterscurrent_fungible_asset_balances.- Fields:
amount,assetType,isFrozen,isPrimary,lastTransactionTimestamp,lastTransactionVersion,metadata,ownerAddress,storageId,tokenStandard. Also includes V1/V2 specific versions likeamountV1,assetTypeV2, etc.
- Fields:
currentObjectsFilter: Filterscurrent_objects.- Fields:
allowUngatedTransfer,isDeleted,lastGuidCreationNum,lastTransactionVersion,objectAddress,ownerAddress,stateKeyHash.
- Fields:
currentTokenDatasV2Filter: Filterscurrent_token_datas_v2.- Fields:
collectionId,decimals,description,isDeletedV2,isFungibleV2,lastTransactionVersion,maximum,supply,tokenDataId,tokenName,tokenStandard,tokenUri,tokenProperties.
- Fields:
currentTokenOwnershipsV2Filter: Filterscurrent_token_ownerships_v2.- Fields:
amount,isFungibleV2,isSoulboundV2,lastTransactionVersion,ownerAddress,storageId,tokenDataId,tokenStandard.
- Fields:
currentTokenRoyaltyV1Filter: Filterscurrent_token_royalty_v1.- Fields:
lastTransactionVersion,payeeAddress,royaltyPointsDenominator,royaltyPointsNumerator,tokenDataId.
- Fields:
eventsFilter: Filtersevents.- Fields:
accountAddress,creationNumber,data,eventIndex,sequenceNumber,transactionVersion,type.
- Fields:
fungibleAssetActivitiesFilter: Filtersfungible_asset_activities.- Fields:
amount,assetType,blockHeight,eventIndex,ownerAddress,tokenStandard,transactionVersion,type.
- Fields:
fungibleAssetMetadataFilter: Filtersfungible_asset_metadata.- Fields:
assetType,creatorAddress,decimals,lastTransactionVersion,name,symbol,tokenStandard.
- Fields:
nftMetadataCrawlerParsedAssetUrisFilter: Filtersnft_metadata_crawler_parsed_asset_uris.- Fields:
assetUri,cdnAnimationUri,cdnImageUri,cdnJsonUri,rawAnimationUri,rawImageUri.
- Fields:
numActiveDelegatorPerPoolFilter: Filtersnum_active_delegator_per_pool.- Fields:
numActiveDelegator,poolAddress.
- Fields:
processorStatusFilter: Filtersprocessor_status.- Fields:
lastSuccessVersion,lastUpdated,processor.
- Fields:
publicKeyAuthKeysFilter: Filterspublic_key_auth_keys.- Fields:
accountPublicKey,authKey,isPublicKeyUsed,lastTransactionVersion,publicKey,publicKeyType,signatureType.
- Fields:
tableItemsFilter: Filterstable_items.- Fields:
key,tableHandle,transactionVersion, and nested JSONB filters fordecodedKeyanddecodedValue.
- Fields:
tableMetadatasFilter: Filterstable_metadatas.- Fields:
handle,keyType,valueType.
- Fields:
tokenActivitiesV2Filter: Filterstoken_activities_v2.- Fields:
afterValue,beforeValue,fromAddress,toAddress,tokenAmount,tokenDataId,transactionVersion,type.
- Fields:
Aggregate Filter Builders
Section titled “Aggregate Filter Builders”currentAptosNamesAggregateFiltercurrentTokenOwnershipsV2AggregateFilter- Purpose: Creates a filter for applying conditions on aggregated results.
- Parameters: A lambda block where you can use the following functions:
count(): Applies a predicate to the count of items.boolAnd(): Checks if a boolean condition is true for all items.boolOr(): Checks if a boolean condition is true for any item.
Order By DSL Functions
Section titled “Order By DSL Functions”These functions are used to construct the order_by argument in a GraphQL query, allowing you to specify the sorting of the results.
authKeyAccountAddressesOrder: Ordersauth_key_account_addresses.- Fields:
accountAddress,authKey,isAuthKeyUsed,lastTransactionVersion.
- Fields:
currentAptosNamesOrder: Orderscurrent_aptos_names.- Fields:
domain,expirationTimestamp,lastTransactionVersion,ownerAddress, etc.
- Fields:
currentFungibleAssetBalancesOrder: Orderscurrent_fungible_asset_balances.- Fields:
amount,assetType,lastTransactionTimestamp,ownerAddress, etc.
- Fields:
currentObjectsOrder: Orderscurrent_objects.- Fields:
allowUngatedTransfer,lastTransactionVersion,objectAddress,ownerAddress.
- Fields:
eventsOrder: Ordersevents.- Fields:
accountAddress,creationNumber,sequenceNumber,transactionVersion.
- Fields:
fungibleAssetMetadataOrder: Ordersfungible_asset_metadata.- Fields:
assetType,creatorAddress,decimals,name,symbol.
- Fields:
numActiveDelegatorPerPoolOrder: Ordersnum_active_delegator_per_pool.- Fields:
numActiveDelegator,poolAddress.
- Fields:
publicKeyAuthKeysOrder: Orderspublic_key_auth_keys.- Fields:
accountPublicKey,authKey,lastTransactionVersion,publicKey.
- Fields:
tableItemsOrder: Orderstable_items.- Fields:
decodedKey,decodedValue,key,tableHandle,transactionVersion.
- Fields:
tableMetadatasOrder: Orderstable_metadatas.- Fields:
handle,keyType,valueType.
- Fields: