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

# Response format

> Structure of the Andi AI Search API response, including result types and instant answers.

All responses are JSON objects. The `format=context` option returns markdown text instead — see [query parameters](/features/query-parameters) for details.

<Tip>
  The `results_type` field tells you the shape of the response. Use it to determine which arrays and objects are present — for example, `results_type: "weather"` means a `weather` object is included.
</Tip>

## Top-level fields

| Field              | Type   | Always present | Description                                                         |
| ------------------ | ------ | -------------- | ------------------------------------------------------------------- |
| `results_type`     | string | Yes            | Category of results (e.g., `search`, `news`, `images`)              |
| `answer`           | string | Yes            | Generated answer for the query (may be empty)                       |
| `type`             | string | Yes            | Same as `results_type`                                              |
| `title`            | string | Yes            | Title summarizing the search results                                |
| `results`          | array  | Yes            | Search results                                                      |
| `metrics`          | object | Yes            | Search performance metrics                                          |
| `correctedQuery`   | string | No             | Spell-corrected query (deep search only, when a correction is made) |
| `related_searches` | array  | No             | Related search suggestions                                          |
| `topics`           | array  | No             | Related topics                                                      |

### Type-specific arrays

Depending on the query intent, the response may include additional arrays alongside `results`:

| Field       | Present when              |
| ----------- | ------------------------- |
| `videos`    | Video intent queries      |
| `images`    | Image intent queries      |
| `news`      | News intent queries       |
| `places`    | Location/business queries |
| `profiles`  | People-related queries    |
| `socials`   | Social media queries      |
| `academics` | Scholarly queries         |

## Search results

Each result in the `results` array has this structure:

