Query

With the Query endpoint, we provide an easy way to grab the events in your log. By using the Loggr Query Language you can make a single call to get individual events or aggregated data about the events.

URL

GET /logs/{logkey}/query?query={lql}&tz={offset}

Request

// This example returns the text field for last 5 events that were posted 

GET /logs/foo/query?query=GET%20events%20TAKE%205%20SORT%20created%20DESC%20OCCURS(TODAY)%20COLUMNS(text)&tz=-5

You will need to URL encode the actual query for it to work. See the Loggr Query Language page for more details on queries you can use.

The tz parameter specifies the timezone offset. When running queries in the browser, your current timezone offset is automatically set. If ommited it assumes UTC. The example above uses the value -5 which represents EST. The table below shows common values for tz:

Timezone tz Value Type
Japan 9
E Central Africa 2
UTC 0 (default)
US Eastern -5
US Central -6
US Mountain -7
US Pacific -8
Pacific Ocean -11

The query method requires READ authorization, so make sure you are passing an APIKEY that is allowed to read.

Response

If your request does not do any grouping, you will get an array of events back, like:

Status: 200 OK

[
    {
        "id":"4dfdff994e1feb0b4c0020ef",
        "created":"\/Date(1308491673911)\/",
        "text":"A user was created",
        "link":"",
        "hash":"LiWqANduFe+cia1nMTfN+g==",
        "tags":["user","created"],
        "source":"web3",
        "log":"sample"
        "class":"created",
        "data":true,
        "geo":null,
        "value":null
    }
]

If your request does grouping, you will get an array of aggregate info like below. Notice that the results are for a query that groups by DAY so the key will be a date.

Status: 200 OK

[
    {
        "key":"9/19/2011",
        "count":"10",
        "avg":"83",
        "sum":"157",
        "min":"28",
        "max":"224"
    }
]