> ## Documentation Index
> Fetch the complete documentation index at: https://bunny.net/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Statistics API date ranges and granularity

> The date ranges the Statistics API endpoints accept, what they default to, and when you can request hourly data.

Every Statistics endpoint except for [Get DNS Query Statistics](/docs/api-reference/core/dns-zone/get-dns-query-statistics) takes the same three query parameters to shape the data it returns. `dateFrom` and `dateTo` set the range, and `hourly` picks the granularity. This page covers what each one does, what happens when you leave them out, and how far back each endpoint lets you look.

## Granularity and how far back you can go

Set `hourly=true` to get one data point per hour. Leave it out, or set `hourly=false`, to get one data point per day.

Hourly data covers the last 30 days. A request with `hourly=true` and a `dateFrom` older than 30 days fails with this error:

```
Cannot request hourly statistics older than 30 days. Use daily granularity instead.
```

Daily data covers the last year. A request with a `dateFrom` older than one year fails with this error:

```
Cannot request statistics older than 1 year.
```

Data older than one year isn't available through these endpoints at either granularity.

## Defaults when you omit the dates

* `hourly=true` with no dates returns the last 30 days.
* `hourly=false`, or no `hourly` parameter, with no dates returns data starting from the same day on the proceeding month.
* `dateFrom` on its own sets `dateTo` to now.

## How the API reads your dates

The API rounds the range to whole days. `dateFrom` rounds down to the start of its day and `dateTo` rounds up to the end of its day, so you get complete days back even when you pass a time of day.

`GET /statistics` also accepts `exactRange=true`, which keeps the hour components of `dateFrom` and `dateTo` as you sent them. It only takes effect together with `hourly=true`.

## Endpoint limits

| Endpoint                                                                                                | Route                                                     | Default range                               | Maximum range          | Oldest data                        |
| ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------------- | ---------------------- | ---------------------------------- |
| [Get Statistics](/docs/api-reference/core/statistics/get-statistics)                                         | `GET /statistics`                                         | Last 30 days (hourly) or last month (daily) | 40 days                | 30 days (hourly) or 1 year (daily) |
| [Get Statistics](/docs/api-reference/core/statistics/get-statistics) with `loadLatest=true`                  | `GET /statistics`                                         | None                                        | 1 day                  | None                               |
| [Get Optimizer Statistics](/docs/api-reference/core/statistics/get-optimizer-statistics)                     | `GET /pullzone/{pullZoneId}/optimizer/statistics`         | Last 30 days (hourly) or last month (daily) | The general rule above | 30 days (hourly) or 1 year (daily) |
| [Get Origin Shield Queue Statistics](/docs/api-reference/core/statistics/get-origin-shield-queue-statistics) | `GET /pullzone/{pullZoneId}/originshield/queuestatistics` | Last 30 days (hourly) or last month (daily) | The general rule above | 30 days (hourly) or 1 year (daily) |
| [Get SafeHop Statistics](/docs/api-reference/core/statistics/get-safehop-statistics)                         | `GET /pullzone/{pullZoneId}/safehop/statistics`           | Last 30 days (hourly) or last month (daily) | The general rule above | 30 days (hourly) or 1 year (daily) |

## Picking a range

For anything within the last 30 days that you want broken down by hour, set `hourly=true`. For anything older than that, and up to a year back, use daily granularity by leaving `hourly` out.
