API Quickstart

This page shows you how to get started using the activities analytics API to query your data in mediarithmics.

Step 1 : Configure authentication

This quickstart guide uses the Long term access tokens authentication method. Choose and configure your own authentication method. For more information, see Authentication.

Step 2 : API call

POST https://api.mediarithmics.com/v1/datamarts/:datamartId/user_activities_analytics

Query Parameters

NameTypeDescription

datamartId*

number

The ID of the datamart to query

Request Body

NameTypeDescription

metrics*

array

Array of Metric to retrieve.

dimension_filter_clauses

object

Filters to apply on dimensions before calculating the metric. For more information, see FilterClause.

dimensions*

array

Dimensions to group metrics by.

date_ranges*

array

Periods to analyze. Each date range is an object with a start_date and an end_date. See DateRange.

{
    "status": "ok",
    "data": {
        "report_view": {
            "items_per_page": 100,
            "total_items": 7,
            "columns_headers": [
                "type"
            ],
            "rows": [
                [
                    "DISPLAY_AD"
                ],
                [
                    "EMAIL"
                ],
                [
                    "SITE_VISIT"
                ],
                [
                    "USER_SCENARIO_NODE_ENTER"
                ],
                [
                    "USER_SCENARIO_NODE_EXIT"
                ],
                [
                    "USER_SCENARIO_START"
                ],
                [
                    "USER_SCENARIO_STOP"
                ]
            ]
        }
    }
}

Here is a sample report request as body payload with all the important properties

{
    // Retrieve the data in the specified date range
    // Mandatory. The data is only queryable for the last 4 months
    // Only one range is allowed now, but the API is prepared to accept
    // multiple ranges in the future.
    // Tip : you can use dates in "now-Xd/d" format as in OTQL queries
    "date_ranges": [
        {
            "start_date": "2021-10-10T00:00:00",
            "end_date": "2021-10-25T23:59:59"
        }
    ],
    // List of dimensions to retrieve
    "dimensions": [
        {
            "name": "date_yyyy_mm_dd"
        },
        {
            "name": "channel_id"
        }
    ],
    // Filters on dimensions
    "dimension_filter_clauses": {
        "operator": "OR",
        "filters": [
            {
                "dimension_name": "type",
                "operator": "EXACT",
                "expressions": [
                    "SITE_VISIT"
                ]
            }
        ]
    },
    // Order by dates, beginning with the most recent
    "order_by": {
            "field_name": "-date_yyyy_mm_dd"
    },
    // List of metrics to retrieve
    "metrics": [
        {
            "expression": "users"
        },
          {
            "expression": "number_of_transactions"
        }
    ]
}

The API will answer with a Single resource wrapper containing a ReportView.

{
    "status": "ok",
    "data": {
        "report_view": {
            // Note : pagination not implemented yet
            "items_per_page": 100,
            "total_items": 100,
            // To know which data is in which column
            "columns_headers": [
                "date_yyyy_mm_dd",
                "channel_id",
                "users",
                "number_of_transactions"
            ],
            // Data
            "rows": [
                [
                    "2021-10-10",
                    666,
                    3881,
                    17800.0
                ],
                [
                    "2021-10-10",
                    555,
                    1838,
                    4200.0
                ],
                [
                    "2021-10-11",
                    666,
                    532,
                    3900.0
                ],
                [
                    "2021-10-11",
                    555,
                    8,
                    100.0
                ]
                // ...[
            ]
        }
    }
}

Congratulations! You've sent your first request to the Activities analytics API.

Last updated