Skip to main content

GetAccountReport

Retrieves a structured account report.

Generates a detailed report for the given account and time range, with all values denominated in the specified reporting asset token.

Method Options​

Authorisation specification of the GetAccountReport method.

TypeMETHOD_TYPE_READ
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_REPORTING_ADMIN
  • ROLE_REPORTING_VIEWER

Parameters​

Request and response parameter message overview:

Input: GetAccountReportRequest Message​

FieldTypeRequiredDescription
AccountNumber

string

False

The Account Number for which the report is requested. Must be a 7-digit number starting with '1'.

PeriodStart

google.protobuf.Timestamp

True

The start of the reporting period (inclusive). This field is required.

PeriodEnd

google.protobuf.Timestamp

True

The end of the reporting period (inclusive). This field is required.

ReportingAssetToken

meshtrade.type.v1.Token

True

The asset token used to valuate all financial data in the report. This is typically a fiat stablecoin (e.g., USDC) but can be any supported asset. This field is required.

Returns: AccountReport 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"
"fmt"
"log"
"time"

account_report_v1 "github.com/meshtrade/api/go/reporting/account_report/v1"
type_v1 "github.com/meshtrade/api/go/type/v1"
"google.golang.org/protobuf/types/known/timestamppb"
)

func main() {
// Create a new context, which is used to manage cancellation and deadlines
// for API calls.
ctx := context.Background()

// Create a new AccountReportService client.
// By default, the client will use the credentials from the MESH_API_CREDENTIALS
// environment variable or other default discovery methods.
// No specific configuration is required unless you need to customize client behavior.
service, err := account_report_v1.NewAccountReportService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
// It's a good practice to close the service client when you're done with it
// to release any underlying resources.
defer func() {
if err := service.Close(); err != nil {
log.Printf("failed to close the client: %v", err)
}
}()

// Define the start and end dates for the report.
// In this example, we're requesting a report for the last 30 days.
endDate := time.Now()
startDate := endDate.AddDate(0, 0, -30)

// Create a new GetAccountReportRequest.
// This request object is used to specify the parameters for the report.
request := &account_report_v1.GetAccountReportRequest{
// Specify the account for which to generate the report.
// Example: "12345"
AccountNumber: "100005",

// Specify the start and end dates for the report period.
// The dates are specified using the google.protobuf.Timestamp format.
PeriodStart: timestamppb.New(startDate),
PeriodEnd: timestamppb.New(endDate),

// Specify the reporting currency token - all report values will be denominated in this currency.
// This example uses mZAR (South African Rand) issued on the Stellar network.
// Learn more: https://mzar.mesh.trade
// Stellar Explorer: https://stellar.expert/explorer/public/asset/mZAR-GCBNWTCCMC32UHZ5OCC2PNMFDGXRVPA7MFFBFFTCVW77SX5PMRB7Q4BY
ReportingAssetToken: &type_v1.Token{
Code: "mZAR",
Issuer: "GCBNWTCCMC32UHZ5OCC2PNMFDGXRVPA7MFFBFFTCVW77SX5PMRB7Q4BY",
Ledger: type_v1.Ledger_LEDGER_STELLAR,
},
}

// Call the GetAccountReport method to generate the report.
// This method sends the request to the Mesh API and returns the generated report.
accountReport, err := service.GetAccountReport(ctx, request)
if err != nil {
log.Fatalf("GetAccountReport failed: %v", err)
}

// The response will contain the generated report data.
// In this example, we're simply printing some of the report's metadata.
// In a real-world application, you would likely process the entries of the report.
fmt.Printf("Successfully generated report for account: %s\n", accountReport.GetAccountNumber())
fmt.Printf("Report generated at: %s\n", accountReport.GetGenerationDate().AsTime().String())
fmt.Printf("Number of income entries: %d\n", len(accountReport.GetIncomeEntries()))
fmt.Printf("Number of fee entries: %d\n", len(accountReport.GetFeeEntries()))
fmt.Printf("Number of trading statement entries: %d\n", len(accountReport.GetTradingStatementEntries()))

// You can now iterate through the entries and process them.
// For example, to print the details of the first income entry:
if len(accountReport.GetIncomeEntries()) > 0 {
firstIncome := accountReport.GetIncomeEntries()[0]
fmt.Printf("First income entry: %+v\n", firstIncome)
}
}

Advanced Configuration​

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

Other Methods​