# Highlights and page text

Three sizes of text for each result: the snippet, the passages that best answer the query, and the page itself.

A search result can carry three sizes of text. Choose by what the model that reads it needs, and by what you want to pay.

| You want | Send | Comes back in | Cost |
|---|---|---|---|
| A short extract around the match | nothing, or `max_chars_per_result` (0 to 2,000) | `snippet` | Free |
| The passages that best answer the query | `max_highlights` (0 to 5; 0 is off) | `highlights`, `highlight_spans` | Free |
| The text of the page | `include_content: true` | `content` | 1 credit a call for the text of up to 10 results; 1 more for each further 10 with text |

## Highlights

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "sourdough starter hydration", "max_highlights": 3 }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "sourdough starter hydration",
        "max_highlights": 3
    },
    timeout=30,
)
r.raise_for_status()
for hit in r.json()["data"]["results"]:
    print(hit["position"], hit["title"], hit["url"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/search', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "query": "sourdough starter hydration",
    "max_highlights": 3
  }),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
  data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);
```

The same call as a tool of the MCP server:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "query": "sourdough starter hydration",
      "max_highlights": 3
    }
  }
}
```

`max_highlights` returns up to that many passages for each result, best first. `highlight_characters` sets how long one passage should be, and cannot be sent without `max_highlights`. Each highlight has a span in `highlight_spans`, in the same order:

| Field | Type | Notes |
|---|---|---|
| `start` | integer, 0 or more or null | Character offset (in Unicode code points) of the highlight in `content.text` as this result returns it. Null when there is nothing to point into: `include_content` was not sent, the highlight lies past the `max_characters` cut, or we hold no page text for the result. |
| `end` | integer or null | The offset just past the highlight. Null with `start`. |
| `score` | number, 0 to 1 | 1.0 is a full-length passage of plain prose that holds every word of the query. |

Without `max_highlights`, `highlights` is the snippet as a one-item list.

Highlights suit an agent that reads many results and decides which to open: they cost nothing and keep the context small.

## Page text

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "sourdough starter hydration",
    "num_results": 5,
    "include_content": true,
    "max_characters": 4000
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "sourdough starter hydration",
        "num_results": 5,
        "include_content": True,
        "max_characters": 4000
    },
    timeout=30,
)
r.raise_for_status()
for hit in r.json()["data"]["results"]:
    print(hit["position"], hit["title"], hit["url"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/search', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "query": "sourdough starter hydration",
    "num_results": 5,
    "include_content": true,
    "max_characters": 4000
  }),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
  data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);
```

The same call as a tool of the MCP server:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "query": "sourdough starter hydration",
      "num_results": 5,
      "include_content": true,
      "max_characters": 4000
    }
  }
}
```

`include_content: true` adds `content` to each `web` and `news` result: the text of the page as we hold it. `max_characters` cuts it (500 to 50,000, default 10,000) and cannot be sent without `include_content`.

| Field | Type | Notes |
|---|---|---|
| `text` | string | The page's text: menus and page chrome removed, e-mail addresses and phone numbers redacted, cut at `max_characters`. |
| `characters` | integer | Length of `text`. |
| `truncated` | boolean | True when the page is longer than `text`. |
| `captured_from` | string | The earliest day this copy can have been taken. Treat the page as being this old. |
| `captured_to` | string | The latest day this copy can have been taken. The same day as `captured_from` for news. |

Three things to know:

- **No request is made to the site.** The text comes from our own copy, so it is fast and it cannot be blocked. It is also as old as that copy: for a web result, `captured_from` and `captured_to` give the window in which the page was captured, and you should treat the page as being as old as `captured_from`.
- **We do not hold text for every result.** Those have `content: null`, are not charged for content, and the response carries a `content_partial` warning.
- **Only `web` and `news` have it.** On another source the filter is reported in a `filter_not_applied` warning, never ignored silently.

The text is cleaned: menus and page chrome are taken out, and e-mail addresses and phone numbers are replaced with `[email]` and `[phone]`.

## Which one

- Deciding what to read: highlights.
- Answering from a handful of pages you trust: `include_content` with a small `num_results`.
- A page as it is right now, or a page a search did not return: that is what [Extract](https://millionshort.com/docs/extract) is for.

The fields are listed in full under [Parameters](https://millionshort.com/docs/search/parameters#highlights), and the cost rules under [Pricing and limits](https://millionshort.com/docs/search/pricing).