| Field         | Type   | Always present | Description                                                        |
| ------------- | ------ | -------------- | ------------------------------------------------------------------ |
| `title`       | string | Yes            | Page title                                                         |
| `link`        | string | Yes            | Page URL (returned as `url` when `linkFormat=url`)                 |
| `desc`        | string | Yes            | Page description or summary                                        |
| `source`      | string | Yes            | Domain name                                                        |
| `type`        | string | Yes            | Result type (see [result types](#result-types))                    |
| `date`        | string | No             | Publication date                                                   |
| `image`       | string | No             | Preview image URL                                                  |
| `snippet`     | string | No             | Query-relevant text excerpt (distinct from `desc`)                 |
| `answer`      | string | No             | Inline answer for instant answer results                           |
| `extracts`    | array  | No             | Text extracts from the page, when available (when `extracts=true`) |
| `contentType` | string | No             | Content type (when `metadata=full`)                                |
| `reader`      | object | No             | Extracted page content (when `metadata=full`)                      |

### Accessing key fields

```python theme={null}
data = response.json()

for result in data["results"]:
    # Always present
    print(result["title"], result["link"], result["source"])

    # Optional fields — check before accessing
    if result.get("snippet"):
        print(f"Snippet: {result['snippet']}")
    if result.get("extracts"):
        print(f"Extract: {result['extracts'][0][:200]}")
    if result.get("date"):
        print(f"Published: {result['date']}")
```

## Result types

The `type` field indicates the kind of result:

| Type             | Description                      |
| ---------------- | -------------------------------- |
| `website`        | Standard web page                |
| `news`           | News article                     |
| `video`          | Video content                    |
| `image`          | Image content                    |
| `place`          | Business or place                |
| `profile`        | Person or entity profile         |
| `social`         | Social media content             |
| `academic`       | Scholarly or research content    |
| `calculation`    | Math computation result          |
| `weather`        | Weather data                     |
| `computation`    | Computed answer                  |
| `instant answer` | Direct answer to a factual query |

## Instant answers

Some queries trigger instant answers alongside regular results.

### Weather

Queries about weather return a `weather` object:

```json theme={null}
{
  "results_type": "weather",
  "answer": "",
  "type": "weather",
  "title": "Weather in San Francisco",
  "results": [],
  "weather": {
    "location": {
      "name": "San Francisco",
      "country": "US",
      "coordinates": {
        "latitude": 37.7749,
        "longitude": -122.4194
      }
    },
    "temperature": 62,
    "feelsLike": 59,
    "units": "imperial",
    "description": "Partly Cloudy",
    "humidity": 72,
    "windSpeed": 12,
    "windDirection": 270,
    "pressure": 1013,
    "icon": "partly-cloudy",
    "cloudiness": 40,
    "visibility": 10000,
    "timestamp": "2025-03-15T14:00:00Z"
  },
  "metrics": {
    "query": "weather san francisco",
    "intent": "WeatherIntent",
    "timestamp": "2025-03-15T14:00:01Z",
    "duration": 850,
    "queries_executed": 1,
    "api_requests_count": 2,
    "results_returned": 0,
    "total_results_found": 0
  }
}
```

Use the `units` parameter to get results in `metric` or `imperial`. The default is auto-detected from the `country` parameter.

### Calculation

Mathematical queries return a `calculation` object:

```json theme={null}
{
  "results_type": "computation",
  "answer": "",
  "type": "computation",
  "title": "150 * 1.08",
  "results": [],
  "calculation": {
    "expression": "150 * 1.08",
    "result": "162"
  },
  "metrics": { ... }
}
```

<Accordion title="Image results">
  Image queries return an `images` array with thumbnail and dimension data:

  ```json theme={null}
  {
    "results_type": "images",
    "answer": "",
    "type": "images",
    "title": "Mountain landscape images",
    "results": [],
    "images": [
      {
        "title": "Mountain landscape",
        "link": "https://example.com/photo",
        "image": "https://example.com/photo.jpg",
        "source": "example.com",
        "type": "image",
        "thumbnail": "https://example.com/photo_thumb.jpg",
        "width": "1920",
        "height": "1080"
      }
    ],
    "metrics": { ... }
  }
  ```

  Image results include `thumbnail` (thumbnail URL), `width`, and `height` as string values.
</Accordion>

## Parsing tips

* **Check `results_type` first** to know the response shape before accessing type-specific fields
* **`results` is always an array** but may be empty for instant answers (weather, calculations)
* **`desc` vs `snippet`**: `desc` is the page's general description; `snippet` is a query-relevant excerpt (when available)
* **`answer` at top level** is a generated answer string (may be empty); `answer` on individual results is an inline answer for instant answer result types
* **Optional fields** (`date`, `image`, `snippet`, `extracts`) may not be present on every result — always check before accessing

## Search intents

The `results_type` and `type` fields reflect what kind of search was performed. You can force an intent with the `intent` parameter, or let the API auto-detect it.

Common intent aliases:

| Alias       | Intent              | Extra fields  |
| ----------- | ------------------- | ------------- |
| `search`    | General web search  | —             |
| `news`      | News articles       | `news`        |
| `video`     | Video content       | `videos`      |
| `images`    | Image search        | `images`      |
| `weather`   | Weather queries     | `weather`     |
| `calculate` | Math expressions    | `calculation` |
| `wiki`      | Wikipedia/knowledge | —             |
| `code`      | Programming queries | —             |
| `recipe`    | Recipe search       | —             |
| `place`     | Business search     | `places`      |
| `time`      | Time queries        | —             |

See [query parameters](/features/query-parameters#intent-values) for the full list of intent aliases.

## Metrics

The response always includes a `metrics` object with search performance data:

```json theme={null}
{
  "results": [...],
  "metrics": {
    "query": "machine learning",
    "intent": "FallbackSearchIntent",
    "timestamp": "2025-03-15T14:00:01Z",
    "duration": 234,
    "queries_executed": 1,
    "api_requests_count": 3,
    "results_returned": 10,
    "total_results_found": 42
  }
}
```

| Field                 | Type    | Description                                                  |
| --------------------- | ------- | ------------------------------------------------------------ |
| `query`               | string  | The query as processed                                       |
| `intent`              | string  | Detected or forced search intent                             |
| `timestamp`           | string  | Timestamp of the request                                     |
| `duration`            | number  | Total request time in milliseconds                           |
| `queries_executed`    | integer | Number of queries executed                                   |
| `api_requests_count`  | integer | Number of API requests made                                  |
| `results_returned`    | integer | Results returned in this response                            |
| `total_results_found` | integer | Total results found across sources                           |
| `cached`              | boolean | Whether response was from cache (only present on cache hits) |

## Next steps

<CardGroup cols={2}>
  <Card title="Query parameters" icon="sliders" href="/features/query-parameters">
    Full parameter reference.
  </Card>

  <Card title="RAG pipeline" icon="brain" href="/examples/rag-pipeline">
    Use search results as LLM context.
  </Card>
</CardGroup>
