Returns a list of all groups belonging to an account as per the specified criteria. This API is paginated and returns 20 groups by default. A group is uniquely identified by a 'group_key'. This key should be used in all the other API referencing a particular group.

Params

Param name Description
page
optional

Page number of results to be fetched, Default 1


Value: Must be Integer.
per
optional

Number of group records to be returned in one page, Default 20


Value: Must be Integer.
order_by
optional

Field on which resultant group records should be sorted


Value: Must be a String
order
optional

Order, “asc” or “desc”, in which results should be sorted


Value: Must be a String
timestamp_format
optional

Format, “str” or “int”, in which timestamps of the group records should be returned, Default “int”


Value: Must be a String
search
optional

Keywords based on which groups should be searched. Currently you can search groups on - group_key, name or tag


Value: Must be a String
scope
optional

Matching condition if multiple keywords are specified for search. Valid values are “all” or “any”. Default is “all”


Value: Must be a String
pretty
optional

Return a pretty formatted response if true, Default is false


Value: Must be a Boolean
field_list
optional

List of fields required in the result.


Value: Must be an array of any type
is_oem
optional

Returns groups of child accounts along with groups of oem account if is_oem flag is true.


Value: Must be one of: <code>true</code>, <code>false</code>, <code>true</code>, <code>false</code>.

Examples

Request - listing all groups without any criteria
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:49b7q_nYN4YZ2k-MsYx5Ng" https://api.datonis.io/api/v3/groups

Response (returns first 20 records)
{
  "total_count": 3,
  "page": 1,
  "groups": [
    {
      "created_at": 1448436290,
      "description": "",
      "group_key": "ca5ec715f2",
      "group_type": 1,
      "name": "Energy Meters Single Phase 30Amps",
      "scope": "all",
      "thing_expression": null,
      "updated_at": 1448436290,
      "tags": "1-Phase,30-Amps"
    },
    {
      "created_at": 1448436624,
      "description": "",
      "group_key": "d1b3572168",
      "group_type": 2,
      "name": "Red Refrigerators and Machines",
      "scope": "all",
      "thing_expression": "this.user_defined_properties.Color ==...
Request - listing groups by specifying number of groups to be returned at a time (page size) and specific set to be returned (page)
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:49b7q_nYN4YZ2k-MsYx5Ng" -d '{"per":"2","page":"2"}' https://api.datonis.io/api/v3/groups

Response (returns page 2 with 2 groups per page)
{
  "total_count": 3,
  "page": "2",
  "groups": [
    {
      "created_at": 1448437406,
      "description": "",
      "group_key": "88a714c562",
      "group_type": 1,
      "name": "Automated Washing Machines",
      "scope": "all",
      "thing_expression": null,
      "updated_at": 1448437406,
      "tags": "automated"
    }
  ]
}
Request - listing groups ordered by a field with string formatted timestamps
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:49b7q_nYN4YZ2k-MsYx5Ng" -d '{"timestamp_format":"str","order_by":"created_at","order":"desc"}' https://api.datonis.io/api/v3/groups

Response (returns groups in the reverse order of time that they were created at with timestamps in string format)
{
  "total_count": 3,
  "page": 1,
  "groups": [
    {
      "created_at": "2015/11/25 07:43:26",
      "description": "",
      "group_key": "88a714c562",
      "group_type": 1,
      "name": "Automated Washing Machines",
      "scope": "all",
      "thing_expression": null,
      "updated_at": "2015/11/25 07:43:26",
      "tags": "automated"
    },
    {
      "created_at": "2015/11/25 07:30:24",
      "description": "",
      "group_key": "d1b3572168",
      "group_type": 2,
      "name": "Red Refrigerators and Machines",
      "scope": "all",
      "thing_expression":...
Request - listing groups based on some search criteria with all keywords matching
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:49b7q_nYN4YZ2k-MsYx5Ng" -d '{"search":"Washing Machines"}' https://api.datonis.io/api/v3/groups

Response (returns groups containing both keywords 'Washing' as well as 'Machines')
{
  "total_count": 1,
  "page": 1,
  "groups": [
    {
      "created_at": 1448437406,
      "description": "",
      "group_key": "88a714c562",
      "group_type": 1,
      "name": "Automated Washing Machines",
      "scope": "all",
      "thing_expression": null,
      "updated_at": 1448437406,
      "tags": "automated"
    }
  ]
}
Request - listing groups based on some search criteria with any of the keywords matching
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:49b7q_nYN4YZ2k-MsYx5Ng" -d '{"search":"Washing Machines", "scope":"any"}' https://api.datonis.io/api/v3/groups

Response (returns groups containing either of the keywords 'Washing' or 'Machines')
{
  "total_count": 2,
  "page": 1,
  "groups": [
    {
      "created_at": 1448437406,
      "description": "",
      "group_key": "88a714c562",
      "group_type": 1,
      "name": "Automated Washing Machines",
      "scope": "all",
      "thing_expression": null,
      "updated_at": 1448437406,
      "tags": "automated"
    },
    {
      "created_at": 1448436624,
      "description": "",
      "group_key": "d1b3572168",
      "group_type": 2,
      "name": "Red Refrigerators and Machines",
      "scope": "all",
      "thing_expression": "this.user_defined_properties.Color == 'Red'",
      "updated_at": 1448437019,
      "tags": ""
    }
  ]
}