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

# Export Analytics

> Export analytics data as CSV or JSON file

# Export Analytics

Exports detailed analytics data as a downloadable CSV or JSON file.

<Note>This endpoint is only accessible to users with `manager` or `admin` roles.</Note>

## Request

<ParamField header="Authorization" type="string" required>
  Bearer token from authentication
</ParamField>

<ParamField query="timeRange" type="string" default="30d">
  Time range for export. Options: `7d`, `30d`, `90d`
</ParamField>

<ParamField query="format" type="string" default="csv">
  Export format. Options: `csv`, `json`
</ParamField>

## Response

### CSV Format

Returns a CSV file with sections for:

* **Task Metrics**: Date, Tasks Created, Tasks Completed, Overdue Tasks
* **Mood Metrics**: Date, Average Score, Responses
* **Flag Metrics**: Date, Total Flags, Low, Medium, High, Critical

### JSON Format

Returns a JSON file with the following structure:

<ResponseField name="timeRange" type="string">
  The time range used for the export
</ResponseField>

<ResponseField name="generatedAt" type="string">
  ISO timestamp of when the export was generated
</ResponseField>

<ResponseField name="taskData" type="array">
  Daily task metrics: `{ date, created, completed, overdue }`
</ResponseField>

<ResponseField name="moodData" type="array">
  Daily mood metrics: `{ date, average, responses }`
</ResponseField>

<ResponseField name="flagData" type="array">
  Daily flag metrics: `{ date, total, low, medium, high, critical }`
</ResponseField>

<RequestExample>
  ```bash theme={null}
  # Export as CSV
  curl -X GET "https://api.hitler.app/analytics/export?timeRange=30d&format=csv" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -o analytics.csv

  # Export as JSON

  curl -X GET "https://api.hitler.app/analytics/export?timeRange=30d&format=json" \
   -H "Authorization: Bearer YOUR_TOKEN" \
   -o analytics.json

  ```
</RequestExample>

<ResponseExample>
  ```json JSON Response theme={null}
  {
    "timeRange": "30d",
    "generatedAt": "2026-02-05T10:30:00.000Z",
    "taskData": [
      { "date": "2026-01-06", "created": 12, "completed": 8, "overdue": 2 },
      { "date": "2026-01-07", "created": 15, "completed": 11, "overdue": 1 },
      ...
    ],
    "moodData": [
      { "date": "2026-01-06", "average": 3.5, "responses": 18 },
      { "date": "2026-01-07", "average": 3.7, "responses": 22 },
      ...
    ],
    "flagData": [
      { "date": "2026-01-06", "total": 2, "low": 1, "medium": 1, "high": 0, "critical": 0 },
      { "date": "2026-01-07", "total": 1, "low": 0, "medium": 0, "high": 1, "critical": 0 },
      ...
    ]
  }
  ```

  ```text CSV Response theme={null}
  Hitler Analytics Export - 30d
  Generated: 2026-02-05T10:30:00.000Z

  TASK METRICS
  Date,Tasks Created,Tasks Completed,Overdue Tasks
  2026-01-06,12,8,2
  2026-01-07,15,11,1
  ...

  MOOD METRICS
  Date,Average Score,Responses
  2026-01-06,3.5,18
  2026-01-07,3.7,22
  ...

  FLAG METRICS
  Date,Total Flags,Low,Medium,High,Critical
  2026-01-06,2,1,1,0,0
  2026-01-07,1,0,0,1,0
  ...
  ```
</ResponseExample>

## Use Cases

### Generating Reports

Export analytics to include in management reports or presentations.

```javascript theme={null}
// Download CSV for a quarterly review
const blob = await api.exportAnalytics({ timeRange: "90d", format: "csv" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "quarterly-analytics.csv";
link.click();
```

### Data Analysis

Export to JSON for further analysis in tools like Python, R, or Excel.

```bash theme={null}
# Download and analyze with jq
curl -s "https://api.hitler.app/analytics/export?format=json" \
  -H "Authorization: Bearer $TOKEN" \
  | jq '.taskData | map(.completed) | add'
```
