> 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
  `);
```
