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

# Query API Quickstart

> Step-by-step walkthrough for your first Scrunch Query API call to fetch weekly brand presence, sentiment, and AI visibility metrics by platform.

### Prerequisites

* A Scrunch workspace
* An API key with **Query** access
* A **brand ID** for the brand you want to query

***

### Call the API

> [tab] cURL
>
> **1. Set your API key**
>
> Get your API key from **Organization Settings → API Keys** and set it and your brand ID as environment variables:
>
> ```bash theme={null}
> export SCRUNCH_API_KEY="your-api-key-here"
> export SCRUNCH_BRAND_ID="your-brand-id"
> ```
>
> **2. Make your first Query API request**
>
> This example retrieves **weekly brand presence** for the last 30 days.
>
> ```bash theme={null}
> curl "https://api.scrunchai.com/v1/$SCRUNCH_BRAND_ID/query?fields=date_week,brand_presence_percentage&start_date=2025-01-01&end_date=2025-01-31" \
>   -H "Authorization: Bearer $SCRUNCH_API_KEY" \
>   -H "Accept: application/json"
> ```
>
> **Example output:**
>
> ```json theme={null}
> {
>   "total": 4,
>   "limit": 1000,
>   "offset": 0,
>   "rows": [
>     {
>       "date_week": "2025-01-06",
>       "brand_presence_percentage": 42.1
>     },
>     {
>       "date_week": "2025-01-13",
>       "brand_presence_percentage": 47.8
>     }
>   ]
> }
> ```

> [tab] Python
>
> **1. Install dependencies**
>
> ```bash theme={null}
> pip install requests pandas
> ```
>
> **2. Create your script**
>
> ```python theme={null}
> import requests
> import pandas as pd
>
> API_KEY = "your-api-key"
> BRAND_ID = "your-brand-id"
> BASE_URL = f"https://api.scrunchai.com/v1/{BRAND_ID}/query"
>
> params = {
>     "fields": "date_week,brand_presence_percentage",
>     "start_date": "2025-01-01",
>     "end_date": "2025-01-31",
> }
>
> response = requests.get(
>     BASE_URL,
>     headers={"Authorization": f"Bearer {API_KEY}"},
>     params=params,
>     timeout=30,
> )
> response.raise_for_status()
>
> data = response.json()
> df = pd.DataFrame(data)
> print(df)
> ```
>
> **3. Run your code**
>
> ```bash theme={null}
> python quickstart.py
> ```

> [tab] JavaScript / TypeScript
>
> **1. Install Axios**
>
> ```bash theme={null}
> npm install axios
> ```
>
> **2. Create your code**
>
> ```javascript theme={null}
> import axios from "axios";
>
> const API_KEY = "your-api-key";
> const BRAND_ID = "your-brand-id";
>
> async function main() {
>   const url = `https://api.scrunchai.com/v1/${BRAND_ID}/query`;
>
>   const response = await axios.get(url, {
>     headers: { Authorization: `Bearer ${API_KEY}` },
>     params: {
>       fields: "date_week,brand_presence_percentage",
>       start_date: "2025-01-01",
>       end_date: "2025-01-31",
>     },
>   });
>
>   console.log(response.data.rows);
> }
>
> main().catch(console.error);
> ```
>
> **3. Run your code**
>
> ```bash theme={null}
> node quickstart.js
> ```

***

## Next steps

> [card] [Query API overview](https://developers.scrunch.com/api-reference/query/overview.md)
>
> Learn how fields, dimensions, and metrics work together.

> [card] [Build dashboards](https://developers.scrunch.com/integrations/looker-studio.md)
>
> Send Query data into Looker Studio or your BI tool.

> [card] [Responses API](https://developers.scrunch.com/api-reference/responses/overview.md)
>
> Get full answers, citations, and sentiment when you need row-level detail.


## Related topics

- [Query API: Aggregated AI Visibility Metrics](https://developers.scrunch.com/api-reference/query/overview.md)
- [Structured Query API: Multi-Metric JSON Endpoint](https://developers.scrunch.com/api-reference/query/structured-query.md)
- [Responses API Quickstart](https://developers.scrunch.com/getting-started/quickstart-responses.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.