> ## Documentation Index
> Fetch the complete documentation index at: https://www.propeldata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query APIs

> Expose any ClickHouse table as an API.

<div />

Out-of-the-box Query APIs for the most common analytics use cases and data visualizations.

<CardGroup cols={2}>
  <Card title="SQL API" icon="database" href="/docs/query-apis/sql-api">
    Execute SQL queries from your application.
  </Card>

  <Card title="Counter" icon="calculator" href="/docs/query-apis/counter">
    Get a single aggregated value for a time range.
  </Card>

  <Card title="Data Grid" icon="table" href="/docs/query-apis/data-grid">
    Get a table of records from a Data Pool.
  </Card>

  <Card title="Leaderboard" icon="trophy" href="/docs/query-apis/leaderboard">
    Get aggregated values grouped by common dimensions.
  </Card>

  <Card title="Metric Report" icon="file-chart-column" href="/docs/query-apis/metric-report">
    Get multiple aggregated values grouped by common dimensions.
  </Card>

  <Card title="Time Series" icon="chart-line" href="/docs/query-apis/time-series">
    Get ready-to-chart time series data.
  </Card>

  <Card title="Top Values" icon="list-ol" href="/docs/query-apis/top-values">
    Get the most frequent non-null values in a column.
  </Card>
</CardGroup>

You can test your GraphQL API requests without writing a single line of code in our [API Playground](https://console.propeldata.com/playground/graphql/).

## Common features

All of our APIs offer the following features:

<AccordionGroup>
  <Accordion title="Pre-defined or inline metric aggregations" icon="chart-simple">
    Make API requests using pre-defined or inline Metric definitions.

    Query using an in-line metric definition:

    ```graphql Query theme={"system"}
    query TimeSeriesExample {
      timeSeries(input: {
        metric: {
          count: {
            dataPool: {
              name: "TacoSoft Demo Data"
            }
          }
        }:
      }) {
        ...
      }
    }
    ```

    Query using a pre-defined metric definition by ID:

    ```graphql Query theme={"system"}
    query TimeSeriesExample {
      timeSeries(input: {
        metric: {
          id: "METXXXXXXXXXXXXXXXXXXXXXXXXXX"
        }
      }) {
        ...
      }
    }
    ```

    Query using a pre-defined metric definition by name:

    ```graphql Query theme={"system"}
    query TimeSeriesExample {
      timeSeries(input: {
        metric: {
          name: "sales"
        }
      }) {
        ...
      }
    }
    ```
  </Accordion>

  <Accordion title="Built-in relative time ranges" icon="clock">
    Built-in relative time ranges make it easy to implement common scenarios:

    * Current periods: `THIS_HOUR`, `TODAY`, `THIS_WEEK`, `THIS_MONTH`, `THIS_QUARTER`, `THIS_YEAR`
    * Previous periods: `PREVIOUS_HOUR`, `YESTERDAY`, `PREVIOUS_WEEK`, `PREVIOUS_MONTH`, `PREVIOUS_QUARTER`, `PREVIOUS_YEAR`
    * Next periods: `NEXT_HOUR`, `TOMORROW`, `NEXT_WEEK`, `NEXT_MONTH`, `NEXT_QUARTER`, `NEXT_YEAR`
    * Last N periods: `LAST_N_MINUTES`, `LAST_N_HOURS`, `LAST_N_DAYS`, `LAST_N_WEEKS`, `LAST_N_MONTHS`, `LAST_N_QUARTERS`, `LAST_N_YEARS`
  </Accordion>

  <Accordion title="Absolute time ranges" icon="calendar">
    Absolute time ranges allow for precise date and time selection.

    ```graphql Query theme={"system"}
    query TimeSeriesExample {
      timeSeries(input: {
        ...
        timeRange: {
          absolute: { start: "2024-01-01", end: "2024-01-05" }
        }
      }) {
        ...
      }
    }
    ```
  </Accordion>

  <Accordion title="Filtering" icon="filter">
    Apply filters using SQL syntax.

    ```graphql theme={"system"}
    query TimeSeriesExample {
      timeSeries(input: {
        ...
        filterSql: "(restaurant_name = 'El Buen Sabor') AND (taco_total_price > 100)"
      }) {
        ...
      }
    }
    ```
  </Accordion>

  <Accordion title="Timezone support" icon="globe">
    Calculates the relative time ranges for the given time zone, allowing for accurate representation of data across different geographical locations.

    ```graphql Query theme={"system"}
    query TimeSeriesExample {
      timeSeries(input: {
        ...
        timeZone: "America/Los_Angeles"
      }) {
        ...
      }
    }
    ```
  </Accordion>

  <Accordion title="FINAL modifier" icon="check-double">
    Automatically adds the FINAL modifier to queries on ReplacingMergeTree tables, ensuring that the latest data is always used.
  </Accordion>

  <Accordion title="Secured by Access Policies" icon="shield">
    Access Policies are enforced for all Query APIs.

    <p>For more details, see our <a href="/docs/access-policies">Access Policies documentation</a>.</p>
  </Accordion>

  <Accordion title="Multi-tenant JWT tokens" icon="key">
    Use JWT tokens to secure multi-tenant applications with any Data API.

    <p>For more details, see our <a href="/docs/multi-tenant-jwt-tokens">Multi-tenant JWT tokens documentation</a>.</p>
  </Accordion>
</AccordionGroup>
