# Combining URL Parameters

### How Parameters Chain

Append parameters to your endpoint URL with `?` for the first and `&` for each additional:

```
https://api.csvgetter.com/abc123?param1=value1&param2=value2&param3=value3
```

Parameters are processed in this order:

1. **Authentication** — Bearer token checked (if enabled)
2. **Data fetch** — Full dataset retrieved from source
3. **`all_fields`** — Override field selection (if set)
4. **`extract_json_property`** — Flatten linked records (if set)
5. **`sql`** — SQL query applied to filter/transform data
6. **`type`** — Output format applied
7. **`nest_json`** — JSON output wrapped in key (if set)
8. **`filename_timestamp`** — Filename modified (if set)
9. **Side effects** — `email_me`, `save_to_gdrive`, `save_to_gsheets`, etc.

***

### Recipe 1: Filter with SQL + Output as JSON + Email Notification

**Scenario:** You want active customers as JSON and get an email each time it runs.

```
https://api.csvgetter.com/abc123?sql=SELECT name, email, plan FROM csvgetter WHERE status='Active' ORDER BY name&type=json_records&email_me=true&email_tag=active-customers
```

| Parameter   | Value                                                                         | Purpose                                  |
| ----------- | ----------------------------------------------------------------------------- | ---------------------------------------- |
| `sql`       | `SELECT name, email, plan FROM csvgetter WHERE status='Active' ORDER BY name` | Filter to active, select 3 columns, sort |
| `type`      | `json_records`                                                                | JSON array of objects                    |
| `email_me`  | `true`                                                                        | Email notification                       |
| `email_tag` | `active-customers`                                                            | Label the notification                   |

***

### Recipe 2: Export to Google Drive with Timestamped Filename

**Scenario:** Daily backup of your Airtable data to Google Drive, with each file uniquely named.

```
https://api.csvgetter.com/abc123?save_to_gdrive=true&filename_timestamp=true
```

| Parameter            | Value  | Purpose                                 |
| -------------------- | ------ | --------------------------------------- |
| `save_to_gdrive`     | `true` | Save to connected Google Drive          |
| `filename_timestamp` | `true` | Append `_2025-03-15T143022` to filename |

Result: A file like `Customers_2025-03-15T143022.csv` appears in your Google Drive.

**With timestamp at the start:**

```
?save_to_gdrive=true&filename_timestamp=start
```

Result: `2025-03-15T143022_Customers.csv`

***

### Recipe 3: SQL Aggregation as Nested JSON for an API

**Scenario:** You're building a dashboard that expects data nested under a `data` key, showing department headcounts.

```
https://api.csvgetter.com/abc123?sql=SELECT department, COUNT(*) as headcount, AVG(salary) as avg_salary FROM csvgetter GROUP BY department ORDER BY headcount DESC&type=json_records&nest_json=data
```

| Parameter   | Value                                         | Purpose                          |
| ----------- | --------------------------------------------- | -------------------------------- |
| `sql`       | `SELECT department, COUNT(*) as headcount...` | Aggregate by department          |
| `type`      | `json_records`                                | JSON output                      |
| `nest_json` | `data`                                        | Wrap result in `{"data": [...]}` |

**Response:**

```json
{
  "data": [
    {"department": "Engineering", "headcount": 42, "avg_salary": 95000},
    {"department": "Marketing", "headcount": 18, "avg_salary": 72000}
  ]
}
```

***

### Recipe 4: Interactive Table for Stakeholders

**Scenario:** Share a browsable, searchable view of your data with non-technical team members.

```
https://api.csvgetter.com/abc123?type=dynamic_table&sql=SELECT name, role, department, start_date FROM csvgetter ORDER BY start_date DESC
```

| Parameter | Value                                          | Purpose                                   |
| --------- | ---------------------------------------------- | ----------------------------------------- |
| `type`    | `dynamic_table`                                | Interactive HTML with search + pagination |
| `sql`     | `SELECT name, role, department, start_date...` | Select relevant columns, sort by date     |

Share this URL directly — recipients see a searchable table in their browser.

***

### Recipe 5: Excel Import with Loading Page

