Developing with Lytics / Lytics API Documentation

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.

Dimensions supported by the Metrics API.

DimensionDescription
experienceUsed to get metrics tied to a specific Lytics Experience. If Dimension = experience, then the Dimension ID must be the Experience ID. Metrics for this Dimension are saved every hour.
experiencegroupUsed to get metrics tied to a Lytics Experience-Group. If Dimension = experiencegroup, then the Dimension ID must be the Experience-Group ID. Metrics for this Dimension are saved every hour.
segmentUsed to get metrics tied to a Lytics Segment. If Dimension = segment, the the Dimension ID must be the Segment ID. Metrics for this Dimension are saved every 2 hours.
streamUsed to get metrics tied to a data stream. If Dimension = stream, the the Dimension ID must be the stream name. Metrics for this Dimension are saved at the top of every hour.

Dimension-Types supported by the Metrics API.

Dimension-TypeDescription
sizeReturns the raw value of the metric
potentialreachReturns the potential of an experience (only supported for metrics where Dimension = experience or experiencegroup)
actualreachReturns the conversion of an experience (only supported for metrics where Dimension = experience or experiencegroup)
conversionratevalue resulting from Actual/Potential reach (only supported for metrics where Dimension = experience or experiencegroup)

Aggreations supported by the Metrics API.

AggregationDescription
sumReturns the sum of values in an interval
maxReturns the max value in an interval
minReturns the min value in an interval

Metric

/api/metric

The Metric API provides access to a variety of metrics collected in the Lytics backend.

GET

Metric

/api/metric/{?dimension,dimension_id,dimension_type,startdate,enddate,aggregation,interval,name,smooth,range,include_empty_rows}

Fetch metrics by providing the arguments in the query-parameters

curl "$LIOAPI/api/metric?keyspace=segsize&metric=web&name=my-metric" -s -H "Authorization: $LIOKEY" | jq '.'
Parameters
namestring (optional)
Ex: my-metric
Name of the metric to return
dimensionstring (required)
Ex: segment
Value of supported dimension (segment, experience, stream, etc)
dimension_idstring (required)
Ex: abc123
ID for the specific item within diemsnion (segment-id)
dimension_typestring (required)
Ex: size
Type of metric to be returned (size, converted, etc)
aggregationstring (optional)
Ex: sum
Aggregation to apply to metrics (sum, max, min)
intervalstring (optional)
Ex: 2h
Duration to roll-up metrics (2h for roll-up into two-hour buckets). Intervals smaller than two hours are not recommended.
include_empty_rowsboolean (optional)
Ex: false
Passing true will include zero values in the response for every interval whether metrics were logged during that period or not.
smoothboolean (optional)
Ex: true
Smooth metrics using a moving-average function
startdatetime (optional)
Ex: now-5w
Fetch metrics after this date; both dates and relative-dates are supported
enddatetime (optional)
Ex: now-1w
Fetch metrics before this date; both dates and relative-dates are supported
rangestring (optional)
Ex: 2h
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)`

Response 200

Headers
Content-Type: application/json
Body
{
    "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
}
POST

Metric

/api/metric

Fetch metrics by providing the arguments in the request body

# 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",
            "startdate": "now-5d",
            "enddate": "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",
            "startdate": "now-1w",
            "enddate": "now"
        },
        {
            "dimension": "stream",
            "dimension_id": "email",
            "dimension_type": "size",
            "interval": "1h",
            "aggregation": "sum",
            "startdate": "now-2w",
            "enddate": "now"
        }]' | jq '.'

Request

Headers
Content-Type: application/json
Body
    {
        "dimension": "segsize",
        "dimension_id": "abc123",
        "dimension_type": "size",
        "interval": "2h",
        "aggregation": "max",
        "startdate": "now-2w",
        "enddate": "now"
    }

Response 200

Headers
Content-Type: application/json
Body
{
    "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
}