# Export API

The Logilica platform enables you to query your data using a semantic data layer.

### Using the API

The following example shows how to use the Export API to fetch the average lead time for tickets within a workspace.

The cURL GET command is below. Note, that the GET command includes the example API token `lgca_UeRxFs_3RYRJEJtdYp7j7Wa6DirG5NjiYslsb` and the example workspace `myworkspace`.

```bash
curl --location  -G 'https://logilica.io/api/query/load' \
    --header 'X-lgca-token: lgca_UeRxFs_3RYRJEJtdYp7j7Wa6DirG5NjiYslsb' \
    --header 'x-lgca-domain: myworkspace' \
    --data-urlencode 'query={
        "measures":["JiraIssueDetail.avgLeadTime"],
        "dimensions":[],
        "filters":[],
        "timeDimensions":[]}'
```

The above query returns the following response.

```json
{
    "query": {
        "measures": [
            "JiraIssueDetail.avgLeadTime"
        ],
        "dimensions": [],
        "filters": [],
        "timeDimensions": [],
        "limit": 10000,
        "timezone": "UTC",
        "rowLimit": 10000
    },
    "data": [
        {
            "JiraIssueDetail.avgLeadTime": 1353.4052033405958
        }
    ],
    "lastRefreshTime": "2024-10-31T04:57:55.297Z"
    // ... additional metadata
}
```

The result of the query is provided in the `data` field of the response. The query that was run is also returned, along with some other metadata including the last time the data was refreshed by the semantic layer.

### Query Format

Queries to the semantic layer are constructed as JSON objects, and have the following fields:

<table><thead><tr><th width="216">Field</th><th width="201">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>dimensions</code></td><td><code>string[]</code></td><td>A list of dimensions as found in the <a href="/pages/kOHUJnr8RPju2lGYX31G">DataStudio Data Model</a></td></tr><tr><td><code>measures</code></td><td><code>string[]</code></td><td>A list of measures as found in the <a href="/pages/kOHUJnr8RPju2lGYX31G">DataStudio Data Model</a></td></tr><tr><td><code>filters</code></td><td><code>Filter[]</code></td><td>A list of <a href="#filters">filter objects</a> to apply to the query</td></tr><tr><td><code>timeDimensions</code></td><td><code>TimeDimensions[]</code></td><td>A list of <a href="#time-dimensions">time dimensions</a> to filter the query on</td></tr><tr><td><code>order</code></td><td><code>object</code></td><td>Key/value pairs of measures/dimensions and direction to sort ("asc" or "desc")</td></tr></tbody></table>

Each of these fields are required, however they may be empty (e.g. an empty list or an object with no keys).

Below is an example query that fetches the number of Resolved ticket events for the team "Example Team" per Jira Issue Type for the month of October 2024. This shows the weekly ticket throughput for the team.

```json
{
    "measures": [
        "JiraIssueEvent.eventCount"
    ],
    "dimensions": [
        "JiraIssueDetail.type"
    ]
    "timeDimensions": [
        {
            "dimension": "JiraIssueEvent.timeInterval",
            "granularity": "week",
            "dateRange": [ "2024-10-01", "2024-10-31" ]
        }
    ],
    "filters": [
        {
            "member": "JiraIssueEvent.event",
            "operator": "equals",
            "values": [
                "Resolved"
            ]
        },
        {
            "member": "JiraIssueDetail.statusCategory",
            "operator": "equals",
            "values": [
                "Done"
            ]
        },
        {
            "member": "Team.name",
            "operator": "equals",
            "values:" [ "Example Team" ]
        }
    ],
    "order": {
        "JiraIssueDetail.type": "asc"
    },

}
```

### Filters

Filters are objects that specify how to filter the data with respect to the dimensions and measures available. They contain the following fields:

<table><thead><tr><th width="216">Field</th><th width="201">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>member</code></td><td><code>string</code></td><td>The dimension or measure to use in the filter, a list of these can be found in the <a href="/pages/kOHUJnr8RPju2lGYX31G">DataStudio Data Model</a></td></tr><tr><td><code>operator</code></td><td><code>filter-operator</code></td><td>The comparison operator to use in the filter. One of <code>equals</code>, <code>notEquals</code>, <code>contains</code>, <code>notContains</code>, <code>startsWith</code>, <code>notStartsWith</code>, <code>endsWith</code>, <code>notEndsWith</code>, <code>gt</code>, <code>gte</code>, <code>lt</code>, <code>lte</code>, <code>set</code>, <code>notSet</code> . <a href="#filter-operators">See below for more information</a>.</td></tr><tr><td><code>values</code></td><td><code>string[]</code></td><td>Array of values for the filter. These must be of type string, with numbers being converted from strings by the semantic layer.</td></tr></tbody></table>

Both the `member` and `operator` field are required, the `value` field is only required for some operators.

#### Filter Operators

* `equals` - matches exactly on the `values` in the array
* `contains` - a case insensitive wild card match on the `values` in the array (similar to `LIKE %`)
* `startsWith` - matches any string that starts with one of the `values` in the values array
* `endsWith` - matches any string that ends with one of the `values` in the values array
* `gt` - matches numeric values greater than the value in the `values` array
* `gte` - matches numeric values greater than or equal to the value in the `values` array
* `lt` - matches numeric values less than the value in the `values` array
* `lte` - matches numeric values less than or equal to the value in the `values` array
* `set` - checks if the value is not null. This operator does not use the `values` array

A number of filter operators have a `not` equivalent (e.g. `notEquals`). These are the negations of the relevant operator. The `not` operators available are: `notEquals`, `notContains`, `notStartsWith`, `notEndsWith` and `notSet`.

### Time Dimensions

Time dimensions are filters specifically on time intervals. These allow you to specify the time interval you wish to fetch in your dataset.

<table><thead><tr><th width="216">Field</th><th width="201">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>dimension</code></td><td><code>string</code></td><td>The time dimension to use. These can be found in the <a href="/pages/kOHUJnr8RPju2lGYX31G">DataStudio Data Model</a> and typically have the name <code>timeInterval</code></td></tr><tr><td><code>dateRange</code></td><td><code>string[]</code></td><td>An array of two date strings, the first being the start time and the second being the end. For example, <code>[ "2024-10-01", "2024-10-31" ]</code></td></tr><tr><td><code>granularity</code></td><td><code>string</code></td><td>The granularity to group the data by. Can be <code>days</code>, <code>weeks</code>, <code>months</code>, <code>years</code></td></tr></tbody></table>

Both `dimension` and `dateRange` are required fields. Omitting `granularity` is permitted and will mean that your data is ungrouped by time.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.logilica.com/advanced/query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
