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

# Search

> Search the web and get ranked results, each scraped to clean data.

`POST /v1/web/search` runs a query against the web and returns ranked results. Turn on `scrapeResults` and every result also comes back with its page already fetched and cleaned, so a single call turns a question into a set of LLM-ready documents with no second round of scraping.

## When to use it

* You know what you're looking for but not the exact URLs — let a query find the pages.
* You want the top few sources on a topic returned as clean Markdown, ready to feed a model.
* You need to bias results to a region, a recency window, or a specific set of domains.

Search is synchronous: send the query, get results back in one response.

## Example request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.hydrafetch.com/v1/web/search \
    -H "X-API-Key: hf_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "query": "best open source vector databases",
      "limit": 3,
      "timeRange": "month"
    }'
  ```

  ```javascript Node theme={null}
  const res = await fetch("https://api.hydrafetch.com/v1/web/search", {
    method: "POST",
    headers: {
      "X-API-Key": "hf_your_key_here",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      query: "best open source vector databases",
      limit: 3,
      timeRange: "month",
    }),
  });
  const { data } = await res.json();
  for (const r of data.results) {
    console.log(r.rank, r.title, r.url);
    console.log(r.data?.markdown);
  }
  ```

  ```python Python theme={null}
  import requests

  res = requests.post(
      "https://api.hydrafetch.com/v1/web/search",
      headers={"X-API-Key": "hf_your_key_here"},
      json={
          "query": "best open source vector databases",
          "limit": 3,
          "timeRange": "month",
      },
  )
  for r in res.json()["data"]["results"]:
      print(r["rank"], r["title"], r["url"])
      print((r["data"] or {}).get("markdown"))
  ```
</CodeGroup>

## Example response

Each result carries its rank and the usual title/url/snippet. Turn on `scrapeResults` and each one also carries a `data` object holding the scraped page; otherwise `data` is `null`.

```json theme={null}
{
  "data": {
    "query": "best open source vector databases",
    "status": "ok",
    "results": [
      {
        "title": "Best open source vector databases",
        "url": "https://example.com/vector-databases",
        "snippet": "A rundown of the leading open source vector databases and how they compare.",
        "rank": 1,
        "data": {
          "url": "https://example.com/vector-databases",
          "finalUrl": "https://example.com/vector-databases",
          "status": 200,
          "metadata": { "title": "Best open source vector databases", "pageType": "article" },
          "markdown": "# Best open source vector databases\n\n..."
        }
      }
    ]
  }
}
```

## Key options

<ParamField body="query" type="string" required>
  What to search the web for. Up to 500 characters.
</ParamField>

<ParamField body="limit" type="number" default="5">
  How many ranked results to return, from 1 to 15.
</ParamField>

<ParamField body="scrapeResults" type="boolean" default="false">
  When `true`, each result also comes back with its page fetched and returned as clean data, at **1 extra credit per page scraped**. Leave it off to get just the ranked title, url, and snippet for the flat search credit.
</ParamField>

<ParamField body="scrapeOptions" type="object">
  How to scrape each result, using the same options as [Scrape](/endpoints/scrape) — pick `formats`, force JavaScript rendering, set a per-page `timeout`, choose a `location`, and more. Applied to every result. Ignored when `scrapeResults` is `false`.
</ParamField>

<ParamField body="timeRange" type="string">
  Restrict results to a recency window relative to now: `day`, `week`, `month`, or `year`.
</ParamField>

<ParamField body="country" type="string">
  ISO 3166 alpha-2 country code (for example `us`, `de`) to bias results toward a region.
</ParamField>

<ParamField body="includeDomains" type="string[]">
  Only return results from these domains. Up to 15.
</ParamField>

<ParamField body="excludeDomains" type="string[]">
  Drop results from these domains. Up to 15.
</ParamField>

## Response fields

<ResponseField name="data.query" type="string">
  The query you searched.
</ResponseField>

<ResponseField name="data.results" type="object[]">
  The ranked results. Each item has `title`, `url`, `snippet`, `rank`, and `data` — the scraped page when `scrapeResults` is on, otherwise `null`.
</ResponseField>

## Billing

A search costs **1 credit**. If you turn on `scrapeResults`, each result that is actually scraped costs **1 more**, the same as scraping that page directly. Scraping is off by default, so a plain search is always 1 credit. As always, you're charged only on success, and the response reports what it consumed.

<Note>
  Richer `scrapeOptions` formats on each result can raise the per-result cost, the same way they do for a direct scrape. See [Credits](/concepts/credits).
</Note>

## Related

<CardGroup cols={2}>
  <Card title="Scrape" icon="https://mintcdn.com/hydrafetch/DnAi7n_kype0jB2E/icons/file-content.svg?fit=max&auto=format&n=DnAi7n_kype0jB2E&q=85&s=478eea6173d8c82bf8c41ab7277656bf" href="/endpoints/scrape" width="18" height="18" data-path="icons/file-content.svg">
    The per-result scrape engine behind search, on a single URL.
  </Card>

  <Card title="Extract" icon="https://mintcdn.com/hydrafetch/DnAi7n_kype0jB2E/icons/table-rows.svg?fit=max&auto=format&n=DnAi7n_kype0jB2E&q=85&s=5d1d78d52ed95a895e83fb2b9fec9284" href="/endpoints/extract" width="18" height="18" data-path="icons/table-rows.svg">
    Turn found pages into schema-shaped JSON, or let extract run its own web search.
  </Card>

  <Card title="Formats" icon="https://mintcdn.com/hydrafetch/koPVMLXM3S4OTC3p/icons/layers.svg?fit=max&auto=format&n=koPVMLXM3S4OTC3p&q=85&s=eed78667f725d33cd5193a7118a8ba5c" href="/concepts/formats" width="18" height="18" data-path="icons/layers.svg">
    Everything `scrapeOptions` can return per result.
  </Card>

  <Card title="API Reference" icon="https://mintcdn.com/hydrafetch/koPVMLXM3S4OTC3p/icons/code.svg?fit=max&auto=format&n=koPVMLXM3S4OTC3p&q=85&s=ce116045b848b9f082595f6161ed7383" href="/api-reference" width="18" height="18" data-path="icons/code.svg">
    Full `POST /v1/web/search` schema and a live playground.
  </Card>
</CardGroup>


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