> 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/retrieve-units-overview.md).

# Retrieve units overview

Management\
\
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.

````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":"http","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\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.\\\nTo refresh admin token `POST /api/token/refresh` [Go to definition](#operation/tokenRefresh)\n","bearerFormat":"JWT","scheme":"bearer"},"token":{"type":"apiKey","name":"X-AUTH-TOKEN","in":"header","description":"Send the admin API key in this header. The `?auth_token=` query parameter is deprecated and is being switched off environment by environment — credentials in URLs land in access logs, proxies and browser history — so do not rely on it.\n"}},"parameters":{"storeCode":{"name":"storeCode","in":"path","description":"Store code","required":true,"schema":{"type":"string"}}},"schemas":{"UnitsOverview":{"properties":{"intervalStartDate":{"type":"string","format":"date"},"intervalEndDate":{"type":"string","format":"date"},"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":["code","message"],"properties":{"code":{"type":"integer"},"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"}]}}}},"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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.openloyalty.io/api-reference/data-analytics/retrieve-units-overview.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
