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

# Analytics

> Period-bucketed swap analytics — timelines, top pairs, protocol/chain breakdown

## Endpoint

```
GET /leokit/explorer/analytics
```

No authentication required. Cached for 5 minutes per period.

## Request

| Parameter | Type   | Required | Description                                            |
| --------- | ------ | -------- | ------------------------------------------------------ |
| `period`  | string | No       | One of `7d`, `30d` (default), `90d`, `6m`, `1y`, `all` |

The bucket size adapts to the period:

| Period           | Bucket size             |
| ---------------- | ----------------------- |
| `7d`–`90d`, `6m` | 1 day                   |
| `1y`, `all`      | 1 week (Monday-aligned) |

## Response

```json theme={null}
{
  "data": {
    "period": "30d",
    "generated_at": "2026-04-28T12:00:00.000Z",
    "summary": {
      "total_deposits": 51200,
      "total_quotes": 0,
      "total_volume_usd": 380120000.00,
      "total_fees_usd": 38012.45,
      "near_ecosystem_fees_usd": 18230.55,
      "conversion_rate": 0
    },
    "volume_timeline": [
      { "date": "2026-04-01", "count": 1820, "volume_usd": 12480921.55, "fees_usd": 1248.09 }
    ],
    "protocols": [
      { "name": "thorchain", "count": 18200, "volume_usd": 122480000.00, "success_rate": 1.0 }
    ],
    "top_pairs": [
      {
        "from_asset": "ETH.USDC-0xA0b...",
        "to_asset": "BTC.BTC",
        "count": 482,
        "volume_usd": 12480.55
      }
    ],
    "chains": [
      { "chain": "ETH", "source_count": 18402, "dest_count": 4820 }
    ]
  }
}
```

## Field Reference

#### Summary

| Field                     | Description                                                              |
| ------------------------- | ------------------------------------------------------------------------ |
| `total_deposits`          | Indexed swap count for the period                                        |
| `total_quotes`            | Currently always `0` (quote-level data is not part of the explorer feed) |
| `total_volume_usd`        | USD volume across the period                                             |
| `total_fees_usd`          | Sum of fees across the timeline (after merging NEAR ecosystem fees)      |
| `near_ecosystem_fees_usd` | NEAR-ecosystem fees received at `leodex.near` over the period            |
| `conversion_rate`         | Currently always `0` (no quote data merged here)                         |

#### `volume_timeline[]`

| Field        | Description                                                                      |
| ------------ | -------------------------------------------------------------------------------- |
| `date`       | Bucket start date (ISO `YYYY-MM-DD`). Weekly buckets are aligned to Monday       |
| `count`      | Swap count in the bucket (includes synthetic NEAR-ecosystem entries when merged) |
| `volume_usd` | USD volume in the bucket                                                         |
| `fees_usd`   | Affiliate fees in the bucket                                                     |

NEAR-ecosystem fee transfers are merged into the timeline by date: each transfer adds its `fee_usd` and `implied_volume_usd` (computed as `fee / 10 bps`) to the matching bucket.

#### `protocols[]`

| Field          | Description            |
| -------------- | ---------------------- |
| `name`         | Protocol slug          |
| `count`        | Swap count             |
| `volume_usd`   | USD volume             |
| `success_rate` | Currently always `1.0` |

The `near` row reflects the merged NEAR-ecosystem traffic (implied volume + on-chain swap count).

#### `top_pairs[]`

Top 10 trading pairs in the period, sorted by `volume_usd`.

#### `chains[]`

Per-chain `source_count` (swaps originating on the chain) and `dest_count` (swaps landing on the chain), sorted by total.

## Errors

| Status | Description                            |
| ------ | -------------------------------------- |
| `400`  | `period` not one of the allowed values |


## OpenAPI

````yaml /api-reference/openapi.json GET /explorer/analytics
openapi: 3.0.3
info:
  title: Leokit API
  version: 1.0.0
  description: API reference for Leokit
servers:
  - url: https://api.leokit.dev
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /explorer/analytics:
    get:
      summary: Explorer period analytics
      parameters:
        - name: period
          in: query
          required: false
          schema:
            type: string
            enum:
              - 7d
              - 30d
              - 90d
              - 6m
              - 1y
              - all
            default: 30d
      responses:
        '200':
          description: Period analytics with timeline, protocols, and chains.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExplorerAnalyticsResponse'
      security:
        - {}
components:
  schemas:
    ExplorerAnalyticsResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          properties:
            period:
              type: string
              enum:
                - 7d
                - 30d
                - 90d
                - 6m
                - 1y
                - all
            generated_at:
              type: string
              format: date-time
            summary:
              type: object
              properties:
                total_deposits:
                  type: integer
                total_quotes:
                  type: integer
                total_volume_usd:
                  type: number
                total_fees_usd:
                  type: number
                near_ecosystem_fees_usd:
                  type: number
                conversion_rate:
                  type: number
            volume_timeline:
              type: array
              items:
                type: object
                properties:
                  date:
                    type: string
                  count:
                    type: integer
                  volume_usd:
                    type: number
                  fees_usd:
                    type: number
            protocols:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                  count:
                    type: integer
                  volume_usd:
                    type: number
                  success_rate:
                    type: number
            top_pairs:
              type: array
              items:
                type: object
                properties:
                  from_asset:
                    type: string
                  to_asset:
                    type: string
                  count:
                    type: integer
                  volume_usd:
                    type: number
            chains:
              type: array
              items:
                type: object
                properties:
                  chain:
                    type: string
                  source_count:
                    type: integer
                  dest_count:
                    type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Api-Key
      description: 'Demo API-Key (Sandbox): 7037d2b3-9c76-4f62-b730-c544f7570fa4'

````