GetExcelAccountReport
Method Details​
Description: Retrieves a structured account report for the given account, within the given time range denominated in the given reporting asset token, exported to an Excel file that can be downloaded.
Required Roles: Check proto file for roles
Parameters:
AccountNumber
(string) (required): Mesh account number for which the account report is requested.PeriodStart
(message) (required): Start of the reporting period (inclusive).PeriodEnd
(message) (required): End of the reporting period (inclusive).ReportingAssetToken
(message) (required): Reporting Asset Token is the asset token in which assets/transactions will be valuated. This will typically refer to some fiat currency stablecoin, but could also refer to another currency such as a crypto currency XLM, BTC etc.
Returns: GetExcelAccountReportResponse
Method Type: METHOD_TYPE_READ
Code Examples​
- Go
- Python
- Java
- Protobuf
package main
import (
"context"
"encoding/base64"
"fmt"
"log"
"os"
"time"
"google.golang.org/protobuf/types/known/timestamppb"
accountreportv1 "github.com/meshtrade/api/go/reporting/account_report/v1"
typev1 "github.com/meshtrade/api/go/type/v1"
)
// main is the entry point of the program.
// It demonstrates how to use the AccountReportService to retrieve an account report in Excel format.
func main() {
// Create a new AccountReportService client.
// In a real-world application, you would typically configure this with proper authentication and connection details.
// For this example, we assume the service is available at "localhost:8080" and we are using an insecure connection.
service, err := accountreportv1.NewAccountReportService()
if err != nil {
log.Fatalf("Failed to create AccountReportService client: %v", err)
}
defer func() {
if err := service.Close(); err != nil {
log.Printf("Failed to close service connection: %v", err)
}
}()
// Create a request to get an Excel account report.
// The request includes the account number and the desired date range for the report.
req := &accountreportv1.GetExcelAccountReportRequest{
AccountNumber: "100005",
PeriodStart: timestamppb.New(time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)),
PeriodEnd: timestamppb.New(time.Date(2023, 12, 31, 0, 0, 0, 0, time.UTC)),
// 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: &typev1.Token{
Code: "mZAR",
Issuer: "GCBNWTCCMC32UHZ5OCC2PNMFDGXRVPA7MFFBFFTCVW77SX5PMRB7Q4BY",
Ledger: typev1.Ledger_LEDGER_STELLAR,
},
}
// Call the GetExcelAccountReport method to retrieve the report.
// The context.Background() is used as a default context.
response, err := service.GetExcelAccountReport(context.Background(), req)
if err != nil {
log.Fatalf("Failed to get Excel account report: %v", err)
}
// The response contains the Excel file content as a base64-encoded string.
// We need to decode it before we can save it as a file.
excelData, err := base64.StdEncoding.DecodeString(response.ExcelBase64)
if err != nil {
log.Fatalf("Failed to decode base64 response: %v", err)
}
// Define the name for the output Excel file.
fileName := "account_report.xlsx"
// Save the decoded Excel data to a file.
// We use os.WriteFile which is the recommended way to write files in Go 1.16+
// 0644 is the standard file permission for a file that is readable by everyone and writable by the owner.
if err := os.WriteFile(fileName, excelData, 0644); err != nil {
log.Fatalf("Failed to write Excel file: %v", err)
}
fmt.Printf("Successfully saved Excel report to %s\n", fileName)
}
import base64
import datetime
from google.protobuf.timestamp_pb2 import Timestamp
from meshtrade.reporting.account_report.v1 import (
AccountReportService,
GetExcelAccountReportRequest,
)
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.
start_date = datetime.datetime(2023, 1, 1, tzinfo=datetime.UTC)
end_date = datetime.datetime(2023, 12, 31, tzinfo=datetime.UTC)
# 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 request to get an Excel account report.
# The request includes the account number and the desired date range for the report.
request = GetExcelAccountReportRequest(
account_number="100005",
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 GetExcelAccountReport method to retrieve the report.
response = service.get_excel_account_report(request)
# The response contains the Excel file content as a base64-encoded string.
# We need to decode it before we can save it as a file.
excel_data = base64.b64decode(response.excel_base64)
# Define the name for the output Excel file.
file_name = "account_report.xlsx"
# Save the decoded Excel data to a file.
with open(file_name, "wb") as f:
f.write(excel_data)
print(f"Successfully saved Excel report to {file_name}")
if __name__ == "__main__":
main()
import co.meshtrade.api.reporting.account_report.v1.AccountReportService;
import co.meshtrade.api.reporting.account_report.v1.Service.GetExcelAccountReportRequest;
import co.meshtrade.api.reporting.account_report.v1.Service.GetExcelAccountReportResponse;
import co.meshtrade.api.type.v1.Token.Token;
import co.meshtrade.api.type.v1.Ledger.Ledger;
import com.google.protobuf.Timestamp;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Base64;
import java.util.Optional;
// main is the entry point of the program.
// It demonstrates how to use the AccountReportService to retrieve an account report in Excel format.
public class GetExcelAccountReportExample {
public static void main(String[] args) {
// Create a new AccountReportService client.
// In a real-world application, you would typically configure this with proper authentication and connection details.
// For this example, we assume the service is available at "localhost:8080" and we are using an insecure connection.
try (AccountReportService service = new AccountReportService()) {
// Define the start and end dates for the report.
Instant startDate = Instant.parse("2023-01-01T00:00:00Z");
Instant endDate = Instant.parse("2023-12-31T00:00:00Z");
// Create Timestamps for the request.
Timestamp periodStartTimestamp = Timestamp.newBuilder().setSeconds(startDate.getEpochSecond()).build();
Timestamp periodEndTimestamp = Timestamp.newBuilder().setSeconds(endDate.getEpochSecond()).build();
// Create a request to get an Excel account report.
// The request includes the account number and the desired date range for the report.
GetExcelAccountReportRequest request =
GetExcelAccountReportRequest.newBuilder()
.setAccountNumber("100005")
.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 GetExcelAccountReport method to retrieve the report.
// The Optional.empty() is used as a default context.
GetExcelAccountReportResponse response = service.getExcelAccountReport(request, Optional.empty());
// The response contains the Excel file content as a base64-encoded string.
// We need to decode it before we can save it as a file.
byte[] excelData = Base64.getDecoder().decode(response.getExcelBase64());
// Define the name for the output Excel file.
String fileName = "account_report.xlsx";
// Save the decoded Excel data to a file.
// We use Files.write which is the recommended way to write files in Java.
Files.write(Paths.get(fileName), excelData);
System.out.printf("Successfully saved Excel report to %s\n", fileName);
} catch (Exception e) {
System.err.println("Failed to get Excel account report: " + 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_reportv1";
option java_package = "co.meshtrade.api.reporting.account_report.v1";
/*
AccountReportService manages comprehensive account activity report generation and export.
This service allows clients to retrieve structured account reports containing
income entries, fee transactions, and trading statements, as well as download
them as Excel files. Reports are generated for a specified account over a
given time range with all values denominated in the account's reporting currency.
All operations require Reporting domain permissions and operate within
the authenticated group context.
*/
service AccountReportService {
/*
Retrieves a structured account report for the given account, within the given time range
denominated in the given reporting asset token.
*/
rpc GetAccountReport(GetAccountReportRequest) returns (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
]
};
}
/*
Retrieves a structured account report for the given account, within the given time range
denominated in the given reporting asset token, exported to an Excel file that can be downloaded.
*/
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
]
};
}
}
message GetAccountReportRequest {
/*
Mesh account number for which the account report is requested.
*/
string account_number = 1;
/*
Start of the reporting period (inclusive).
*/
google.protobuf.Timestamp period_start = 2;
/*
End of the reporting period (inclusive).
*/
google.protobuf.Timestamp period_end = 3;
/*
Reporting Asset Token is the asset token in which assets/transactions will be valuated.
This will typically refer to some fiat currency stablecoin, but could also refer to another currency
such as a crypto currency XLM, BTC etc.
*/
meshtrade.type.v1.Token reporting_asset_token = 4;
}
message GetExcelAccountReportRequest {
/*
Mesh account number for which the account report is requested.
*/
string account_number = 1 [(buf.validate.field) = {
string: {
min_len: 1
pattern: "^[0-9]{1,}$"
}
cel: {
id: "account_number.required"
message: "account_number is required"
expression: "this.matches('^[0-9]{1,}$')"
}
}];
/*
Start of the reporting period (inclusive).
*/
google.protobuf.Timestamp period_start = 2 [(buf.validate.field).cel = {
id: "period_start.required"
message: "'period_start' timestamp is required"
expression: "this != null"
}];
/*
End of the reporting period (inclusive).
*/
google.protobuf.Timestamp period_end = 3 [(buf.validate.field).cel = {
id: "period_end.required"
message: "'period_end' timestamp is required"
expression: "this != null"
}];
/*
Reporting Asset Token is the asset token in which assets/transactions will be valuated.
This will typically refer to some fiat currency stablecoin, but could also refer to another currency
such as a crypto currency XLM, BTC etc.
*/
meshtrade.type.v1.Token reporting_asset_token = 4;
}
message GetExcelAccountReportResponse {
/*
Base64-encoded binary content of the Excel report file.
*/
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