> For the complete documentation index, see [llms.txt](https://help.openloyalty.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.openloyalty.io/api-reference/data-analytics.md).

# Data Analytics

These endpoints will allow you to retrieve data for analytical dashboards and graphs

## Retrieve general overview

> \<label style="background-color: #D4EDBC;padding:5px;">Management\</label>\<br>\<br>\
> The endpoint is used to retrieve a general overview of the analytics dashboard.\
> To use the endpoint, you must provide a "dataType" parameter that specifies the type of data you want to retrieve.\
> Additionally, you can provide optional query parameters to filter the data.\
> \
> You can specify an "aggregationType" parameter to group the data by day, week, month, or year. You can also specify an "intervalStartDate" and "intervalEndDate" parameter to retrieve data for a specific time range.\
> \
> If you don't specify the "aggregationType" parameter, aggregation will be based on interval:\
> \
> \- 1-30 - days daily aggregation\
> \- 31-90 - days weekly aggregation\
> \- 91-360 - days monthly aggregation\
> \- over 360 - days annual aggregation\
> \
> If you don't provide any optional query parameters and don't specify an interval, it will return all data from the beginning to today.<br>

````json
{"openapi":"3.0.0","info":{"title":"Open Loyalty","version":"0.0.1"},"tags":[{"name":"Data Analytics","description":"These endpoints will allow you to retrieve data for analytical dashboards and graphs"}],"servers":[{"url":"http://openloyalty.localhost"}],"security":[{"Bearer":[]},{"token":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","description":"Open Loyalty has the JWT authorization.\nTo learn what a JSON Web Token is and how it works, check out Introduction to JSON Web Tokens <https://jwt.io/introduction/>\n\n### Obtain an access token\n\nSend a request with the parameters username and password\n\n#### Definition\n\n`POST /api/admin/login_check` [Go to definition](#operation/adminLoginCheck)\\\n`POST /api/{storeCode}/member/login_check` [Go to definition](#operation/memberLoginCheck)\n\n#### Example\n\n```bash\ncurl {HOST}/api/admin/login_check\n    -H 'Content-Type: application/json;charset=UTF-8'\n    -H 'Accept: application/json, text/plain, */*'\n    --data-binary '{\"username\":\"admin\",\"password\":\"password\"}'\n```\n\n#### Example Response\n\n```json\n{\n    \"token\":\"eyJhbGciOiJSUzI1NiIsInR5cCI6...\",\n    \"refresh_token\":\"0558f8bb29948c4e54c443f...\"\n}\n```\n\n### Using JSON Web Token\n\nAdd authorization header to each request\\\n`Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...`\\\nYou can now access any API method you want under the /api prefix.\n\n#### Example\n```bash\ncurl {HOST}/api/{storeCode}/analytics/members\n    -H 'Accept: application/json'\n    -H 'Content-type: application/x-www-form-urlencoded'\n    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...'\n```\n\n### Refresh JSON Web Token\nYou can refresh token using refresh_token that was given during login.\\\nThere are two endpoints\\\nTo refresh admin token `POST /api/token/refresh` [Go to definition](#operation/tokenRefresh)\\\nTo refresh member token `POST /api/{storeCode}/token/refresh` [Go to definition](#operation/tokenRefreshMember)\n","name":"Authorization","in":"header","bearerFormat":"JWT","scheme":"bearer"},"token":{"type":"apiKey","name":"X-AUTH-TOKEN","in":"header"}},"parameters":{"storeCode":{"name":"storeCode","in":"path","description":"Store code","required":true,"schema":{"type":"string"}}},"schemas":{"GeneralOverview":{"properties":{"intervalStartDate":{"type":"string","format":"date-time"},"intervalEndDate":{"type":"string","format":"date-time"},"header":{"$ref":"#/components/schemas/GeneralOverviewHeader"},"data":{"type":"object","additionalProperties":true},"comparativePeriodData":{"type":"object","deprecated":true,"additionalProperties":true}},"type":"object"},"GeneralOverviewHeader":{"properties":{"registeredMembers":{"type":"integer"},"activeMembers":{"type":"integer"},"revenue":{"type":"number","format":"float"},"avgSpending":{"type":"number","format":"float"},"transactions":{"type":"integer"},"avgTransactionValue":{"type":"number","format":"float"},"avgNumberOfTransactions":{"type":"number","format":"float"},"returnTransactions":{"type":"integer"},"totalReturns":{"type":"number","format":"float"},"avgReturnValue":{"type":"number","format":"float"},"avgNumberOfReturnTransactions":{"type":"number","format":"float"}},"type":"object"},"ExpiredToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"InvalidToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"Unauthorized":{"required":["message"],"properties":{"message":{"type":"string"}},"type":"object"}},"responses":{"BadRequest":{"description":"Bad request.","content":{"application/json":{"schema":{"required":["code","message","errors"],"properties":{"code":{"type":"integer"},"message":{"type":"string"},"errors":{"type":"array","items":{"required":["message","parameters","plural","code","path"],"properties":{"message":{"type":"string"},"parameters":{},"plural":{"type":"integer","nullable":true},"code":{"type":"string"},"path":{"type":"string"}},"type":"object"}}},"type":"object"}}}},"AccessDenied":{"description":"Forbidden.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}},"NotFound":{"description":"Not found.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}}}},"paths":{"/api/{storeCode}/analytics/dashboard/general-overview":{"get":{"tags":["Data Analytics"],"summary":"Retrieve general overview","description":"<label style=\"background-color: #D4EDBC;padding:5px;\">Management</label><br><br>\nThe endpoint is used to retrieve a general overview of the analytics dashboard.\nTo use the endpoint, you must provide a \"dataType\" parameter that specifies the type of data you want to retrieve.\nAdditionally, you can provide optional query parameters to filter the data.\n\nYou can specify an \"aggregationType\" parameter to group the data by day, week, month, or year. You can also specify an \"intervalStartDate\" and \"intervalEndDate\" parameter to retrieve data for a specific time range.\n\nIf you don't specify the \"aggregationType\" parameter, aggregation will be based on interval:\n\n- 1-30 - days daily aggregation\n- 31-90 - days weekly aggregation\n- 91-360 - days monthly aggregation\n- over 360 - days annual aggregation\n\nIf you don't provide any optional query parameters and don't specify an interval, it will return all data from the beginning to today.\n","operationId":"dataAnalyticsGetGeneralOverview","parameters":[{"name":"dataType","in":"query","required":true,"schema":{"type":"string","enum":["registeredMembers","revenue","avgSpending","transactions","avgTransactionValue","avgNumberOfTransactions","returnTransactions","totalReturns","avgReturnValue","avgNumberOfReturnTransactions"]}},{"name":"aggregationType","in":"query","required":false,"schema":{"type":"string","enum":["day","week","month","year"]}},{"name":"intervalStartDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"intervalEndDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"$ref":"#/components/parameters/storeCode"}],"responses":{"200":{"description":"Data for general overview dashboard","content":{"application/json":{"schema":{"type":"object","allOf":[{"$ref":"#/components/schemas/GeneralOverview"},{"properties":{"aggregationType":{"type":"string","enum":["day","week","month","year"]},"dataType":{"type":"string","enum":["registeredMembers","revenue","avgSpending","transactions","avgTransactionValue","avgNumberOfTransactions","activeMembers","returnTransactions","totalReturns","avgReturnValue","avgNumberOfReturnTransactions"]}},"type":"object","property":null}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"Unauthorized.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ExpiredToken"},{"$ref":"#/components/schemas/InvalidToken"},{"$ref":"#/components/schemas/Unauthorized"}]}}}},"403":{"$ref":"#/components/responses/AccessDenied"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
````

## Retrieve units overview

> \<label style="background-color: #D4EDBC;padding:5px;">Management\</label>\<br>\<br>\
> The endpoint is used to retrieve a units overview of the analytics dashboard.\
> \
> You can specify an "aggregationType" parameter to group the data by day, week, month, or year. You can also specify an "intervalStartDate" and "intervalEndDate" parameter to retrieve data for a specific time range.\
> \
> If you don't specify the "aggregationType" parameter, aggregation will be based on interval:\
> \
> \- 1-30 - days daily aggregation\
> \- 31-90 - days weekly aggregation\
> \- 91-360 - days monthly aggregation\
> \- over 360 - days annual aggregation\
> \
> If you don't provide any optional query parameters and don't specify an interval, it will return all data from the beginning to today.<br>

````json
{"openapi":"3.0.0","info":{"title":"Open Loyalty","version":"0.0.1"},"tags":[{"name":"Data Analytics","description":"These endpoints will allow you to retrieve data for analytical dashboards and graphs"}],"servers":[{"url":"http://openloyalty.localhost"}],"security":[{"Bearer":[]},{"token":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","description":"Open Loyalty has the JWT authorization.\nTo learn what a JSON Web Token is and how it works, check out Introduction to JSON Web Tokens <https://jwt.io/introduction/>\n\n### Obtain an access token\n\nSend a request with the parameters username and password\n\n#### Definition\n\n`POST /api/admin/login_check` [Go to definition](#operation/adminLoginCheck)\\\n`POST /api/{storeCode}/member/login_check` [Go to definition](#operation/memberLoginCheck)\n\n#### Example\n\n```bash\ncurl {HOST}/api/admin/login_check\n    -H 'Content-Type: application/json;charset=UTF-8'\n    -H 'Accept: application/json, text/plain, */*'\n    --data-binary '{\"username\":\"admin\",\"password\":\"password\"}'\n```\n\n#### Example Response\n\n```json\n{\n    \"token\":\"eyJhbGciOiJSUzI1NiIsInR5cCI6...\",\n    \"refresh_token\":\"0558f8bb29948c4e54c443f...\"\n}\n```\n\n### Using JSON Web Token\n\nAdd authorization header to each request\\\n`Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...`\\\nYou can now access any API method you want under the /api prefix.\n\n#### Example\n```bash\ncurl {HOST}/api/{storeCode}/analytics/members\n    -H 'Accept: application/json'\n    -H 'Content-type: application/x-www-form-urlencoded'\n    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...'\n```\n\n### Refresh JSON Web Token\nYou can refresh token using refresh_token that was given during login.\\\nThere are two endpoints\\\nTo refresh admin token `POST /api/token/refresh` [Go to definition](#operation/tokenRefresh)\\\nTo refresh member token `POST /api/{storeCode}/token/refresh` [Go to definition](#operation/tokenRefreshMember)\n","name":"Authorization","in":"header","bearerFormat":"JWT","scheme":"bearer"},"token":{"type":"apiKey","name":"X-AUTH-TOKEN","in":"header"}},"parameters":{"storeCode":{"name":"storeCode","in":"path","description":"Store code","required":true,"schema":{"type":"string"}}},"schemas":{"UnitsOverview":{"properties":{"intervalStartDate":{"type":"string","format":"date-time"},"intervalEndDate":{"type":"string","format":"date-time"},"walletTypeCode":{"type":"string"},"header":{"$ref":"#/components/schemas/UnitsOverviewHeader"},"data":{"type":"object","additionalProperties":true}},"type":"object"},"UnitsOverviewHeader":{"properties":{"unitsIssued":{"type":"number","format":"float"},"unitsSpent":{"type":"number","format":"float"},"unitsExpired":{"type":"number","format":"float"},"unitsPending":{"type":"number","format":"float"},"unitsActive":{"type":"number","format":"float"},"redemptionRate":{"type":"number","format":"float"},"breakageRate":{"type":"number","format":"float"}},"type":"object"},"ExpiredToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"InvalidToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"Unauthorized":{"required":["message"],"properties":{"message":{"type":"string"}},"type":"object"}},"responses":{"BadRequest":{"description":"Bad request.","content":{"application/json":{"schema":{"required":["code","message","errors"],"properties":{"code":{"type":"integer"},"message":{"type":"string"},"errors":{"type":"array","items":{"required":["message","parameters","plural","code","path"],"properties":{"message":{"type":"string"},"parameters":{},"plural":{"type":"integer","nullable":true},"code":{"type":"string"},"path":{"type":"string"}},"type":"object"}}},"type":"object"}}}},"AccessDenied":{"description":"Forbidden.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}},"NotFound":{"description":"Not found.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}}}},"paths":{"/api/{storeCode}/analytics/units-overview/{walletTypeCode}":{"get":{"tags":["Data Analytics"],"summary":"Retrieve units overview","description":"<label style=\"background-color: #D4EDBC;padding:5px;\">Management</label><br><br>\nThe endpoint is used to retrieve a units overview of the analytics dashboard.\n\nYou can specify an \"aggregationType\" parameter to group the data by day, week, month, or year. You can also specify an \"intervalStartDate\" and \"intervalEndDate\" parameter to retrieve data for a specific time range.\n\nIf you don't specify the \"aggregationType\" parameter, aggregation will be based on interval:\n\n- 1-30 - days daily aggregation\n- 31-90 - days weekly aggregation\n- 91-360 - days monthly aggregation\n- over 360 - days annual aggregation\n\nIf you don't provide any optional query parameters and don't specify an interval, it will return all data from the beginning to today.\n","operationId":"dataAnalyticsGetUnitsOverview","parameters":[{"name":"aggregationType","in":"query","required":false,"schema":{"type":"string","enum":["day","week","month","year"]}},{"name":"dataType","in":"query","required":false,"schema":{"type":"string","enum":["unitsIssued","unitsSpent","unitsExpired","unitsPending","unitsActive","redemptionRate","breakageRate"]}},{"name":"intervalStartDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"intervalEndDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"$ref":"#/components/parameters/storeCode"},{"name":"walletTypeCode","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Data for units overview dashboard","content":{"application/json":{"schema":{"type":"object","allOf":[{"$ref":"#/components/schemas/UnitsOverview"},{"properties":{"aggregationType":{"type":"string","enum":["day","week","month","year"]},"dataType":{"type":"string","enum":["unitsIssued","unitsSpent","unitsExpired","unitsPending","unitsActive","redemptionRate","breakageRate"]}},"type":"object","property":null}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"Unauthorized.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ExpiredToken"},{"$ref":"#/components/schemas/InvalidToken"},{"$ref":"#/components/schemas/Unauthorized"}]}}}},"403":{"$ref":"#/components/responses/AccessDenied"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
````

## Retrieve campaign overview

> \<label style="background-color: #D4EDBC;padding:5px;">Management\</label>\<br>\<br><br>

````json
{"openapi":"3.0.0","info":{"title":"Open Loyalty","version":"0.0.1"},"tags":[{"name":"Data Analytics","description":"These endpoints will allow you to retrieve data for analytical dashboards and graphs"}],"servers":[{"url":"http://openloyalty.localhost"}],"security":[{"Bearer":[]},{"token":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","description":"Open Loyalty has the JWT authorization.\nTo learn what a JSON Web Token is and how it works, check out Introduction to JSON Web Tokens <https://jwt.io/introduction/>\n\n### Obtain an access token\n\nSend a request with the parameters username and password\n\n#### Definition\n\n`POST /api/admin/login_check` [Go to definition](#operation/adminLoginCheck)\\\n`POST /api/{storeCode}/member/login_check` [Go to definition](#operation/memberLoginCheck)\n\n#### Example\n\n```bash\ncurl {HOST}/api/admin/login_check\n    -H 'Content-Type: application/json;charset=UTF-8'\n    -H 'Accept: application/json, text/plain, */*'\n    --data-binary '{\"username\":\"admin\",\"password\":\"password\"}'\n```\n\n#### Example Response\n\n```json\n{\n    \"token\":\"eyJhbGciOiJSUzI1NiIsInR5cCI6...\",\n    \"refresh_token\":\"0558f8bb29948c4e54c443f...\"\n}\n```\n\n### Using JSON Web Token\n\nAdd authorization header to each request\\\n`Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...`\\\nYou can now access any API method you want under the /api prefix.\n\n#### Example\n```bash\ncurl {HOST}/api/{storeCode}/analytics/members\n    -H 'Accept: application/json'\n    -H 'Content-type: application/x-www-form-urlencoded'\n    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...'\n```\n\n### Refresh JSON Web Token\nYou can refresh token using refresh_token that was given during login.\\\nThere are two endpoints\\\nTo refresh admin token `POST /api/token/refresh` [Go to definition](#operation/tokenRefresh)\\\nTo refresh member token `POST /api/{storeCode}/token/refresh` [Go to definition](#operation/tokenRefreshMember)\n","name":"Authorization","in":"header","bearerFormat":"JWT","scheme":"bearer"},"token":{"type":"apiKey","name":"X-AUTH-TOKEN","in":"header"}},"parameters":{"storeCode":{"name":"storeCode","in":"path","description":"Store code","required":true,"schema":{"type":"string"}}},"schemas":{"SingleView":{"properties":{"campaignId":{"type":"string","format":"uuid"},"intervalStartDate":{"type":"string","format":"date-time"},"intervalEndDate":{"type":"string","format":"date-time"},"header":{"$ref":"#/components/schemas/SingleViewHeader"},"data":{"type":"object","additionalProperties":true},"comparativePeriodData":{"type":"object","deprecated":true,"additionalProperties":true}},"type":"object"},"SingleViewHeader":{"properties":{"totalEngagement":{"type":"integer"},"engagedMembers":{"type":"integer"}},"type":"object"},"ExpiredToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"InvalidToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"Unauthorized":{"required":["message"],"properties":{"message":{"type":"string"}},"type":"object"}},"responses":{"BadRequest":{"description":"Bad request.","content":{"application/json":{"schema":{"required":["code","message","errors"],"properties":{"code":{"type":"integer"},"message":{"type":"string"},"errors":{"type":"array","items":{"required":["message","parameters","plural","code","path"],"properties":{"message":{"type":"string"},"parameters":{},"plural":{"type":"integer","nullable":true},"code":{"type":"string"},"path":{"type":"string"}},"type":"object"}}},"type":"object"}}}},"AccessDenied":{"description":"Forbidden.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}},"NotFound":{"description":"Not found.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}}}},"paths":{"/api/{storeCode}/analytics/campaign/single-view/{campaignId}":{"get":{"tags":["Data Analytics"],"summary":"Retrieve campaign overview","description":"<label style=\"background-color: #D4EDBC;padding:5px;\">Management</label><br><br>\n","operationId":"dataAnalyticsGetCampaignSingleView","parameters":[{"name":"dataType","in":"query","required":true,"schema":{"type":"string","enum":["totalEngagement","engagedMembers"]}},{"name":"aggregationType","in":"query","required":false,"schema":{"type":"string","enum":["day","week","month","year"]}},{"name":"intervalStartDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"intervalEndDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"$ref":"#/components/parameters/storeCode"},{"name":"campaignId","in":"path","required":true,"schema":{"type":"string","pattern":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"}}],"responses":{"200":{"description":"Data for general overview dashboard","content":{"application/json":{"schema":{"type":"object","allOf":[{"$ref":"#/components/schemas/SingleView"},{"properties":{"aggregationType":{"type":"string","enum":["day","week","month","year"]},"dataType":{"type":"string","enum":["totalEngagement","engagedMembers"]}},"type":"object","property":null}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"Unauthorized.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ExpiredToken"},{"$ref":"#/components/schemas/InvalidToken"},{"$ref":"#/components/schemas/Unauthorized"}]}}}},"403":{"$ref":"#/components/responses/AccessDenied"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.openloyalty.io/api-reference/data-analytics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
