Source: https://datafa.st/docs/api-overview
Markdown source: https://datafa.st/docs/api-overview.md
Description: Get aggregate analytics metrics including pageviews, visitors, sessions, bounce rate, revenue, and conversion rate.

# Get site overview

`GET https://datafa.st/api/v1/analytics/overview`

Retrieve aggregate analytics metrics for your website. Requires [Bearer Token](/docs/api-introduction) authentication.

## Response

**Success (200 OK):** Returns aggregate metrics

```json
{
  "status": "success",
  "data": [
    {
      "visitors": 12450,
      "sessions": 16890,
      "bounce_rate": 65.32,
      "avg_session_duration": 245678.45,
      "currency": "$",
      "revenue": 28450,
      "revenue_per_visitor": 2.29,
      "conversion_rate": 1.15
    }
  ]
}
```

## Query Parameters

- **`startAt`** (string, optional): Start date in ISO 8601 format (e.g., `2024-01-01` or `2024-01-01T00:00:00Z`)
- **`endAt`** (string, optional): End date in ISO 8601 format (e.g., `2024-01-31` or `2024-01-31T23:59:59Z`)
- **`timezone`** (string, optional): Timezone in IANA format (e.g., `America/New_York`, `UTC`). Defaults to website timezone
- **`fields`** (string, optional): Comma-separated list of fields to return. Valid fields: `visitors`, `sessions`, `bounce_rate`, `avg_session_duration`, `currency`, `revenue`, `revenue_per_visitor`, `conversion_rate`. If not specified, all fields are returned.

## Notes

- **By default, if `startAt` and `endAt` are not provided, the endpoint returns all-time aggregated data**
- If only one of `startAt` or `endAt` is provided, the API returns a 400 error - both must be provided together
- Conversion rate is calculated as a percentage (e.g., 1.15 for 1.15%)

## Errors

- **400 Bad Request:** Invalid parameters or missing required parameters (e.g., only one of `startAt` or `endAt` provided)
- **401 Unauthorized:** Missing or invalid API key
- **404 Not Found:** Website not found
- **500 Internal Server Error:** Server-side issue

## Query parameters

### Optional parameters

- **`fields`** (string): Comma-separated list of fields to return. Valid fields: `visitors`, `sessions`, `bounce_rate`, `avg_session_duration`, `currency`, `revenue`, `revenue_per_visitor`, `conversion_rate`. If not specified, all fields are returned.

- **`startAt`** (string): Start date/time in ISO 8601 format (e.g., 2024-01-01T00:00:00Z or 2024-01-01). If omitted, returns all-time data

- **`endAt`** (string): End date/time in ISO 8601 format. Must be provided together with `startAt` if using custom date range

- **`timezone`** (string): Timezone for data aggregation (e.g., UTC, America/New_York, Europe/Amsterdam). Defaults to your website's timezone if not specified

## Code examples

### Example request (Node.js/Express)

```javascript
// Get all-time overview
const response = await fetch(
  "https://datafa.st/api/v1/analytics/overview",
  {
    method: "GET",
    headers: {
      Authorization: `Bearer ${DATAFAST_API_KEY}`,
      "Content-Type": "application/json",
    },
  }
);

const result = await response.json();

// Get overview for specific date range
const response2 = await fetch(
  "https://datafa.st/api/v1/analytics/overview?startAt=2024-01-01&endAt=2024-01-31&timezone=America/New_York",
  {
    method: "GET",
    headers: {
      Authorization: `Bearer ${DATAFAST_API_KEY}`,
      "Content-Type": "application/json",
    },
  }
);

const result2 = await response2.json();
```

### Success response (200 OK)

```json
{
  "status": "success",
  "data": [
    {
      "visitors": 12450,
      "sessions": 16890,
      "bounce_rate": 65.32,
      "avg_session_duration": 245678.45,
      "currency": "$",
      "revenue": 28450,
      "revenue_per_visitor": 2.29,
      "conversion_rate": 1.15
    }
  ]
}
```
