{"openapi": "3.0.1", "info": {"title": "Analytics HTTP API", "description": "**Authentication is required** to access any of the\nfollowing endpoints. Please see [Authorization](../../platform/getting_started.html)\ndocumentation for more details.\n\nAvailable columns and transformations are listed in the\n[Columns](../columns.html) documentation.\n", "version": "16.34"}, "servers": [{"url": "https://your-instance-name.piwik.pro/"}], "paths": {"/api/analytics/v1/query/": {"post": {"tags": ["Queries"], "summary": "Execute query", "description": "API that allows querying the database directly. Please note that each\nrequest must be authenticated.\n\n#### Copy definition\n\nYou can use the **View API call definition** option\navailable in Analytics module in each report to get more\nusage examples based on your existing reports.\n\n![View API call definition](../../static/images/copy-api-call.png)\n\n\n#### Compression\n\nWhen requesting large amount of data, make sure to include\nan **Accept-Encoding: gzip** header to enable\ncompression.\n\n\n#### Cache\n\nPlease note that all query results are cached for 10 minutes.\n", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "properties": {"website_id": {"type": "string", "format": "uuid", "description": "ID of a website or a meta site.", "example": "70236925-724f-404e-b634-7b5633bc0bcc"}, "columns": {"type": "array", "description": "Column definitions for the query.", "items": {"type": "object", "properties": {"column_id": {"type": "string", "description": "ID of the column (either a dimension or a metric)."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by the\ncolumn that was specified.\n"}, "goal_id": {"type": "integer", "description": "Optional ID of a goal. Available only for metrics related to goals.\n"}}, "required": ["column_id"]}, "example": [{"column_id": "device_type"}, {"column_id": "revenue", "transformation_id": "sum"}]}, "date_from": {"type": "string", "format": "date", "description": "Start date for the query (inclusive). Cannot be used with relative_date field at the same time. Mandatory if ``relative_date`` is not used."}, "date_to": {"type": "string", "format": "date", "description": "End date for the query (inclusive). Cannot be used with ``relative_date`` field at the same time. Mandatory if ``relative_date`` is not used."}, "relative_date": {"type": "string", "enum": ["today", "yesterday", "last_week", "last_month", "last_year", "last_X_days"], "description": "Use relative date in query. Cannot be used with absolute date fields at\nthe same time. ``X`` in ``last_X_days`` must be in range 1 <= ``X`` <= 365.\nNote that ``last_X_days`` does not include data from today.\nMandatory if absolute date fields are not used.\n"}, "filters": {"type": "object", "description": "Dimension filters for the query. The top-level object must specify\nAND/OR clause, but any nested objects may either specify another AND/OR\nclause or a single filter.\n", "properties": {"operator": {"type": "string", "description": "Logical operator (AND/OR) for the clause.", "enum": ["and", "or"]}, "conditions": {"type": "array", "description": "List of filters or recursively nested clauses.", "items": {"type": "object", "required": ["column_id", "condition"], "properties": {"column_id": {"type": "string", "description": "ID of the column (must be a dimension)."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}, "condition": {"type": "object", "description": "Definition of a the condition for this column.", "properties": {"operator": {"type": "string", "description": "Filtering operator. Available choices depend on\nthe specified column's type.\n\nString operators: ``eq``, ``neq``,\n``contains``, ``not_contains``,\n``icontains``, ``not_icontains``,\n``starts_with``, ``ends_with``,\n``matches``, ``not_matches``. For regular expressions (operators: ``matches`` and ``not_matches``)\nuse [re2](https://github.com/google/re2/wiki/Syntax) syntax.\n\nNumeric operators: ``eq``, ``neq``, ``gt``, ``gte``,\n``lt``, ``lte``.\n\nBoolean operators: ``eq``, ``neq``.\n\nEnum operators: ``eq``, ``neq``, ``empty``, ``not_empty``.\n"}, "value": {"description": "Value that should be matched by filter. Value type must\nmatch the type of the specified column. For enumerated\nfields, you must use the ID value.\n"}}, "required": ["operator", "value"]}}, "example": {"column_id": "event_title", "condition": {"operator": "contains", "value": "test"}}}}}, "required": ["operator", "conditions"]}, "metric_filters": {"type": "object", "description": "Metric filters for the query. The top-level object must specify AND/OR\nclause, but any nested objects may either specify another AND/OR\nclause or a single filter.\n", "properties": {"operator": {"type": "string", "description": "Logical operator (AND/OR) for the clause.", "enum": ["and", "or"]}, "conditions": {"type": "array", "description": "List of filters or recursively nested clauses.", "items": {"type": "object", "required": ["column_id", "condition"], "properties": {"column_id": {"type": "string", "description": "ID of the column (must be a metric, or a dimension converted\nto a metric).\n"}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto a metric.\n"}, "goal_id": {"type": "integer", "description": "Specify a goal ID to calculate the metric using data limited\nto that goal only. Supported only by goal-related metrics.\n"}, "condition": {"type": "object", "description": "Definition of a the condition for this column.", "properties": {"operator": {"type": "string", "description": "Filtering operator.", "enum": ["eq", "neq", "gt", "gte", "lt", "lte"]}, "value": {"description": "Value that should be matched by filter.", "type": "float", "example": 42.5}}, "required": ["operator", "value"]}}, "example": {"column_id": "page_views", "condition": {"operator": "eq", "value": 42}}}}}, "required": ["operator", "conditions"]}, "offset": {"type": "integer", "default": 0, "minimum": 0, "description": "Number of rows to skip before beginning to return rows."}, "limit": {"type": "integer", "default": 100, "minimum": 1, "maximum": 100000, "description": "Number of rows to return."}, "order_by": {"type": "array", "description": "Array of sorting directives. Each directive is a 2-element array with\n0-based colum index and direction). You can sort on more than one column.\nBy default sorts descending by the first metric in query.\n", "items": {"type": "array"}, "example": [[1, "desc"], [2, "asc"]]}, "format": {"type": "string", "enum": ["json", "json-kv", "csv", "xml"], "default": "json", "description": "Data format of a successful response (error responses are always in json).\n"}, "column_format": {"type": "string", "enum": ["id", "name"], "default": "id", "description": "Format of the columns header (in CSV responses) and metadata labels\n(in JSON responses). By default uses identifiers (``id`` option), set to\n``name`` to use human-readable names.\n"}, "options": {"type": "object", "description": "Additional options for query.\n", "properties": {"sampling": {"type": "float", "description": "Apply sampling for query with given data percent. Sampling 0.1 means\nonly 10% of data are used to calculate query results. Sampling 1\nmeans that 100% of data is used to calculate results. Leave empty to\napply default sampling value for this website. By default this means\nthat sampling is turned off.\n", "example": 0.2, "minimum": 0.01, "maximum": 1}}}}, "required": ["website_id", "columns"], "example": {"website_id": "70236925-724f-404e-b634-7b5633bc0bcc", "columns": [{"column_id": "device_type"}, {"column_id": "revenue", "transformation_id": "sum"}], "date_from": "2020-02-10", "date_to": "2020-02-10", "filters": {"operator": "and", "conditions": [{"column_id": "event_title", "condition": {"operator": "contains", "value": "test"}}]}, "metric_filters": {"operator": "and", "conditions": [{"column_id": "page_views", "condition": {"operator": "eq", "value": 42}}]}, "offset": 0, "limit": 100, "order_by": [[1, "desc"], [2, "asc"]], "format": "json", "options": {"sampling": 0.2}}}}}}, "responses": {"200": {"description": "OK", "content": {"application/json": {"schema": {"type": "object", "properties": {"data": {"type": "array", "description": "Rows with results for the query.", "items": {"type": "object", "description": null}}, "meta": {"type": "object", "description": "Additional results metadata for the query.", "properties": {"count": {"type": "integer", "description": "Total number of results available for this query."}}}}, "example": {"data": [[["EU", "Europe"], "Blink", 529437, 128334], [["NA", "North America"], "Blink", 199355, 47171], [["AS", "Asia"], "Blink", 153385, 37308]], "meta": {"count": 42}}}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}, "source": {"type": "object", "description": "Source of the error (if available).", "properties": {"parameter": {"type": "string", "description": "Path to the parameter that caused the error."}}}}}}}, "example": {"errors": [{"status": "400", "detail": "Dimension \"example\" does not exist.", "source": {"parameter": "columns.column_id"}}]}}}}}, "401": {"description": "Unauthorized", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}}}}}, "example": {"errors": [{"status": "401", "detail": "No valid credentials provided."}]}}}}}, "403": {"description": "Forbidden", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}}}}}, "example": {"errors": [{"status": "403", "detail": "No valid license found."}]}}}}}}}}, "/api/analytics/v1/sessions/": {"post": {"tags": ["Raw data"], "summary": "Fetch sessions", "description": "API that allows fetching raw sessions from the database (event-level data\nis not available in this API). Please note that each request must be\nauthenticated.\n\n#### Compression\n\nWhen requesting large amount of data, make sure to include\nan **Accept-Encoding: gzip** header to enable\ncompression.\n", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "properties": {"website_id": {"type": "string", "format": "uuid", "description": "ID of a website or a meta site.", "example": "70236925-724f-404e-b634-7b5633bc0bcc"}, "columns": {"type": "array", "description": "Definitions of additional columns that should be returned (timestamp and\nidentifiers will be returned by default).\n", "items": {"type": "object", "properties": {"column_id": {"type": "string", "description": "ID of the dimension column."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}}, "required": ["column_id"]}, "example": [{"column_id": "resolution"}, {"column_id": "device_type"}]}, "date_from": {"type": "string", "format": "date", "description": "Start date for the query (inclusive). Cannot be used with relative_date field at the same time. Mandatory if ``relative_date`` is not used."}, "date_to": {"type": "string", "format": "date", "description": "End date for the query (inclusive). Cannot be used with ``relative_date`` field at the same time. Mandatory if ``relative_date`` is not used."}, "relative_date": {"type": "string", "enum": ["today", "yesterday", "last_week", "last_month", "last_year", "last_X_days"], "description": "Use relative date in query. Cannot be used with absolute date fields at\nthe same time. ``X`` in ``last_X_days`` must be in range 1 <= ``X`` <= 365.\nNote that ``last_X_days`` does not include data from today.\nMandatory if absolute date fields are not used.\n"}, "filters": {"type": "object", "description": "Dimension filters for the query. The top-level object must specify\nAND/OR clause, but any nested objects may either specify another AND/OR\nclause or a single filter.\n", "properties": {"operator": {"type": "string", "description": "Logical operator (AND/OR) for the clause.", "enum": ["and", "or"]}, "conditions": {"type": "array", "description": "List of filters or recursively nested clauses.", "items": {"type": "object", "required": ["column_id", "condition"], "properties": {"column_id": {"type": "string", "description": "ID of the dimension column."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}, "condition": {"type": "object", "description": "Definition of a the condition for this column.", "properties": {"operator": {"type": "string", "description": "Filtering operator. Available choices depend on\nthe specified column's type.\n\nString operators: ``eq``, ``neq``,\n``starts_with``, ``ends_with``.\n``starts_with``, ``ends_with``,\n``matches``, ``not_matches``. For regular expressions (operators: ``matches`` and ``not_matches``)\nuse [re2](https://github.com/google/re2/wiki/Syntax) syntax.\n\nNumeric operators: ``eq``, ``neq``, ``gt``, ``gte``,\n``lt``, ``lte``.\n\nBoolean operators: ``eq``, ``neq``.\n\nEnum operators: ``eq``, ``neq``, ``empty``, ``not_empty``.\n"}, "value": {"description": "Value that should be matched by filter. Value type must\nmatch the type of the specified column. For enumerated\nfields, you must use the ID value.\n"}}, "required": ["operator", "value"]}}, "example": {"column_id": "browser_name", "condition": {"operator": "eq", "value": "FF"}}}}}, "required": ["operator", "conditions"]}, "offset": {"type": "integer", "default": 0, "minimum": 0, "description": "Number of rows to skip before beginning to return rows."}, "limit": {"type": "integer", "default": 100, "minimum": 1, "maximum": 100000, "description": "Number of rows to return."}, "format": {"type": "string", "enum": ["json", "json-kv", "csv"], "default": "json", "description": "Data format of a successful response (error responses are always in json).\n"}, "column_format": {"type": "string", "enum": ["id", "name"], "default": "id", "description": "Format of the columns header (in CSV responses) and metadata labels\n(in JSON responses). By default uses identifiers (``id`` option), set to\n``name`` to use human-readable names.\n"}}, "required": ["website_id", "columns"], "example": {"website_id": "70236925-724f-404e-b634-7b5633bc0bcc", "columns": [{"column_id": "resolution"}, {"column_id": "device_type"}], "date_from": "2020-02-10", "date_to": "2020-02-10", "filters": {"operator": "and", "conditions": [{"column_id": "browser_name", "condition": {"operator": "eq", "value": "FF"}}]}, "offset": 0, "limit": 100, "format": "json"}}}}}, "responses": {"200": {"description": "OK", "content": {"application/json": {"schema": {"type": "object", "properties": {"data": {"type": "array", "description": "Rows with results for the query.", "items": {"type": "object", "description": null}}, "meta": {"type": "object", "description": "Additional results metadata for the query.", "properties": {"columns": {"type": "array", "description": "List of column IDs returned.", "items": {"type": "str"}}, "count": {"type": "integer", "description": "Total number of results available for this query."}}}}, "example": {"data": [["2132601", "2ecf33167d400648", "2018-12-03T00:21:03", "375x667", [1, "Smartphone"]]], "meta": {"columns": ["session_id", "visitor_id", "timestamp", "resolution", "device_type"], "count": 1999}}}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}, "source": {"type": "object", "description": "Source of the error (if available).", "properties": {"parameter": {"type": "string", "description": "Path to the parameter that caused the error."}}}}}}}, "example": {"errors": [{"status": "400", "detail": "Dimension \"example\" does not exist.", "source": {"parameter": "columns.column_id"}}]}}}}}, "401": {"description": "Unauthorized", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}}}}}, "example": {"errors": [{"status": "401", "detail": "No valid credentials provided."}]}}}}}, "403": {"description": "Forbidden", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}}}}}, "example": {"errors": [{"status": "403", "detail": "No valid license found."}]}}}}}}}}, "/api/analytics/v1/events/": {"post": {"tags": ["Raw data"], "summary": "Fetch events", "description": "API that allows fetching raw events from the database. Please note that\neach request must be authenticated.\n\n#### Compression\n\nWhen requesting large amount of data, make sure to include\nan **Accept-Encoding: gzip** header to enable\ncompression.s\n", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "properties": {"website_id": {"type": "string", "format": "uuid", "description": "ID of a website or a meta site.", "example": "70236925-724f-404e-b634-7b5633bc0bcc"}, "columns": {"type": "array", "description": "Definitions of additional columns that should be returned (timestamp and\nidentifiers will be returned by default).\n", "items": {"type": "object", "properties": {"column_id": {"type": "string", "description": "ID of the dimension column."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}}, "required": ["column_id"]}, "example": [{"column_id": "resolution"}, {"column_id": "device_type"}]}, "date_from": {"type": "string", "format": "date", "description": "Start date for the query (inclusive). Cannot be used with relative_date field at the same time. Mandatory if ``relative_date`` is not used."}, "date_to": {"type": "string", "format": "date", "description": "End date for the query (inclusive). Cannot be used with ``relative_date`` field at the same time. Mandatory if ``relative_date`` is not used."}, "relative_date": {"type": "string", "enum": ["today", "yesterday", "last_week", "last_month", "last_year", "last_X_days"], "description": "Use relative date in query. Cannot be used with absolute date fields at\nthe same time. ``X`` in ``last_X_days`` must be in range 1 <= ``X`` <= 365.\nNote that ``last_X_days`` does not include data from today.\nMandatory if absolute date fields are not used.\n"}, "filters": {"type": "object", "description": "Dimension filters for the query. The top-level object must specify\nAND/OR clause, but any nested objects may either specify another AND/OR\nclause or a single filter.\n", "properties": {"operator": {"type": "string", "description": "Logical operator (AND/OR) for the clause.", "enum": ["and", "or"]}, "conditions": {"type": "array", "description": "List of filters or recursively nested clauses.", "items": {"type": "object", "required": ["column_id", "condition"], "properties": {"column_id": {"type": "string", "description": "ID of the dimension column."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}, "condition": {"type": "object", "description": "Definition of a the condition for this column.", "properties": {"operator": {"type": "string", "description": "Filtering operator. Available choices depend on\nthe specified column's type.\n\nString operators: ``eq``, ``neq``,\n``starts_with``, ``ends_with``.\n``starts_with``, ``ends_with``,\n``matches``, ``not_matches``. For regular expressions (operators: ``matches`` and ``not_matches``)\nuse [re2](https://github.com/google/re2/wiki/Syntax) syntax.\n\nNumeric operators: ``eq``, ``neq``, ``gt``, ``gte``,\n``lt``, ``lte``.\n\nBoolean operators: ``eq``, ``neq``.\n\nEnum operators: ``eq``, ``neq``, ``empty``, ``not_empty``.\n"}, "value": {"description": "Value that should be matched by filter. Value type must\nmatch the type of the specified column. For enumerated\nfields, you must use the ID value.\n"}}, "required": ["operator", "value"]}}, "example": {"column_id": "browser_name", "condition": {"operator": "eq", "value": "FF"}}}}}, "required": ["operator", "conditions"]}, "offset": {"type": "integer", "default": 0, "minimum": 0, "description": "Number of rows to skip before beginning to return rows."}, "limit": {"type": "integer", "default": 100, "minimum": 1, "maximum": 100000, "description": "Number of rows to return."}, "format": {"type": "string", "enum": ["json", "json-kv", "csv"], "default": "json", "description": "Data format of a successful response (error responses are always in json).\n"}, "column_format": {"type": "string", "enum": ["id", "name"], "default": "id", "description": "Format of the columns header (in CSV responses) and metadata labels\n(in JSON responses). By default uses identifiers (``id`` option), set to\n``name`` to use human-readable names.\n"}}, "required": ["website_id", "columns"], "example": {"website_id": "70236925-724f-404e-b634-7b5633bc0bcc", "columns": [{"column_id": "resolution"}, {"column_id": "device_type"}], "date_from": "2020-02-10", "date_to": "2020-02-10", "filters": {"operator": "and", "conditions": [{"column_id": "browser_name", "condition": {"operator": "eq", "value": "FF"}}]}, "offset": 0, "limit": 100, "format": "json"}}}}}, "responses": {"200": {"description": "OK", "content": {"application/json": {"schema": {"type": "object", "properties": {"data": {"type": "array", "description": "Rows with results for the query.", "items": {"type": "object"}}, "meta": {"type": "object", "description": "Additional results metadata for the query.", "properties": {"columns": {"type": "array", "description": "List of column IDs returned.", "items": {"type": "str"}}, "count": {"type": "integer", "description": "Total number of results available for this query."}}}}, "example": {"data": [["2132601", "8131637", "2ecf33167d400648", "2018-12-03T00:21:03", "375x667", [1, "Smartphone"]]], "meta": {"columns": ["session_id", "event_id", "visitor_id", "timestamp", "resolution", "device_type"], "count": 3448}}}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}, "source": {"type": "object", "description": "Source of the error (if available).", "properties": {"parameter": {"type": "string", "description": "Path to the parameter that caused the error."}}}}}}}, "example": {"errors": [{"status": "400", "detail": "Dimension \"example\" does not exist.", "source": {"parameter": "columns.column_id"}}]}}}}}, "401": {"description": "Unauthorized", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}}}}}, "example": {"errors": [{"status": "401", "detail": "No valid credentials provided."}]}}}}}, "403": {"description": "Forbidden", "content": {"application/json": {"schema": {"type": "object", "properties": {"errors": {"type": "array", "items": {"type": "object", "properties": {"status": {"type": "string", "description": "HTTP status code for the error."}, "detail": {"type": "string", "description": "Additional information about the error."}}}}}, "example": {"errors": [{"status": "403", "detail": "No valid license found."}]}}}}}}}}}, "components": {"schemas": {"QueryRequest": {"type": "object", "properties": {"website_id": {"type": "string", "format": "uuid", "description": "ID of a website or a meta site.", "example": "70236925-724f-404e-b634-7b5633bc0bcc"}, "columns": {"type": "array", "description": "Column definitions for the query.", "items": {"type": "object", "properties": {"column_id": {"type": "string", "description": "ID of the column (either a dimension or a metric)."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by the\ncolumn that was specified.\n"}, "goal_id": {"type": "integer", "description": "Optional ID of a goal. Available only for metrics related to goals.\n"}}, "required": ["column_id"]}, "example": [{"column_id": "device_type"}, {"column_id": "revenue", "transformation_id": "sum"}]}, "date_from": {"type": "string", "format": "date", "description": "Start date for the query (inclusive). Cannot be used with relative_date field at the same time. Mandatory if ``relative_date`` is not used."}, "date_to": {"type": "string", "format": "date", "description": "End date for the query (inclusive). Cannot be used with ``relative_date`` field at the same time. Mandatory if ``relative_date`` is not used."}, "relative_date": {"type": "string", "enum": ["today", "yesterday", "last_week", "last_month", "last_year", "last_X_days"], "description": "Use relative date in query. Cannot be used with absolute date fields at\nthe same time. ``X`` in ``last_X_days`` must be in range 1 <= ``X`` <= 365.\nNote that ``last_X_days`` does not include data from today.\nMandatory if absolute date fields are not used.\n"}, "filters": {"type": "object", "description": "Dimension filters for the query. The top-level object must specify\nAND/OR clause, but any nested objects may either specify another AND/OR\nclause or a single filter.\n", "properties": {"operator": {"type": "string", "description": "Logical operator (AND/OR) for the clause.", "enum": ["and", "or"]}, "conditions": {"type": "array", "description": "List of filters or recursively nested clauses.", "items": {"type": "object", "required": ["column_id", "condition"], "properties": {"column_id": {"type": "string", "description": "ID of the column (must be a dimension)."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}, "condition": {"type": "object", "description": "Definition of a the condition for this column.", "properties": {"operator": {"type": "string", "description": "Filtering operator. Available choices depend on\nthe specified column's type.\n\nString operators: ``eq``, ``neq``,\n``contains``, ``not_contains``,\n``icontains``, ``not_icontains``,\n``starts_with``, ``ends_with``,\n``matches``, ``not_matches``. For regular expressions (operators: ``matches`` and ``not_matches``)\nuse [re2](https://github.com/google/re2/wiki/Syntax) syntax.\n\nNumeric operators: ``eq``, ``neq``, ``gt``, ``gte``,\n``lt``, ``lte``.\n\nBoolean operators: ``eq``, ``neq``.\n\nEnum operators: ``eq``, ``neq``, ``empty``, ``not_empty``.\n"}, "value": {"description": "Value that should be matched by filter. Value type must\nmatch the type of the specified column. For enumerated\nfields, you must use the ID value.\n"}}, "required": ["operator", "value"]}}, "example": {"column_id": "event_title", "condition": {"operator": "contains", "value": "test"}}}}}, "required": ["operator", "conditions"]}, "metric_filters": {"type": "object", "description": "Metric filters for the query. The top-level object must specify AND/OR\nclause, but any nested objects may either specify another AND/OR\nclause or a single filter.\n", "properties": {"operator": {"type": "string", "description": "Logical operator (AND/OR) for the clause.", "enum": ["and", "or"]}, "conditions": {"type": "array", "description": "List of filters or recursively nested clauses.", "items": {"type": "object", "required": ["column_id", "condition"], "properties": {"column_id": {"type": "string", "description": "ID of the column (must be a metric, or a dimension converted\nto a metric).\n"}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto a metric.\n"}, "goal_id": {"type": "integer", "description": "Specify a goal ID to calculate the metric using data limited\nto that goal only. Supported only by goal-related metrics.\n"}, "condition": {"type": "object", "description": "Definition of a the condition for this column.", "properties": {"operator": {"type": "string", "description": "Filtering operator.", "enum": ["eq", "neq", "gt", "gte", "lt", "lte"]}, "value": {"description": "Value that should be matched by filter.", "type": "float", "example": 42.5}}, "required": ["operator", "value"]}}, "example": {"column_id": "page_views", "condition": {"operator": "eq", "value": 42}}}}}, "required": ["operator", "conditions"]}, "offset": {"type": "integer", "default": 0, "minimum": 0, "description": "Number of rows to skip before beginning to return rows."}, "limit": {"type": "integer", "default": 100, "minimum": 1, "maximum": 100000, "description": "Number of rows to return."}, "order_by": {"type": "array", "description": "Array of sorting directives. Each directive is a 2-element array with\n0-based colum index and direction). You can sort on more than one column.\nBy default sorts descending by the first metric in query.\n", "items": {"type": "array"}, "example": [[1, "desc"], [2, "asc"]]}, "format": {"type": "string", "enum": ["json", "json-kv", "csv", "xml"], "default": "json", "description": "Data format of a successful response (error responses are always in json).\n"}, "column_format": {"type": "string", "enum": ["id", "name"], "default": "id", "description": "Format of the columns header (in CSV responses) and metadata labels\n(in JSON responses). By default uses identifiers (``id`` option), set to\n``name`` to use human-readable names.\n"}, "options": {"type": "object", "description": "Additional options for query.\n", "properties": {"sampling": {"type": "float", "description": "Apply sampling for query with given data percent. Sampling 0.1 means\nonly 10% of data are used to calculate query results. Sampling 1\nmeans that 100% of data is used to calculate results. Leave empty to\napply default sampling value for this website. By default this means\nthat sampling is turned off.\n", "example": 0.2, "minimum": 0.01, "maximum": 1}}}}, "required": ["website_id", "columns"], "example": {"website_id": "70236925-724f-404e-b634-7b5633bc0bcc", "columns": [{"column_id": "device_type"}, {"column_id": "revenue", "transformation_id": "sum"}], "date_from": "2020-02-10", "date_to": "2020-02-10", "filters": {"operator": "and", "conditions": [{"column_id": "event_title", "condition": {"operator": "contains", "value": "test"}}]}, "metric_filters": {"operator": "and", "conditions": [{"column_id": "page_views", "condition": {"operator": "eq", "value": 42}}]}, "offset": 0, "limit": 100, "order_by": [[1, "desc"], [2, "asc"]], "format": "json", "options": {"sampling": 0.2}}}, "RawDataRequest": {"type": "object", "properties": {"website_id": {"type": "string", "format": "uuid", "description": "ID of a website or a meta site.", "example": "70236925-724f-404e-b634-7b5633bc0bcc"}, "columns": {"type": "array", "description": "Definitions of additional columns that should be returned (timestamp and\nidentifiers will be returned by default).\n", "items": {"type": "object", "properties": {"column_id": {"type": "string", "description": "ID of the dimension column."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}}, "required": ["column_id"]}, "example": [{"column_id": "resolution"}, {"column_id": "device_type"}]}, "date_from": {"type": "string", "format": "date", "description": "Start date for the query (inclusive). Cannot be used with relative_date field at the same time. Mandatory if ``relative_date`` is not used."}, "date_to": {"type": "string", "format": "date", "description": "End date for the query (inclusive). Cannot be used with ``relative_date`` field at the same time. Mandatory if ``relative_date`` is not used."}, "relative_date": {"type": "string", "enum": ["today", "yesterday", "last_week", "last_month", "last_year", "last_X_days"], "description": "Use relative date in query. Cannot be used with absolute date fields at\nthe same time. ``X`` in ``last_X_days`` must be in range 1 <= ``X`` <= 365.\nNote that ``last_X_days`` does not include data from today.\nMandatory if absolute date fields are not used.\n"}, "filters": {"type": "object", "description": "Dimension filters for the query. The top-level object must specify\nAND/OR clause, but any nested objects may either specify another AND/OR\nclause or a single filter.\n", "properties": {"operator": {"type": "string", "description": "Logical operator (AND/OR) for the clause.", "enum": ["and", "or"]}, "conditions": {"type": "array", "description": "List of filters or recursively nested clauses.", "items": {"type": "object", "required": ["column_id", "condition"], "properties": {"column_id": {"type": "string", "description": "ID of the dimension column."}, "transformation_id": {"type": "string", "description": "Optional ID of the transformation. Must be supported by\nthe column that was specified and must convert the column\ninto another dimension (and not a metric).\n"}, "condition": {"type": "object", "description": "Definition of a the condition for this column.", "properties": {"operator": {"type": "string", "description": "Filtering operator. Available choices depend on\nthe specified column's type.\n\nString operators: ``eq``, ``neq``,\n``starts_with``, ``ends_with``.\n``starts_with``, ``ends_with``,\n``matches``, ``not_matches``. For regular expressions (operators: ``matches`` and ``not_matches``)\nuse [re2](https://github.com/google/re2/wiki/Syntax) syntax.\n\nNumeric operators: ``eq``, ``neq``, ``gt``, ``gte``,\n``lt``, ``lte``.\n\nBoolean operators: ``eq``, ``neq``.\n\nEnum operators: ``eq``, ``neq``, ``empty``, ``not_empty``.\n"}, "value": {"description": "Value that should be matched by filter. Value type must\nmatch the type of the specified column. For enumerated\nfields, you must use the ID value.\n"}}, "required": ["operator", "value"]}}, "example": {"column_id": "browser_name", "condition": {"operator": "eq", "value": "FF"}}}}}, "required": ["operator", "conditions"]}, "offset": {"type": "integer", "default": 0, "minimum": 0, "description": "Number of rows to skip before beginning to return rows."}, "limit": {"type": "integer", "default": 100, "minimum": 1, "maximum": 100000, "description": "Number of rows to return."}, "format": {"type": "string", "enum": ["json", "json-kv", "csv"], "default": "json", "description": "Data format of a successful response (error responses are always in json).\n"}, "column_format": {"type": "string", "enum": ["id", "name"], "default": "id", "description": "Format of the columns header (in CSV responses) and metadata labels\n(in JSON responses). By default uses identifiers (``id`` option), set to\n``name`` to use human-readable names.\n"}}, "required": ["website_id", "columns"], "example": {"website_id": "70236925-724f-404e-b634-7b5633bc0bcc", "columns": [{"column_id": "resolution"}, {"column_id": "device_type"}], "date_from": "2020-02-10", "date_to": "2020-02-10", "filters": {"operator": "and", "conditions": [{"column_id": "browser_name", "condition": {"operator": "eq", "value": "FF"}}]}, "offset": 0, "limit": 100, "format": "json"}}}}}