Skip to main content

SearchAccounts

Searches accounts using flexible text criteria within the hierarchy.

Performs case-insensitive substring matching on display names, returning accounts that match the search criteria.

Method Options​

Authorisation specification of the SearchAccounts method.

TypeMETHOD_TYPE_READ
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_WALLET_ADMIN
  • ROLE_WALLET_VIEWER
  • ROLE_WALLET_ACCOUNT_ADMIN
  • ROLE_WALLET_ACCOUNT_VIEWER

Parameters​

Request and response parameter message overview:

Input: SearchAccountsRequest Message​

FieldTypeRequiredDescription
Sorting
FieldTypeRequiredDescription
FieldstringFalseField to sort by. Supported values: "number" or empty string for default ordering.
Ordermeshtrade.type.v1.SortingOrderFalseSort order for results.
False

Optional sorting configuration.

DisplayName

string

False

Optional substring to search for in account display names. Case-insensitive partial matching.

PopulateLedgerData

bool

False

When true, fetches current balances and state from the ledger. When false, returns only stored metadata without live data.

Returns: SearchAccountsResponse Message​

FieldTypeDescription
Accounts

meshtrade.wallet.account.v1.Account[]

Collection of accounts matching the search criteria.

Code Examples​

Select supported SDK in the language of your choice for a full example of how to invoke the this method:

package main

import (
"context"
"log"

accountv1 "github.com/meshtrade/api/go/wallet/account/v1"
typev1 "github.com/meshtrade/api/go/type/v1"
)

func main() {
ctx := context.Background()

// Default configuration is used and credentials come from MESH_API_CREDENTIALS
// environment variable or default discovery methods. Zero config required
// unless you want custom configuration.
service, err := accountv1.NewAccountService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Search for accounts by display name substring
request := &accountv1.SearchAccountsRequest{
DisplayName: "Trading", // Search for accounts with "Trading" in name
PopulateLedgerData: false, // Set to true to fetch live blockchain data
Sorting: &accountv1.SearchAccountsRequest_Sorting{
Field: "number", // Sort by account number
Order: typev1.SortingOrder_SORTING_ORDER_DESC, // Descending order
},
}

// Call the SearchAccounts method
response, err := service.SearchAccounts(ctx, request)
if err != nil {
log.Fatalf("SearchAccounts failed: %v", err)
}

// Display search results
log.Printf("Found %d accounts matching '%s':", len(response.Accounts), request.DisplayName)
for _, account := range response.Accounts {
log.Printf(" Account %s:", account.Number)
log.Printf(" Name: %s", account.Name)
log.Printf(" Display Name: %s", account.DisplayName)
log.Printf(" Ledger: %s", account.Ledger)
log.Printf(" State: %s", account.State)
}
}

Advanced Configuration​

For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.

Other Methods​