---
title: "client.analytics()"
description: "Every method in this namespace: its signature, its parameters, what it returns and an example."
url: "https://openemail.uk/docs/java/reference/analytics"
area: "Java"
category: "Reference"
---

# client.analytics()

Every method in this namespace: its signature, its parameters, what it returns and an example.

## Methods

The numbers behind the Analytics page: how mail arrives in the mailbox, and what became of the mail the workspace sent.

### `analytics().mailbox`

Read how mail arrives

```java
Map<String, Object> mailbox(RequestOptions options)
```

Returns how mail arrives, as the Analytics page of the app shows it, for a window, the last 30 days unless `from` and `to` say otherwise: how many conversations arrived and when, per `grain` bucket in `days` and per hour of the day in `hours`, the addresses they arrived at, the senders who wrote most, how many conversations wait on a reply for 1, 3 or 7 days or more, and the folders.

`days` is sparse: a bucket in which nothing arrived has no entry, so a chart must fill the gaps. `offsetMinutes` shifts the boundaries so days and hours break where the reader's do, and `series` holds the per bucket counts of the top addresses and senders so each can be charted.

A key limited to particular addresses counts only the mail that arrived at them, and `address` narrows everything to one address. An address the key does not reach counts nothing rather than failing.

Scopes: `threads:read`.

**Parameters**

- `options.from` (`Instant or String`): The start of the window. Defaults to 30 days before `to`.
- `options.to` (`Instant or String`): The end of the window. Defaults to now.
- `options.offsetMinutes` (`int`): Minutes east of UTC, from -840 to 840, defaulting to 0. Pass `ZonedDateTime.now().getOffset().getTotalSeconds() / 60` for the local zone.
- `options.grain` (`String`): Bucket width: `minute`, `hour` or `day`, defaulting to `day`.
- `options.address` (`String`): Count only the mail delivered to this address.
- `options.apiKey` (`String`): Overrides the client's API key for this call only.

**Returns**

A map with `object` set to `mailbox_insights`, `from`, `to`, `grain`, `offsetMinutes`, `scanned`, `days`, `hours`, `addresses`, `senders`, `senderCount`, `waiting`, `unattributed`, `folders` and `series`.

**Example**

```java
Map<String, Object> insights = client.analytics().mailbox(RequestOptions.of("offsetMinutes", 120));

System.out.println(insights.get("scanned") + " " + insights.get("senderCount") + " " + insights.get("senders"));
```

**Notes**

- Read only, so the SDK retries it after a network failure like any other read.
- `from` after `to` is a 422 `invalid_parameter`.

Also available in: API [`GET /analytics/mailbox`](https://openemail.uk/docs/api/reference/analytics#get-analytics-mailbox); TypeScript [`analytics.mailbox()`](https://openemail.uk/docs/sdk/reference/analytics#mailbox); Python [`analytics.mailbox()`](https://openemail.uk/docs/python/reference/analytics#mailbox); Ruby [`analytics.mailbox`](https://openemail.uk/docs/ruby/reference/analytics#mailbox); PHP [`analytics->mailbox`](https://openemail.uk/docs/php/reference/analytics#mailbox); Go [`Analytics.Mailbox`](https://openemail.uk/docs/go/reference/analytics#mailbox); C# [`Analytics.MailboxAsync`](https://openemail.uk/docs/csharp/reference/analytics#mailbox); CLI [`openemail analytics mailbox`](https://openemail.uk/docs/cli/reference/analytics#analytics-mailbox).

### `analytics().sending`

Read what became of sent mail

```java
Map<String, Object> sending(RequestOptions options)
```

Returns the numbers behind the Analytics page of the app: what the workspace sent inside a window and what became of it. `totals` adds up the sends, recipients and test sends and how many were delivered, failed, bounced, complained about, uncertain or still pending, `days` cuts sent, delivered, failed, bounced and complained to `grain` buckets, and `statuses`, `sources`, `senders` and `suppressed` break the window down.

The window is `days`, 30 by default and at most 365, or `minutes`, which wins when both are sent. It ends now, reported as `until`, and starts at the beginning of its oldest bucket, reported as `since`. `offsetMinutes` shifts the bucket boundaries so days break where the reader's do.

A key limited to particular addresses counts only the mail sent from them, and `address` narrows everything to one address.

Scopes: `emails:read`.

**Parameters**

- `options.days` (`int`): Window length in days, from 1 to 365, defaulting to 30.
- `options.minutes` (`int`): Window length in minutes, which wins over `days`.
- `options.offsetMinutes` (`int`): Minutes east of UTC, from -840 to 840, defaulting to 0.
- `options.grain` (`String`): Bucket width: `minute`, `hour` or `day`, defaulting to `day`.
- `options.address` (`String`): Count only the mail sent from this address.
- `options.apiKey` (`String`): Overrides the client's API key for this call only.

**Returns**

A map with `object` set to `sending_analytics`, `since`, `until`, `grain`, `offsetMinutes`, `totals`, `days`, `statuses`, `sources`, `senders` and `suppressed`.

**Example**

```java
Map<String, Object> analytics = client.analytics().sending(RequestOptions.of("days", 7));

System.out.println(analytics.get("totals"));
```

**Notes**

- Read only, so the SDK retries it after a network failure like any other read.

Also available in: API [`GET /analytics/sending`](https://openemail.uk/docs/api/reference/analytics#get-analytics-sending); TypeScript [`analytics.sending()`](https://openemail.uk/docs/sdk/reference/analytics#sending); Python [`analytics.sending()`](https://openemail.uk/docs/python/reference/analytics#sending); Ruby [`analytics.sending`](https://openemail.uk/docs/ruby/reference/analytics#sending); PHP [`analytics->sending`](https://openemail.uk/docs/php/reference/analytics#sending); Go [`Analytics.Sending`](https://openemail.uk/docs/go/reference/analytics#sending); C# [`Analytics.SendingAsync`](https://openemail.uk/docs/csharp/reference/analytics#sending); CLI [`openemail analytics sending`](https://openemail.uk/docs/cli/reference/analytics#analytics-sending).
