# Statistics

Statistics is a format which allows to make statistical operations (for example: sum) on underlying timeseries data.

## Example

### Request params

```json
{
    "report": "sending_stats",
    "filter": null,
    "aggregate_by": "campaign_id",
    "from": "2024-04-08T00:00:00.000-06:00",
    "to": "2024-04-25T00:00:00.000-06:00"
}
```

### Response
```json
{
    "range_timezone": "America/Denver",
    "series": [
        {
            "label": {
                "type": "out"
            },
            "value": 50
        },
        {
            "label": {
                "type": "in"
            },
            "value": 60
        }
    ],
    "result_type": "statistics",
    "interval": "1d",
    "effective_from": "2024-04-05T00:00:00.000-06:00",
    "effective_to": "2024-04-25T00:00:00.000-06:00"
}
```
## `from`, `to` request params

The `from` and `to` request params are optional, but we strongly suggest providing them for faster responses. When empty, data will be searched between customer's creation time and now.

When those params are provided, query:
* Will be executed to match requested timeframe using timeseries data from time buckets that were not deleted by retention yet.
* Will be executed over maximum of 150 time buckets. In case of query that queries more time buckets than 150, the greater time bucket resolution will be searched.

Time buckets with their retention are described here: [Timeseries#intervals](https://api.developer.placewise.com/doc-344256#intervals).

## Series

Single series consists of:
* `label` - an object which describes the series
* `value` - number which is produced via statistic operation

## Query limits

### Data points

Single query can include at most `100` data points.

Trying to fetch more than `100` data points **will not** return HTTP error. Returned data will be just limited to `100` data points. You can see how many data points were returned by the query via `data_points` response field.

In order to lower down number of data points, you need to use `filter` or `from`/`to` params to scope down the query.

## Timezones handling

See [Introduction#Timezones](https://docs.mpc.placewise.com/doc-343952#timezones)
