Skip to content
Igor Balos edited this page Nov 13, 2017 · 2 revisions

You can retrieve many different statistics by API. Here are couple of examples on how statistics retrieval can be used.

For these API requests you will need to use a server API token. Once you obtain it, you will need to use server API client.

ApiClient client = Postmark.getApiClient(<server token>);

Listing outbound statistics.

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, - 365);
Date lastYear = cal.getTime();

// stats outbound
OutboundStats stats = client.getOutboundStats(Parameters.init().build("fromDate", lastYear));
System.out.println(stats.getBounced());

List sent email statistics.

// stats sent
OutboundSendStats statsSent = client.getOutboundSendStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsSent.getDays());

List bounced email statistics.

// stats bounce
OutboundBounceStats statsBounce = client.getOutboundBounceStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsBounce.getDays());

List spam email statistics.

// stats spam
OutboundSpamStats statsSpam = client.getOutboundSpamStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsSpam.getDays());

List clicked email statistics.

// stats tracked
OutboundTrackedStats statsTracked = client.getOutboundTrackedStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsTracked.getDays());

List opened email statistics.

// stats opens
OutboundOpenStats statsOpens = client.getOutboundOpenStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsOpens.getDays());

List opened platforms email statistics.

// stats open platforms
OutboundOpenPlatformStats statsOpenPlatoforms = client.getOutboundOpenPlatformStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsOpenPlatoforms.getDays());

List email open clients statistics.

// stats open clients
HashMap statsOpenClient = client.getOutboundOpenClientStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsOpenClient.get("Days"));

List email open read time statistics.

// stats open read times
HashMap statsOpenReadTimes = client.getOutboundOpenReadTimes(Parameters.init().build("fromDate", lastYear));
System.out.println(statsOpenReadTimes.get("Days"));

List email click detailed statistics.

// stats clicks
OutboundClickStats statsClicks = client.getOutboundClickStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsClicks.getDays().get(0).getClicks());

List email click browser usage statistics.

// stats clicks
HashMap statsClicksBrowserUsage = client.getOutboundClickBrowsersStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsClicksBrowserUsage.get("Days"));

List email click platform statistics.

// stats platform
OutboundClickPlatformStats statsClicksPlatform = client.getOutboundClickPlatformStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsClicksPlatform.getDays());

List email click location statistics.

// stats click location
System.out.println("STATS CLICKS LOCATION");
OutboundClickLocationStats statsClicksLocation = client.getOutboundClickLocationStats(Parameters.init().build("fromDate", lastYear));
System.out.println(statsClicksLocation.getDays());