A Successful response will return a 200 status and a JSON encoded body in the following format:

{
        "devices": <Array>,
        "index": <Number>,
        "counts": <Object>,
        "tags": <Array>,
        "filters": <Array>
    }

Devices

Serialized devices are returned in an array called devices.

Index

The index value from the request is returned in the response as "index". If index is not present in the query string, then 0 will be returned in the response.

"index": 2

Counts

A few statistics are returned in an object called counts.

Here's an example:

"counts":
    {
        "original": 10,
        "query": 8,
        "final": 3
    }

The original value contains the number of devices prior to any kind of filter. i.e. the total number
of devices owned by the user.

The query value contains the number of devices after filtering by text search and tag, but before
applying filters.

The final value contains the number of devices after all filtering. This should currently be same as
the length of the devices array. This may change in the future if we implement pagination or some
other limit of the max results.

These statistics could be used to render a message along the lines of "showing 3 of 8 results".

Tags

The tags value is an array of all possible tags that may be used to restrict the search.

Here's an example:

"tags":
    [
        {
            "name": "Tagged by green colour",
            "uid": "qwertyui-1234-1234-1234-12abcdefgijk"
        },
        {
            "name": "Tagged by red colour",
            "uid": "jkloty66-erty-erty-erty-4567cdefooop"

        }
    ]

The name value should be presented to the user, the uid value should be used in the query string
to filter devices.

Filters

The filters value is an array of objects that describe the key/value filters that may used to
further results.

Here is an example:

"filters":
    [
        {
            "key": "os",
            "label": "Operating System",
            "values": [
                ["Linux (Ubuntu etc.)", "linux"],
                ["OSX (Mac)", "OSX"],
                ["Windows, "Windows"],
                ["Unknown", ""]
            ]
        }
    ]

There may be 0 or more filters returned in the response. Note that this list changes in response
to the search key and tags. For instance, if all the devices are for the linux OS then the os
filter will be omitted in the response.

A filter is given in the following format:

{
        "key": String,
        "label": String,
        "values": Array of Arrays
    }

The key is the key used in the request, label is the text that should be presented to the user,
values is a list of potential values for the filter. A value consists of an array of two items;
the first is the label to be displayed to the user, and the second is the value to be sent in the
request.

It is expected that filter information is presented to the user as the label, and a list of check-boxes.
For instance the above response would be rendered something along these lines:

Operating System

[ ] Linux (Ubuntu etc.)
[ ] OSX (Mac)
[ ] Windows
[ ] Unknown