# Web Search API

Search the web for AI agents: ranked results with a page-text excerpt for each one, the published date when the page has one, and the domain. One result set per query, ready to drop into a prompt.

**Pricing:** $0.001 per result

**Endpoint:** `POST /v1/data/web/search/run`

**Auth:** `Authorization: Bearer mk_live_...`

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `query` | array | Yes | One or more search queries, written the way you would ask a search engine. Each query returns its own ranked results. |
| `maxResults` | integer | No | How many results to return for each query, up to 20. Defaults to 10; use 0 for the maximum of 20. |
| `country` | string | No | Two-letter country code to localise results to, e.g. us, in or gb. Leave blank for no country preference. |
| `freshness` | string | No | Only return pages published within this window. Pages with no published date are kept. |
| `includeDomains` | array | No | Only return results from these domains (and their subdomains), e.g. reuters.com. Up to 20. |
| `excludeDomains` | array | No | Never return results from these domains (and their subdomains), e.g. pinterest.com. Up to 20. |

## Example

`?wait=true` holds the request open until the run finishes (up to 60s) and returns the rows inline: one request, no polling.

```bash
curl -X POST "https://api.mindcase.co/v1/data/web/search/run?wait=true" \
  -H "Authorization: Bearer mk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"params":{"query":["..."]}}'
```

```python
import requests

resp = requests.post(
    "https://api.mindcase.co/v1/data/web/search/run",
    params={"wait": "true"},
    headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
    json={"params": {
    "query": [
        "..."
    ]
}},
)
rows = resp.json()["data"]
```

## Longer runs

If the run is still going at the 60s ceiling you get back `{ job_id, status: "running" }` instead of rows (same if the result is over 100 rows; those come back `truncated`). Poll with that `job_id`:

```bash
# 1) check status
curl https://api.mindcase.co/v1/jobs/JOB_ID \
  -H "Authorization: Bearer mk_live_YOUR_API_KEY"

# 2) when status == completed, fetch the rows
curl https://api.mindcase.co/v1/jobs/JOB_ID/results \
  -H "Authorization: Bearer mk_live_YOUR_API_KEY"
```

Full API reference (auth, jobs, balance, SDKs, MCP): https://mindcase.co/skills.md

## Response columns

| Field | Display name | Type |
|-------|--------------|------|
| `query` | Query | text |
| `position` | Position | integer |
| `title` | Title | text |
| `url` | URL | url |
| `domain` | Domain | text |
| `excerpt` | Excerpt | text |
| `publishedDate` | Published Date | date |
| `engine` | Engine | text |
| `fetchedAt` | Fetched At | datetime |
