GetAccountReport
Method Details​
Description: 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.
Required Roles: Check proto file for roles
Parameters:
AccountNumber(string): The Account Number for which the report is requested. Must be a 7-digit number starting with '1'.PeriodStart(message) (required): The start of the reporting period (inclusive). This field is required.PeriodEnd(message) (required): The end of the reporting period (inclusive). This field is required.ReportingAssetToken(message) (required): 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
Method Type: METHOD_TYPE_READ
Code Examples​
- Go
- Python
- Java
- Protobuf
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)
}
}
import datetime
from google.protobuf.timestamp_pb2 import Timestamp
from meshtrade.reporting.account_report.v1 import (
AccountReportService,
GetAccountReportRequest,
)
from meshtrade.type.v1.ledger_pb2 import LEDGER_STELLAR
from meshtrade.type.v1.token_pb2 import Token
def main():
# 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 = AccountReportService()
# It's a good practice to close the service client when you're done with it
# to release any underlying resources.
with service:
# Define the start and end dates for the report.
# In this example, we're requesting a report for the last 30 days.
end_date = datetime.datetime.now(datetime.UTC)
start_date = end_date - datetime.timedelta(days=30)
# Create Timestamps for the request
period_start_timestamp = Timestamp()
period_start_timestamp.FromDatetime(start_date)
period_end_timestamp = Timestamp()
period_end_timestamp.FromDatetime(end_date)
# Create a new GetAccountReportRequest.
# This request object is used to specify the parameters for the report.
request = GetAccountReportRequest(
# Specify the account for which to generate the report.
# Example: "12345"
account_number="100005",
# Specify the start and end dates for the report period.
# The dates are specified using the google.protobuf.Timestamp format.
period_start=period_start_timestamp,
period_end=period_end_timestamp,
# 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
reporting_asset_token=Token(
code="mZAR",
issuer="GCBNWTCCMC32UHZ5OCC2PNMFDGXRVPA7MFFBFFTCVW77SX5PMRB7Q4BY",
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.
account_report = service.get_account_report(request)
# 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.
print(f"Successfully generated report for account: {account_report.account_number}")
print(f"Report generated at: {account_report.generation_date.ToDatetime()}")
print(f"Number of income entries: {len(account_report.income_entries)}")
print(f"Number of fee entries: {len(account_report.fee_entries)}")
print(f"Number of trading statement entries: {len(account_report.trading_statement_entries)}")
# You can now iterate through the entries and process them.
# For example, to print the details of the first income entry:
if account_report.income_entries:
first_income = account_report.income_entries[0]
print(f"First income entry: {first_income}")
if __name__ == "__main__":
main()
import co.meshtrade.api.reporting.account_report.v1.AccountReportOuterClass.AccountReport;
import co.meshtrade.api.reporting.account_report.v1.AccountReportService;
import co.meshtrade.api.reporting.account_report.v1.Service.GetAccountReportRequest;
import co.meshtrade.api.type.v1.Token.Token;
import co.meshtrade.api.type.v1.Ledger.Ledger;
import com.google.protobuf.Timestamp;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Optional;
public class GetAccountReportExample {
public static void main(String[] args) {
// 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.
try (AccountReportService service = new AccountReportService()) {
// Define the start and end dates for the report.
// In this example, we're requesting a report for the last 30 days.
Instant endDate = Instant.now();
Instant startDate = endDate.minus(30, ChronoUnit.DAYS);
// Create Timestamps for the request.
Timestamp periodStartTimestamp = Timestamp.newBuilder().setSeconds(startDate.getEpochSecond()).build();
Timestamp periodEndTimestamp = Timestamp.newBuilder().setSeconds(endDate.getEpochSecond()).build();
// Create a new GetAccountReportRequest.
// This request object is used to specify the parameters for the report.
GetAccountReportRequest request =
GetAccountReportRequest.newBuilder()
// Specify the account for which to generate the report.
// Example: "12345"
.setAccountNumber("100005")
// Specify the start and end dates for the report period.
// The dates are specified using the com.google.protobuf.Timestamp format.
.setPeriodStart(periodStartTimestamp)
.setPeriodEnd(periodEndTimestamp)
// 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
.setReportingAssetToken(
Token.newBuilder()
.setCode("mZAR")
.setIssuer("GCBNWTCCMC32UHZ5OCC2PNMFDGXRVPA7MFFBFFTCVW77SX5PMRB7Q4BY")
.setLedger(Ledger.LEDGER_STELLAR)
.build())
.build();
// Call the GetAccountReport method to generate the report.
// This method sends the request to the Mesh API and returns the generated report.
AccountReport accountReport = service.getAccountReport(request, Optional.empty());
// 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.
System.out.println(
"Successfully generated report for account: " + accountReport.getAccountNumber());
System.out.println(
"Report generated at: "
+ Instant.ofEpochSecond(accountReport.getGenerationDate().getSeconds()));
System.out.println("Number of income entries: " + accountReport.getIncomeEntriesCount());
System.out.println("Number of fee entries: " + accountReport.getFeeEntriesCount());
System.out.println(
"Number of trading statement entries: " + accountReport.getTradingStatementEntriesCount());
// You can now iterate through the entries and process them.
// For example, to print the details of the first income entry:
if (accountReport.getIncomeEntriesCount() > 0) {
System.out.println("First income entry: " + accountReport.getIncomeEntries(0));
}
} catch (Exception e) {
System.err.println("GetAccountReport failed: " + e.getMessage());
e.printStackTrace();
}
}
}
syntax = "proto3";
package meshtrade.reporting.account_report.v1;
import "buf/validate/validate.proto";
import "google/protobuf/timestamp.proto";
import "meshtrade/iam/role/v1/role.proto";
import "meshtrade/option/v1/method_type.proto";
import "meshtrade/reporting/account_report/v1/account_report.proto";
import "meshtrade/type/v1/token.proto";
option go_package = "github.com/meshtrade/api/go/reporting/account_report/v1;account_report_v1";
option java_package = "co.meshtrade.api.reporting.account_report.v1";
/*
The AccountReportService provides endpoints for generating and exporting
comprehensive account activity reports.
Clients can use this service to retrieve structured reports containing income,
fees, and trading statements for a specified account and time period. All
financial values within the reports are denominated in a user-specified
reporting currency.
Access to all service methods requires appropriate Reporting domain permissions.
*/
service AccountReportService {
/*
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.
*/
rpc GetAccountReport(GetAccountReportRequest) returns (meshtrade.reporting.account_report.v1.AccountReport) {
option (meshtrade.option.v1.method_type) = METHOD_TYPE_READ;
option (meshtrade.iam.role.v1.roles) = {
roles: [
ROLE_REPORTING_ADMIN,
ROLE_REPORTING_VIEWER
]
};
}
/*
Exports an account report as a downloadable Excel file.
Generates the same report as GetAccountReport but returns it as a
base64-encoded string representing an Excel (.xlsx) file.
*/
rpc GetExcelAccountReport(GetExcelAccountReportRequest) returns (GetExcelAccountReportResponse) {
option (meshtrade.option.v1.method_type) = METHOD_TYPE_READ;
option (meshtrade.iam.role.v1.roles) = {
roles: [
ROLE_REPORTING_ADMIN,
ROLE_REPORTING_VIEWER
]
};
}
}
/*
Defines the parameters for requesting a structured account report.
*/
message GetAccountReportRequest {
option (buf.validate.message).cel = {
id: "period.chronological.get",
message: "period_end must be on or after period_start",
expression: "this.period_end > this.period_start"
};
/*
The Account Number for which the report is requested.
Must be a 7-digit number starting with '1'.
*/
string account_number = 1 [(buf.validate.field) = {
string: {
pattern: "^1[0-9]{6}$"
}
}];
/*
The start of the reporting period (inclusive). This field is required.
*/
google.protobuf.Timestamp period_start = 2 [(buf.validate.field).required = true];
/*
The end of the reporting period (inclusive). This field is required.
*/
google.protobuf.Timestamp period_end = 3 [(buf.validate.field).required = 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.
*/
meshtrade.type.v1.Token reporting_asset_token = 4 [(buf.validate.field).required = true];
}
/*
Defines the parameters for requesting an Excel export of an account report.
*/
message GetExcelAccountReportRequest {
option (buf.validate.message).cel = {
id: "period.chronological.excel",
message: "period_end must be on or after period_start",
expression: "this.period_end >= this.period_start"
};
/*
The Unique Mesh Account Number for which the report is requested.
Must be a 7-digit number starting with '1'.
*/
string account_number = 1 [(buf.validate.field) = {
string: {
pattern: "^1[0-9]{6}$"
}
}];
/*
The start of the reporting period (inclusive). This field is required.
*/
google.protobuf.Timestamp period_start = 2 [(buf.validate.field).required = true];
/*
The end of the reporting period (inclusive). This field is required.
*/
google.protobuf.Timestamp period_end = 3 [(buf.validate.field).required = true];
/*
The asset token used to valuate all financial data in the report.
This is typically a fiat stablecoin (e.g., mZAR or USDC) but can be any supported asset.
This field is required.
*/
meshtrade.type.v1.Token reporting_asset_token = 4 [(buf.validate.field).required = true];
}
/*
Contains the response for an Excel account report export.
*/
message GetExcelAccountReportResponse {
/*
The binary content of the generated Excel (.xlsx) report, encoded as a
base64 string.
*/
string excel_base64 = 1;
}
Advanced Configuration​
For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.
Other Methods​
- Reporting Account Report v1 Method List - For Other methods