# Tenant statistics based on device type

**URL:** <https://community.cumulocity.com/t/tenant-statistics-based-on-device-type/7608>\
**Category:** Forum\
**Tags:** development, api, cumulocity\
**Created:** [June 6, 2023, 1:33pm UTC](https://community.cumulocity.com/t/tenant-statistics-based-on-device-type/7608 "2023-06-06T13:33:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhorst](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@jhorst](https://community.cumulocity.com/u/jhorst)\
**Post date:** [June 6, 2023, 1:33pm UTC](https://community.cumulocity.com/t/tenant-statistics-based-on-device-type/7608/1 "2023-06-06T13:33:17Z")

</div>

I am developing an application to visualize the history of statistics of tenants.  
Currently, I am using the statistics API route for that. Specifically, to visualize the device count by day (_GET_ /tenant/statistics). The problem is that i also need to know the number of devices by device type (preferably grouped by the c8y\_hardware Fragment).

But I currently see no way to get this kind of results from the API or generally filter historical statistic data in any kind.  
Is there something I am missing here?

---

<div class="post-metadata">

**Author:** ![Korbinian\_Butz](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/korbinian_butz/32/10473_2.png) [@Korbinian\_Butz](https://community.cumulocity.com/u/Korbinian_Butz)\
**Post date:** [June 6, 2023, 6:47pm UTC](https://community.cumulocity.com/t/tenant-statistics-based-on-device-type/7608/2 "2023-06-06T18:47:15Z")

</div>

I don’t think you’re missing something. The Device Count is part of the usage statistics - but the count is not grouped by Device Type, it’s always the total Device Count.

What you could do is implementing a service that does these counts in a scheduled manner, e.g. once per day, via API. The count results you could send as Measurements to a dedicated Device. Once there you can create a Dashboard with e.g. KPI Widgets and Datapoint Graphs to display data - or work with the data in the App you are developing at the moment.

// Edit: To count devices you could use:

```plaintext
GET /inventory/managedObjects?q=$filter=(type eq 'your-device-type')&pageSize=1&withChildren=false&withTotalElements=true
or
GET /inventory/managedObjects?q=$filter=(c8y_Hardware.model eq 'your-hw-model')&pageSize=1&withChildren=false&withTotalElements=true

```

… and extract count from `statistics.totalElements` field.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [December 3, 2023, 6:47pm UTC](https://community.cumulocity.com/t/tenant-statistics-based-on-device-type/7608/3 "2023-12-03T18:47:47Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
