---
title: "Metric"
description: "<p>The Metric API provides access to a variety of metrics that are recorded</p><p>in the Lytics platform. With this API, you can access segment-size metrics,</p><p>events received per-hour, as well as many workflow specific metrics.</p>"
url: "https://www.contentstack.com/docs/developers/apis/lytics-api/v1/metric"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-05"
---

# Metric

The Metric API provides access to a variety of metrics that are recorded

in the Lytics platform. With this API, you can access segment-size metrics,

events received per-hour, as well as many workflow specific metrics.

## Metric

### Metric

**GET** `/api/metric/`

Fetch metrics by providing the arguments in the query-parameters

\`\`sh

curl "$LIOAPI/api/metric?keyspace=segsize&metric=web&name=my-metric" -s -H "Authorization: $LIOKEY" | jq '.'

\`\`

#### Query Parameters

- **account_id** (optional)
  Your Lytics account ID.
- **name** (optional)
  Name of the metric to return
- **dimension** (required)
  Value of supported dimension (segment, experience, stream, etc)
- **dimension_id** (required)
  ID for the specific item within dimension such as a segment ID. Tip: If the type is a segment you can use all\_segments as the dimension id to get all segments for the account.
- **dimension_type** (required)
  Type of metric to be returned (size, converted, etc)
- **aggregation** (optional)
  Aggregation to apply to metrics (sum, max, min)
- **interval** (optional)
  Duration to roll-up metrics (2h for roll-up into two-hour buckets). Intervals smaller than two hours are not recommended.
- **include_empty_rows** (optional)
  Passing true will include zero values in the response for every interval whether metrics were logged during that period or not.
- **smooth** (optional)
  Smooth metrics using a moving-average function
- **start_date** (optional)
  Fetch metrics after this date; both dates and relative-dates are supported
- **end_date** (optional)
  Fetch metrics before this date; both dates and relative-dates are supported
- **range** (optional)
  Time string used to calculate range from now (e.g "2h" will return the last 2 hours). This parameter cannot

be used in conjunction with start\_date and/or end\_date)

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "data": [
    {
      "name": "sample-request",
      "dimension": "segsize",
      "dimension_id": "abc123",
      "dimension_type": "size",
      "range": "2d",
      "aggregation": "max",
      "interval": "2h",
      "is_cached": true,
      "values": [
        {
          "value": 0,
          "ts": "1525231674371"
        },
        {
          "value": 100,
          "ts": "1525238874371"
        },
        {
          "value": 200,
          "ts": "1525246074371"
        },
        {
          "value": 300,
          "ts": "1525253274371"
        },
        {
          "value": 400,
          "ts": "1525260474371"
        },
        {
          "value": 500,
          "ts": "1525267674371"
        },
        {
          "value": 600,
          "ts": "1525274874371"
        },
        {
          "value": 700,
          "ts": "1525282074371"
        },
        {
          "value": 800,
          "ts": "1525289274371"
        },
        {
          "value": 900,
          "ts": "1525296474371"
        }
      ]
    }
  ],
  "message": "success",
  "status": 200
}
```

## Metric

### Metric

**POST** `/api/metric`

Fetch metrics by providing the arguments in the request body

\`\`sh

\# Example of segment-size metrics

curl -s -XPOST "$LIOAPI/api/metric" \\

\-H 'Content-type: application/json' \\

\-H "Authorization: $LIOKEY" \\

\-d '{

"dimension": "segsize",

"dimension\_id": "abc123",

"dimension\_type": "size",

"interval": "2h",

"aggregation": "max",

"start\_date": "now-5d",

"end\_date": "now",

"smooth": true

}' | jq '.'

\# Example request of data collected from the default and email stream

curl -s -XPOST "$LIOAPI/api/metric" \\

\-H "Content-type: application/json" \\

\-H "Authorization: $LIOKEY" \\

\-d '\[{

"dimension": "stream",

"dimension\_id": "default",

"dimension\_type": "size",

"interval": "1h",

"aggregation": "sum",

"start\_date": "now-1w",

"end\_date": "now"

},

{

"dimension": "stream",

"dimension\_id": "email",

"dimension\_type": "size",

"interval": "1h",

"aggregation": "sum",

"start\_date": "now-2w",

"end\_date": "now"

}\]' | jq '.'

\`\`

#### Query Parameters

- **account_id** (optional)
  Your Lytics account ID.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "data": [
    {
      "name": "sample-request",
      "dimension": "segsize",
      "dimension_id": "abc123",
      "dimension_type": "size",
      "range": "2d",
      "aggregation": "max",
      "interval": "2h",
      "is_cached": true,
      "values": [
        {
          "value": 0,
          "ts": "1525231674371"
        },
        {
          "value": 100,
          "ts": "1525238874371"
        },
        {
          "value": 200,
          "ts": "1525246074371"
        },
        {
          "value": 300,
          "ts": "1525253274371"
        },
        {
          "value": 400,
          "ts": "1525260474371"
        },
        {
          "value": 500,
          "ts": "1525267674371"
        },
        {
          "value": 600,
          "ts": "1525274874371"
        },
        {
          "value": 700,
          "ts": "1525282074371"
        },
        {
          "value": 800,
          "ts": "1525289274371"
        },
        {
          "value": 900,
          "ts": "1525296474371"
        }
      ]
    }
  ],
  "message": "success",
  "status": 200
}
```