# API for Events

## Endpoint

Use the APIs in this section with the `/events-query` endpoint.

## Supported queries

### events

Gets a list of events based on time, filters, and specified limit.

### eventCounts

Gets the count of events; optionally grouped by rounded timestamp, and/or by `facetType` or label name.

## Prerequisites

- Configure a GraphQL client. See [GraphQL](https://www.graphql-js.org/docs/graphql-clients/) documentation.
- Authenticate using the basic HTTP authentication protocol.

## events

Gets a list of events based on time, filters, and specified limit.

### Syntax

```javascript
events(
  timestamp: Time (1)
  durationSecs: Int (2)
  filter: EventFilter (3)
  offset: Int (4)
  limit: Int (5)
  sortBy: EventSortBy (6)
  sortOrder: SortOrder (7)
    ): [Event!] (8)
```

|     |     |
| --- | --- |
| **1** | `timestamp`: Events start at this timestamp; defaults to `now()`. |
| **2** | `durationSecs`: Duration for going back; defaults to 300 seconds. |
| **3** | `filter`: The filter on events. |
| **4** | `offset`: Use this for sequential processing of large sets, where the overall number of expected results exceeds the `limit`. |
| **5** | `limit`: Limited to this maximum; default is 200. |
| **6** | `sortBy`: Specifies the column on which to sort the list; default is `timestamp`. |
| **7** | `sortOrder`: Specifies the sort order; default is descending. |
| **8** | Returns the list of events. |

### Example

## eventCounts

Gets the count of events; optionally grouped by rounded timestamp, and/or by `facetType` or label name.

### Syntax

```javascript
eventCounts(
  timestamp: Time (1)
  durationSecs: Int (2)
  filter: EventFilter (3)
  countUnique: String (4)
  groupBys: [String!] (5)
  roundSecs: Int (6)
  topOrBottomK: TopOrBottomK (7)
  limit: Int (8)
): [EventCount!] (9)
```

|     |     |
| --- | --- |
| **1** | `timestamp`: Events start at this timestamp; defaults to `now()`. |
| **2** | `durationSecs`: Duration for going back; defaults to 300 seconds. |
| **3** | `filter`: The filter on events. |
| **4** | `countUnique`: If specified, performs the cardinality count of the number of unique events by the facet type (prefixed with '@') or label name. If not specified, computes the standard count. |
| **5** | `groupBys`: Groups events by facet type (prefixed with '@') and/or label names; defaults to everything. |
| **6** | `roundSecs`: Number of seconds to round the timestamp. If not specified, the count is over the full time range. |
| **7** | `topOrBottomK`: Specifies the sort order. Applies _top k_ or _bottom k_, based on count, for each rounded timestamp (optional). |
| **8** | `limit`: Limited to this maximum; default is 200. |
| **9** | Returns the count(s) of events. |

### Example
