> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.lootlabs.gg/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# LootLabs Statistics API

# 📊 LootLabs Statistics API Manual

Welcome to the **LootLabs Statistics API**. This API allows you to fetch reports and analytics related to your ad feeds using secure and structured requests. You can group your data, select date ranges, and retrieve only the columns you need.

---

## 🔐 Authentication

All requests must include an `api_token`, which authenticates your identity.  
You can find your API token in your [LootLabs dashboard](https://creators.lootlabs.gg) under **Profile Settings**.
[How do I get a LootLabs API Key?](https://help.lootlabs.gg/en/article/how-do-i-get-a-lootlabs-api-key-1ccz7zy/)

---

## 📎 Required Request Parameters

The following parameters are required in every request:

| Parameter | Required | Description |
| ---- |
| `api_token` | ✅ Yes | Your private API token. |
| `from_date` | ✅ Yes | Start date for the data query. Format: `yyyy-mm-dd` |
| `to_date` | ✅ Yes | End date for the data query. Format: `yyyy-mm-dd` |
| `feeds` | ✅ Yes | One or more Feed IDs, separated by commas (e.g. `000,001`) |
| `columns` | ✅ Yes | Data fields to include, separated by commas. See available options below. |
| `group_by` | ✅ Yes | How the data should be grouped. See grouping options below. |

---

## 📊 Available `columns` Values

You must specify one or more of the following columns to include in the response:

* `net_requests`: Valid, filtered ad requests.
* `gross_requests`: Total ad requests received.
* `total_impressions`: Ad impressions served.
* `total_revenue`: Revenue generated.

Example:
```
columns=total_revenue,net_requests
```

---

## 🧩 Grouping Options (`group_by`)

You must define how the data should be grouped:

* `country_code`: Group data by user country.
* `subid`: Group by Sub ID.
* `report_date`: Group by date.
* `feed`: Group by feed ID.

Example:
```
group_by=country_code
```

---

## 📥 GET Request Example

Make a GET request using URL query parameters:

```
https://creators.lootlabs.gg/api/public/reports?api_token=YOUR_API_TOKEN&feeds=000&from_date=2024-11-11&to_date=2024-11-17&columns=total_revenue,net_requests&group_by=feed
```

Replace `YOUR_API_TOKEN` with your actual API token.

---

## 📤 POST Request Example

You can also send the same request via POST with a JSON payload.

**URL:**
```
https://creators.lootlabs.gg/api/public/reports?api_token=YOUR_API_TOKEN
```

**Payload:**
```json
{
  "feeds": "000",
  "from_date": "2024-11-11",
  "to_date": "2024-11-17",
  "columns": [
    "total_revenue",
    "net_requests"
  ],
  "group_by": "feed"
}
```

---

## ✅ Sample Response

Here is an example of what a successful response looks like:

```json
{
  "type": "fetched",
  "request_time": 0,
  "message": {
    "columns": [
      "gross_requests",
      "net_requests"
    ],
    "count": 1,
    "results": [
      {
        "gross_requests": 0,
        "net_requests": 0,
        "feed": 000
      }
    ],
    "group_by": "feed",
    "from_date": "2024-11-11",
    "to_date": "2024-11-17",
    "feeds": [
      "000"
    ]
  }
}
```

## 📜 Fetching Your Feed Numbers

Before making report requests, you may need to know your **Feed IDs**.  
You can retrieve a list of your available feeds using the following endpoint:

**GET Request:**
```
https://creators.lootlabs.gg/api/public/reports/feeds?api_token=YOUR_API_TOKEN
```

Replace `YOUR_API_TOKEN` with your actual LootLabs API token.

---

### 📤 Example Response
```json
{
  "type": "fetched",
  "request_time": 0,
  "feeds": [
    {
      "_id": "000",
      "name": "Main Feed"
    },
    {
      "_id": "001",
      "name": "Secondary Feed"
    }
  ]
}
```

---

### 🔍 Response Fields
* `_id`: The numeric ID for your feed (use this in the `feeds` parameter for report queries).
* `name`: The descriptive name of the feed in your account.

### 🔎 Explanation of Response Fields

* `type`: Status of the response (`fetched`, `error`, etc.)
* `request_time`: Time taken to process the request (in seconds).
* `columns`: List of data fields returned.
* `count`: Number of result rows.
* `results`: List of grouped data.
* `group_by`: The grouping option used.
* `from_date` / `to_date`: The date range of the query.
* `feeds`: Feed IDs involved in the request.

---

## 📌 Notes

* Dates must be formatted as `yyyy-mm-dd`.
* All parameters are required.
* Use commas for multiple feeds or columns.
* The `group_by` value determines the shape of your data.
* If no data is found for your parameters, the `results` array will be empty.[
](#2-getting-your-api-token)
---

## 💬 Need Help?

If you experience issues or need support:
* Visit your LootLabs dashboard.
* Open a support ticket or use the live chat.
* Make sure to include your `api_token` and request details when reporting issues.

---
