> For the complete documentation index, see [llms.txt](https://docs.telemetry.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.telemetry.sh/api-reference/query.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.telemetry.sh/api-reference/query.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
