# Query

The Query API allows you to retrieve data from Telemetry. It accepts basic SQL, enabling you to query all available data using commands such as JOINS and UNIONS. These queries can return a wide range of data, from system metrics to user engagement.

<mark style="color:green;">**POST**</mark> **`https://api.telemetry.sh/query`**

**Headers**

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Content-Type  | String | application/json  |
| Authorization | String | \<YOUR\_API\_KEY> |

**Body**

| Name  | Type   | Description               |
| ----- | ------ | ------------------------- |
| query | String | SQL Query you want to run |

### Example usage with cURL

To query the average Uber price grouped by city from the table named `uber_rides` using cURL, you can use the following command:

```
curl -X POST https://api.telemetry.sh/query \
  -H "Content-Type: application/json" \
  -H "Authorization: $API_KEY" \
  -d '{
    "query": "
      SELECT
        city,
        AVG(price) AS average_price
      FROM
        uber_rides
      GROUP BY
        city
      LIMIT
        10000;
    "
  }'
```

### Using the JavaScript SDK

We recommend using our SDKs for a better developer experience. Here’s an example of how to use our JavaScript SDK:

```javascript
const results = 
  await telemetry.query(`
    SELECT
      city,
      AVG(price)
    FROM
      uber_rides
    GROUP BY
      city
  `);
```


---

# 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.telemetry.sh/api-reference/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.
