Skip to main content

GetAccountByNumber

Retrieves an account using its Account Number.

Provides a convenient lookup method using the 7-digit account number. Optionally fetches live balance data when populate_ledger_data is true.

Method Options​

Authorisation specification of the GetAccountByNumber 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: GetAccountByNumberRequest Message​

FieldTypeRequiredDescription
AccountNumber

string

False

The Account Number. Must be a 7-digit number starting with '1'.

PopulateLedgerData

bool

False

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

Returns: Account Message​

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"
)

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()

// Look up account using its 7-digit Account Number
request := &accountv1.GetAccountByNumberRequest{
AccountNumber: "1234567", // 7-digit account number
PopulateLedgerData: true, // Fetch live blockchain data
}

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

// Display account information retrieved by number
log.Printf("Account found by number %s:", request.AccountNumber)
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)

// Display balances if live data was populated
if request.PopulateLedgerData && len(account.Balances) > 0 {
log.Printf(" Balances:")
for _, balance := range account.Balances {
log.Printf(" %s: %s",
balance.InstrumentMetadata.Name,
balance.Amount.Value)
}
}
}

Advanced Configuration​

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

Other Methods​