Analytics API
Access Salesforce Reports and Dashboards programmatically.
List Reports
Go
reports, err := client.Analytics().ListReports(ctx)
for _, report := range reports {
fmt.Printf("%s: %s\n", report.Name, report.ID)
}
Run Report (Synchronous)
Go
result, err := client.Analytics().RunReport(ctx, reportID, true) // includeDetails=true
fmt.Println("Total:", result.FactMap.GrandTotal)
Run Report (Async)
Go
instance, _ := client.Analytics().RunReportAsync(ctx, reportID)
// Poll for completion
result, _ := client.Analytics().GetReportInstance(ctx, reportID, instance.ID)
List Dashboards
Go
dashboards, err := client.Analytics().ListDashboards(ctx)
for _, dash := range dashboards {
fmt.Printf("%s (Folder: %s)\n", dash.Name, dash.FolderName)
}
Available Methods
| Method | Description |
|---|---|
ListReports() |
List all reports |
GetReport() |
Get report metadata |
RunReport() |
Run report synchronously |
RunReportAsync() |
Run report asynchronously |
GetReportInstance() |
Get async results |
ListDashboards() |
List dashboards |
GetDashboard() |
Get dashboard details |
RefreshDashboard() |
Refresh dashboard data |