# Reporting API

description: Access your revenue, traffic, and performance data programmatically via the Panxo Reporting API.

## Reporting API

The Reporting API gives publishers programmatic access to their revenue and traffic data. Use it to build custom dashboards, automate reporting, or integrate Panxo metrics into your existing analytics stack.

***

### Authentication

All requests require an API key passed via the `X-Panxo-API-Key` header.

```bash
curl -X GET https://api.panxo.com/api/v1/reporting/overview \
  -H "X-Panxo-API-Key: pk_your_api_key_here"
```

#### Getting your API key

{% stepper %}
{% step %}

### Log in

Log in to [app.panxo.com](https://app.panxo.com)
{% endstep %}

{% step %}

### Open API Keys

Go to **Settings > API Keys**
{% endstep %}

{% step %}

### Generate

Generate a new key (format: `pk_...`)
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Keep your API key secret. Do not expose it in client-side code or public repositories.
{% endhint %}

***

### Base URL

```
https://api.panxo.com/api/v1/reporting
```

***

### Endpoints

#### GET /overview

Returns aggregated metrics for your property over a given period.

**Query Parameters**

| Parameter | Type     | Required | Default | Description                             |
| --------- | -------- | -------- | ------- | --------------------------------------- |
| `period`  | `string` | No       | `30d`   | Time period. One of: `7d`, `30d`, `90d` |

**Request**

```bash
curl -X GET "https://api.panxo.com/api/v1/reporting/overview?period=30d" \
  -H "X-Panxo-API-Key: pk_your_api_key_here"
```

**Response**

```json
{
  "success": true,
  "period": "30d",
  "data": {
    "revenue": {
      "total": 1520.45,
      "currency": "USD"
    },
    "traffic": {
      "ai_visits": 48230,
      "human_visits": 892400,
      "ai_percentage": 5.12
    },
    "performance": {
      "rpm": 31.52,
      "fill_rate": 86.40
    }
  },
  "generated_at": "2026-02-02T14:30:00.000Z"
}
```

**Response Fields**

| Field                   | Type     | Description                                                     |
| ----------------------- | -------- | --------------------------------------------------------------- |
| `revenue.total`         | `number` | Total revenue in USD for the period                             |
| `revenue.currency`      | `string` | Always `USD`                                                    |
| `traffic.ai_visits`     | `number` | Total AI-influenced visits                                      |
| `traffic.human_visits`  | `number` | Total human visits                                              |
| `traffic.ai_percentage` | `number` | AI visits as percentage of total traffic                        |
| `performance.rpm`       | `number` | Average Revenue Per Mille (per 1,000 AI visits)                 |
| `performance.fill_rate` | `number` | Average fill rate (percentage of AI visits that received an ad) |

***

#### GET /daily

Returns a day-by-day breakdown of revenue and traffic metrics.

**Query Parameters**

| Parameter | Type     | Required | Default | Description                           |
| --------- | -------- | -------- | ------- | ------------------------------------- |
| `days`    | `number` | No       | `30`    | Number of days to return. Range: 1-90 |

**Request**

```bash
curl -X GET "https://api.panxo.ai/api/v1/reporting/daily?days=7" \
  -H "X-Panxo-API-Key: pk_your_api_key_here"
```

**Response**

```json
{
  "success": true,
  "days_requested": 7,
  "days_returned": 7,
  "data": [
    {
      "date": "2026-02-02",
      "revenue": 52.30,
      "ai_visits": 1650,
      "human_visits": 31200,
      "rpm": 31.70,
      "fill_rate": 87.20
    },
    {
      "date": "2026-02-01",
      "revenue": 48.15,
      "ai_visits": 1520,
      "human_visits": 29800,
      "rpm": 31.68,
      "fill_rate": 86.50
    }
  ],
  "generated_at": "2026-02-02T14:30:00.000Z"
}
```

**Response Fields (per day)**

| Field          | Type     | Description                 |
| -------------- | -------- | --------------------------- |
| `date`         | `string` | Date in `YYYY-MM-DD` format |
| `revenue`      | `number` | Revenue in USD for that day |
| `ai_visits`    | `number` | AI-influenced visits        |
| `human_visits` | `number` | Human visits                |
| `rpm`          | `number` | RPM for that day            |
| `fill_rate`    | `number` | Fill rate for that day      |

{% hint style="info" %}
Data is ordered by date descending (most recent first). Days with no traffic data are omitted from the response.
{% endhint %}

***

### Error Handling

#### Authentication Errors

```json
{
  "success": false,
  "error": "Invalid API key format. Key must start with pk_"
}
```

| HTTP Code | Error                           | Cause                                 |
| --------- | ------------------------------- | ------------------------------------- |
| `401`     | `Authentication required`       | Missing `X-Panxo-API-Key` header      |
| `401`     | `Invalid API key format`        | Key does not start with `pk_`         |
| `403`     | `Invalid or inactive API key`   | Key not found or property is inactive |
| `429`     | `Rate limit exceeded`           | Too many requests                     |
| `500`     | `Failed to fetch overview data` | Internal server error                 |

#### Response Structure

All responses follow the same structure:

**Success:**

```json
{
  "success": true,
  "data": { ... },
  "generated_at": "2026-02-02T14:30:00.000Z"
}
```

**Error:**

```json
{
  "success": false,
  "error": "Error description"
}
```

***

### Rate Limits

| Limit               | Value  |
| ------------------- | ------ |
| Requests per minute | 60     |
| Requests per day    | 10,000 |

Rate limit headers are included in responses:

```
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1706886000
```

***

### Code Examples

{% tabs %}
{% tab title="JavaScript" %}
{% code title="overview\.js" %}

```javascript
const API_KEY = 'pk_your_api_key_here';
const BASE_URL = 'https://api.panxo.ai/api/v1/reporting';

// Get 30-day overview
async function getOverview() {
  const response = await fetch(`${BASE_URL}/overview?period=30d`, {
    headers: { 'X-Panxo-API-Key': API_KEY }
  });
  return response.json();
}

// Get daily breakdown
async function getDailyReport(days = 30) {
  const response = await fetch(`${BASE_URL}/daily?days=${days}`, {
    headers: { 'X-Panxo-API-Key': API_KEY }
  });
  return response.json();
}

// Usage
const overview = await getOverview();
console.log(`Revenue: $${overview.data.revenue.total}`);
console.log(`AI Traffic: ${overview.data.traffic.ai_percentage}%`);
console.log(`RPM: $${overview.data.performance.rpm}`);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code title="overview\.py" %}

```python
import requests

API_KEY = 'pk_your_api_key_here'
BASE_URL = 'https://api.panxo.ai/api/v1/reporting'
HEADERS = {'X-Panxo-API-Key': API_KEY}

# Get 30-day overview
def get_overview(period='30d'):
    response = requests.get(
        f'{BASE_URL}/overview',
        params={'period': period},
        headers=HEADERS
    )
    return response.json()

# Get daily breakdown
def get_daily_report(days=30):
    response = requests.get(
        f'{BASE_URL}/daily',
        params={'days': days},
        headers=HEADERS
    )
    return response.json()

# Usage
overview = get_overview()
print(f"Revenue: ${overview['data']['revenue']['total']}")
print(f"AI Traffic: {overview['data']['traffic']['ai_percentage']}%")
print(f"RPM: ${overview['data']['performance']['rpm']}")
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code title="examples.sh" %}

```bash
# Overview (last 30 days)
curl -s "https://api.panxo.ai/api/v1/reporting/overview?period=30d" \
  -H "X-Panxo-API-Key: pk_your_api_key_here" | jq .

# Daily breakdown (last 7 days)
curl -s "https://api.panxo.ai/api/v1/reporting/daily?days=7" \
  -H "X-Panxo-API-Key: pk_your_api_key_here" | jq .
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

### Support

| Resource            | Link                                        |
| ------------------- | ------------------------------------------- |
| Publisher Dashboard | [app.panxo.ai](https://app.panxo.ai/)       |
| Technical Support   | <tech@panxo.ai>                             |
| API Status          | [status.panxo.ai](https://status.panxo.ai/) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.panxo.ai/dashboard-and-reporting/reporting-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