**Scenario:** Large dataset that takes a few seconds to load. You want a "please wait" page rather than a browser timeout.

```
https://api.csvgetter.com/abc123?type=excel_web_query&show_wait_page=true
```

| Parameter        | Value             | Purpose                              |
| ---------------- | ----------------- | ------------------------------------ |
| `type`           | `excel_web_query` | Format for Excel's "From Web"        |
| `show_wait_page` | `true`            | Show loading page while data fetches |

***

### Recipe 6: Top 10 Records as XML

**Scenario:** Your integration requires XML and you only need the most recent 10 entries.

```
https://api.csvgetter.com/abc123?sql=SELECT * FROM csvgetter ORDER BY created_at DESC LIMIT 10&type=xml
```

| Parameter | Value                                  | Purpose           |
| --------- | -------------------------------------- | ----------------- |
| `sql`     | `...ORDER BY created_at DESC LIMIT 10` | Latest 10 records |
| `type`    | `xml`                                  | XML output        |

***

### Recipe 7: Filtered Data to Google Sheets

**Scenario:** Update a specific Google Sheet with only high-priority items.

```
https://api.csvgetter.com/abc123?sql=SELECT * FROM csvgetter WHERE priority='High'&save_to_gsheets=true&spreadsheet=SPREADSHEET_ID&sheet=Sheet1
```

| Parameter         | Value                      | Purpose                 |
| ----------------- | -------------------------- | ----------------------- |
| `sql`             | `...WHERE priority='High'` | Filter to high priority |
| `save_to_gsheets` | `true`                     | Write to Google Sheets  |
| `spreadsheet`     | Your spreadsheet ID        | Target spreadsheet      |
| `sheet`           | `Sheet1`                   | Target sheet/tab        |

***

### Recipe 8: Flattened Linked Records as JSON

**Scenario:** Your Airtable has linked record fields that return as JSON arrays. You want to extract just the names.

```
https://api.csvgetter.com/abc123?extract_json_property=name&type=json_records
```

| Parameter               | Value          | Purpose                                   |
| ----------------------- | -------------- | ----------------------------------------- |
| `extract_json_property` | `name`         | Extract `name` from linked record objects |
| `type`                  | `json_records` | JSON output                               |

**Before:**

```json
[{"assignee": "[{\"id\":\"rec1\",\"name\":\"Alice\"},{\"id\":\"rec2\",\"name\":\"Bob\"}]"}]
```

**After:**

```json
[{"assignee": "Alice, Bob"}]
```

***

### Recipe 9: Upload Training Data to OpenAI

**Scenario:** Send a filtered dataset to OpenAI for use with the Assistants API.

```
https://api.csvgetter.com/abc123?sql=SELECT question, answer FROM csvgetter WHERE verified='true'&save_to_openai=true&save_to_openai_filename=qa_training_data.csv
```

| Parameter                 | Value                      | Purpose                  |
| ------------------------- | -------------------------- | ------------------------ |
| `sql`                     | `...WHERE verified='true'` | Only verified Q\&A pairs |
| `save_to_openai`          | `true`                     | Upload to OpenAI         |
| `save_to_openai_filename` | `qa_training_data.csv`     | Custom filename          |

***

### Recipe 10: Authenticated Export with Email + Drive Backup

**Scenario:** Secure endpoint that also saves to Drive and notifies you.

```bash
curl -H "Authorization: Bearer my-secret-token" \
  "https://api.csvgetter.com/abc123?save_to_gdrive=true&filename_timestamp=end&email_me=true&email_tag=secure-backup"
```

| Parameter            | Value                    | Purpose                    |
| -------------------- | ------------------------ | -------------------------- |
| Auth header          | `Bearer my-secret-token` | Authenticate the request   |
| `save_to_gdrive`     | `true`                   | Backup to Drive            |
| `filename_timestamp` | `end`                    | Unique filename            |
| `email_me`           | `true`                   | Notification               |
| `email_tag`          | `secure-backup`          | Label for the notification |


---

# 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.csvgetter.com/platform-features/combining-url-parameters.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.
