# Search parameters

Every field of a search request, and everything that comes back.

```text
POST https://api.millionshort.com/v1/search
```

Searches one to five sources and returns one ranked list. Results from several sources are merged by rank and duplicates are removed. The call is synchronous. It needs an [API key](https://millionshort.com/docs/authentication).

## Request

A JSON body. Only `query` is required. A field that is not listed here is refused with `400 INVALID_PARAM`.

| Field | Type | Default | Notes |
|---|---|---|---|
| `query` | string, 1 to 400 characters |  | Required. |
| `sources` | array of `web`, `news`, `smallweb`, `discussions`, `hn`, `social`, `communities`, `podcasts`, `academic`, `medical`, `law`, `finance`, `contracts`, 1 to 5 items | `["web"]` | Sources to search. Each source searched costs 1 credit. |
| `num_results` | integer, 1 to 50 | `10` | How many results to return in total. With several sources this is the length of the one merged list, not a count per source. |
| `remove_top_sites` | integer, 0 to 1,000,000 | `0` | Remove results from the N most popular sites. 0 keeps everything. Free. |
| `only_top_sites` | integer, 0 to 1,000,000 | `0` | Keep only results from the N most popular sites. Cannot be combined with `remove_top_sites`. |
| `include_domains` | array of strings, up to 25 |  | Return results from these sites only. |
| `exclude_domains` | array of strings, up to 25 |  | Never return results from these sites. |
| `boost_domains` | array of strings, up to 25 |  | Move results from these sites ahead of the rest. |
| `bury_domains` | array of strings, up to 25 |  | Move results from these sites to the end. |
| `only_domains` | array of strings, up to 25 |  | Another name for `include_domains`. Both sent are merged. |
| `block_domains` | array of strings, up to 25 |  | Another name for `exclude_domains`. Both sent are merged. |
| `page_types` | array of `research`, `directories`, `creative-writing`, `support`, `comments`, `faqs`, `reference`, `legal`, `listicles`, `news`, `articles`, `companies`, `press-releases`, `profiles`, `blogs`, `products`, `forums`, `spam`, `data`, `documentation`, `transcripts`, `tutorials`, `reviews` |  | Keep only these kinds of page, for example `[tutorials, documentation]`. Applied by `web` and `news`; other sources in the call get a `filter_not_applied` warning. |
| `exclude_page_types` | array of `research`, `directories`, `creative-writing`, `support`, `comments`, `faqs`, `reference`, `legal`, `listicles`, `news`, `articles`, `companies`, `press-releases`, `profiles`, `blogs`, `products`, `forums`, `spam`, `data`, `documentation`, `transcripts`, `tutorials`, `reviews` |  | Never return these kinds of page, for example `[listicles, spam]`. |
| `boost_page_types` | array of `research`, `directories`, `creative-writing`, `support`, `comments`, `faqs`, `reference`, `legal`, `listicles`, `news`, `articles`, `companies`, `press-releases`, `profiles`, `blogs`, `products`, `forums`, `spam`, `data`, `documentation`, `transcripts`, `tutorials`, `reviews` |  | Move these kinds of page ahead of the rest, for example `[documentation]`. |
| `bury_page_types` | array of `research`, `directories`, `creative-writing`, `support`, `comments`, `faqs`, `reference`, `legal`, `listicles`, `news`, `articles`, `companies`, `press-releases`, `profiles`, `blogs`, `products`, `forums`, `spam`, `data`, `documentation`, `transcripts`, `tutorials`, `reviews` |  | Move these kinds of page to the end, for example `[forums]`. |
| `topics` | array of `adult`, `art`, `programming`, `law`, `education`, `hardware`, `entertainment`, `social-life`, `fashion`, `business`, `food`, `games`, `health`, `history`, `home`, `industry`, `literature`, `politics`, `religion`, `science`, `software`, `sports`, `transport`, `travel` |  | Keep only these topics, for example `[science, health]`. Applied by `web` and `news`; other sources in the call get a `filter_not_applied` warning. |
| `exclude_topics` | array of `adult`, `art`, `programming`, `law`, `education`, `hardware`, `entertainment`, `social-life`, `fashion`, `business`, `food`, `games`, `health`, `history`, `home`, `industry`, `literature`, `politics`, `religion`, `science`, `software`, `sports`, `transport`, `travel` |  | Never return these topics, for example `[adult]`. |
| `boost_topics` | array of `adult`, `art`, `programming`, `law`, `education`, `hardware`, `entertainment`, `social-life`, `fashion`, `business`, `food`, `games`, `health`, `history`, `home`, `industry`, `literature`, `politics`, `religion`, `science`, `software`, `sports`, `transport`, `travel` |  | Move these topics ahead of the rest, for example `[programming]`. |
| `bury_topics` | array of `adult`, `art`, `programming`, `law`, `education`, `hardware`, `entertainment`, `social-life`, `fashion`, `business`, `food`, `games`, `health`, `history`, `home`, `industry`, `literature`, `politics`, `religion`, `science`, `software`, `sports`, `transport`, `travel` |  | Move these topics to the end, for example `[entertainment]`. |
| `popularity_buckets` | array of `top-100`, `top-1k`, `top-10k`, `top-100k`, `top-1m`, `long-tail` |  | Keep results whose site is in one of these popularity buckets, for example `[long-tail, top-1m]`. See also `remove_top_sites` and `only_top_sites`. |
| `traffic_trend` | array of `rising`, `spiking`, `steady`, `falling`, `dropped`, `new` |  | Keep results whose site's traffic is moving this way, for example `[rising, spiking]`. Each result says its own in `traffic_trend`. The site filters are checked on the best matches for the query, and sites on the move are rare: expect a short list. |
| `popular_in` | array of strings, 1 to 10 items |  | Keep results whose site is popular in any of these countries, for example `[DE, AT]`. Each result lists its own in `popular_in`. |
| `site_tech` | array of strings (each 1 to 40 characters), 1 to 10 items |  | Keep results whose site is built with any of these, for example `[wordpress, woocommerce]`. Names are matched without regard to case against what results return in `site_tech`. A name is letters, digits, spaces and `. + # / -`, starting with a letter or digit. |
| `exclude_risky` | boolean | `false` | Drop results whose site carries a risk label (`risk` is not null). |
| `start_date` | string or null |  | Results published on or after this day (`YYYY-MM-DD`). Applied by `news`, `hn`, `social`, `communities`, `podcasts`, `academic`, `medical`, `law`, `finance` and `contracts`. `web` pages carry no date: a `filter_not_applied` warning says so. |
| `end_date` | string or null |  | Results published on or before this day (`YYYY-MM-DD`). Same sources as `start_date`. |
| `time_range` | `day`, `week`, `month`, `year` or null |  | The last 1, 7, 30 or 365 days. Cannot be combined with `start_date` or `end_date`. |
| `language` | string or null |  | A two-letter language code such as `en` or `de`. Applied by `news`, `hn`, `social`, `communities`, `podcasts` and `academic`, which store a language. `web` stores none: the language of each web result is detected from its text, the filter is applied to the best matches, and a `language_detected` warning says so. |
| `country` | string or null |  | Results from this country. `web` and `news`: sites with the country's domain ending (`.de`, `.co.uk`; for `US` also `.gov`, `.edu` and `.mil`). `finance`: the filer's country. `contracts`: `US` or `CA`. Other sources get a `filter_not_applied` warning. |
| `max_highlights` | integer, 0 to 5 | `0` | Return up to this many passages per result that best answer the query, in `highlights`, with `highlight_spans`. 0 keeps `highlights` as the snippet alone. Free. |
| `highlight_characters` | integer, 100 to 600 | `300` | Target length of one highlight. Needs `max_highlights`. |
| `include_content` | boolean | `false` | Add `content` to each result: the text of the page as we hold it, for `web` and `news` results. No request is made to the site. 1 credit per call, covering up to 10 results that come back with content; each further 10 (or part) 1 more; nothing when none comes back with content. |
| `max_characters` | integer, 500 to 50,000 | `10000` | Longest `content.text` to return. Needs `include_content`. |
| `safe_search` | `off`, `moderate`, `strict` | `"moderate"` |  |
| `max_chars_per_result` | integer, 0 to 2,000 | `800` | Longest snippet to return per result, in characters. 0 returns no snippets. |
| `explain` | boolean | `false` | Add `why` and `signals` to every result. Free. |

Notes:

- **Sources.** `sources` takes the slugs on the [Sources](https://millionshort.com/docs/api-reference/sources) page. Each source searched costs 1 credit.
- **Number of results.** `num_results` is the length of the one merged list, for the whole call. It is not a number per source.
- **Popularity.** `remove_top_sites: 10000` removes every result whose site is among the 10,000 most popular, which is how you reach the long tail. `only_top_sites` does the opposite. Sending both with a value above 0 is a `400`.
- **Domain lists.** A leading `www.`, a scheme or a path in an entry is ignored. `include_domains` and `exclude_domains` filter; `boost_domains` and `bury_domains` only change the order.
- **Snippets.** `max_chars_per_result` sets the longest snippet. `0` returns no snippets.

Every filter below is free.

### Boost, bury, block, only

Four verbs, and they work on sites, on page types and on topics:

| Verb | Sites | Page types | Topics |
|---|---|---|---|
| Keep only | `include_domains` (or `only_domains`) | `page_types` | `topics` |
| Never return | `exclude_domains` (or `block_domains`) | `exclude_page_types` | `exclude_topics` |
| Move ahead | `boost_domains` | `boost_page_types` | `boost_topics` |
| Move to the end | `bury_domains` | `bury_page_types` | `bury_topics` |

```json
{ "query": "rust lifetime elision", "page_types": ["tutorials", "documentation"], "bury_page_types": ["forums"], "exclude_page_types": ["listicles"] }
```

### Page types and topics

Web and news results carry a page type (what kind of page it is) and a topic (what it is about); either can be `null` when it is not known. The page-type and topic lists act on `web` and `news` only. Another source in the same call gets a warning, even where its results carry the labels.

The two lists:

- **Page types:** `research`, `directories`, `creative-writing`, `support`, `comments`, `faqs`, `reference`, `legal`, `listicles`, `news`, `articles`, `companies`, `press-releases`, `profiles`, `blogs`, `products`, `forums`, `spam`, `data`, `documentation`, `transcripts`, `tutorials`, `reviews`
- **Topics:** `adult`, `art`, `programming`, `law`, `education`, `hardware`, `entertainment`, `social-life`, `fashion`, `business`, `food`, `games`, `health`, `history`, `home`, `industry`, `literature`, `politics`, `religion`, `science`, `software`, `sports`, `transport`, `travel`

```json
{ "query": "creatine", "boost_topics": ["science", "health"], "exclude_topics": ["sports"] }
```

### Popularity

`remove_top_sites` and `only_top_sites` cut by rank. `popularity_buckets` keeps the buckets you name: `top-100`, `top-1k`, `top-10k`, `top-100k`, `top-1m`, `long-tail`. `popular_in` keeps sites that are popular in at least one of the countries you name, and each result lists its own countries in `popular_in`.

```json
{ "query": "heat pump grant", "popular_in": ["GB", "IE"] }
```

### Traffic trend

Each result says how visits to its site are moving, in `traffic_trend`: `rising`, `spiking`, `steady`, `falling`, `dropped`, `new`. `rising` is growing, `spiking` jumped sharply in the last days, `falling` is shrinking, `dropped` fell sharply, `new` appeared recently, `steady` shows no clear change. Send `traffic_trend` to keep only the sites moving the way you name.

Most sites are steady, and many small sites have no trend at all (`null`). A filter for `rising` or `spiking` therefore keeps few results and often none: use it with a broad query, ask for 20 or more results, and expect a short list, sometimes an empty one (the response then carries a `short_results` warning). To see the trend without filtering, read `traffic_trend` on each result.

```json
{ "query": "best running shoes", "traffic_trend": ["rising", "spiking", "new"], "num_results": 20 }
```

### Site technology

Each result lists what its site is built with in `site_tech`, for example `["WordPress", "WooCommerce"]`. Send `site_tech` to keep only sites built with one of the names you give. Names are matched without regard to case.

```json
{ "query": "handmade ceramic mugs", "site_tech": ["woocommerce"], "page_types": ["products"] }
```

### Risk

A result whose site carries a risk label says so in `risk`. `exclude_risky: true` drops those results.

```json
{ "query": "free vpn comparison", "popularity_buckets": ["long-tail", "top-1m"], "exclude_risky": true }
```

### Dates, language and country

`start_date` and `end_date` are days written `YYYY-MM-DD`; both days are included. `time_range` is a shorthand for the last day, week, month or year and cannot be combined with the two dates. `language` is a two-letter language code and `country` a two-letter country code.

```json
{ "query": "Bundestag Haushalt", "sources": ["news"], "time_range": "week", "language": "de" }
```

German pages from the web source. Web stores no language, so each result's language is detected from its text; the results say `"language": "de"` and the response carries a `language_detected` warning:

```json
{ "query": "wärmepumpe förderung", "language": "de" }
```

A web result whose language cannot be told has `language: null` and does not pass a `language` filter. The filter is checked on the best matches for the query, not on the whole index, so the list can be short.

```json
{ "query": "planning permission loft conversion", "country": "GB" }
```

Not every source can apply every one of these. **A filter is never ignored silently:** where a source cannot apply it, that source's results come back as if the filter had not been sent, and the response carries a `filter_not_applied` warning that names the filter and the sources. Three cases are more exact than that: `hn` and `social` hold the last 30 days, so a date range that ends earlier returns nothing from them, and the warning says so; a filter that is not available right now carries no `sources` and was applied nowhere; and `include_content` on a source without stored page text is reported the same way.

| Filter | Applied by | Elsewhere |
|---|---|---|
| `start_date`, `end_date`, `time_range` | `news`, `hn`, `social`, `communities`, `podcasts`, `academic`, `medical`, `law`, `finance`, `contracts` | `web` pages carry no date of their own, so `web` gets a warning. So do `smallweb` and `discussions` |
| `language` | `news`, `hn`, `social`, `communities`, `podcasts`, `academic`. `web` stores no language (it is mostly English, with pages in other languages too): the language of each web result is detected from its text, the filter is applied to the best matches, and a `language_detected` warning says so | a warning |
| `country` | `web` and `news`: sites with the country's domain ending, such as `.de` or `.co.uk` (for `US` also `.gov`, `.edu` and `.mil`). `finance`: the filer's country. `contracts`: `US` or `CA` | a warning |
| `page_types`, `topics` | `web`, `news` | a warning |
| `exclude_page_types`, `boost_page_types`, `bury_page_types` and the three topic lists | `web`, `news` | a warning |
| The domain lists, `remove_top_sites`, `only_top_sites`, `popularity_buckets`, `traffic_trend`, `popular_in`, `site_tech`, `exclude_risky` | every source. A result with no site of its own, such as a post on a platform, has no site facts and does not pass a site filter | |

`GET /v1/sources` returns the same table as data: each source lists the filters it applies.

### Highlights

`max_highlights` (0 to 5; 0 is off) returns the passages of each result that best answer the query, best first, in `highlights`. `highlight_characters` sets how long one passage should be. Highlights are free.

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. |

```json
{ "query": "sourdough starter hydration", "max_highlights": 3 }
```

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

### Page content

`include_content: true` adds `content` to each `web` and `news` result: the text of the page as we hold it. We do not hold text for every result: those have `content: null`, are not charged, and the response carries a `content_partial` warning. No request is made to the site, so it is fast and it cannot be blocked. `max_characters` cuts the text (500 to 50,000, default 10,000).

| 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. |

The text is cleaned: menus and page chrome are taken out, and e-mail addresses and phone numbers are replaced with `[email]` and `[phone]`. It is the page as it was when we captured it: for a web result `captured_from` and `captured_to` give the window, and you should treat the page as being as old as `captured_from`; for a news result both are the day the article was collected. A result we hold no text for has `content: null`.

```json
{ "query": "sourdough starter hydration", "num_results": 5, "include_content": true, "max_characters": 4000 }
```

Content adds 1 credit to the call, which covers the page text of up to 10 results; each further 10 results that come back with text (or part of 10) add 1 more. A call where every `content` is `null` is not charged for content.

### Rules between fields

Each of these is a `400 INVALID_PARAM`: a value in both `page_types` and `exclude_page_types` (or in both `topics` and `exclude_topics`); more than 25 domains in `include_domains` and `only_domains` together (the same for `exclude_domains` and `block_domains`); a date outside the years 1000 to 2100; `time_range` together with `start_date` or `end_date`; `max_characters` without `include_content`; `highlight_characters` without `max_highlights`.

### A saved scope: `space`

`space` searches with a saved scope from [Spaces](https://millionshort.com/docs/spaces).

| Field | Type | Default | Notes |
|---|---|---|---|
| `space` | string, up to 80 characters | | The [Space](https://millionshort.com/docs/search/spaces) to search with: its id (`spc_` and 26 characters), a slug of your team, or `curated:` and the slug of a curated Space |

```json
{ "query": "sourdough hydration", "space": "baking" }
```

A Space is a saved set of the fields above: sites, the popularity cut, page types, topics, a lens, site filters, default sources and `safe_search`. A field you send in the request replaces the Space's value for that setting; everything you do not send comes from the Space. The answer then carries `data.space`, which names the Space, lists the settings it supplied (`applied`) and the request fields that replaced one (`overridden`). A Space costs nothing: the search costs what it would cost without it.

A Space that searches inside a list of sites applies its first 50; a longer list is cut and the answer carries a `space_sites_cut` warning. A Space that does not exist is a `404 SPACE_NOT_FOUND`. [Using a Space on a search](https://millionshort.com/docs/spaces#using-a-space-on-a-search) has the table of which field replaces which setting, the shape of `data.space` and how such a search is counted.

### Accepted for older clients

These fields are accepted so that existing clients keep working.

| Field | Type | Notes |
|---|---|---|
| `index_level` | `full`, `top100`, `top1k`, `top10k`, `top100k`, `top1m` | Earlier spelling of `remove_top_sites`: `top10k` means `remove_top_sites: 10000`, `full` means 0. |
| `mode` | `standard` | There is one mode. The field is accepted so existing clients keep working. |

## Examples

The web without its 10,000 most popular sites:

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

```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",
        "remove_top_sites": 10000
    },
    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",
    "remove_top_sites": 10000
  }),
});
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",
      "remove_top_sites": 10000
    }
  }
}
```

Three sources, twenty results, with the reasons for each result:

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "transformer interpretability",
    "sources": ["web", "academic", "hn"],
    "num_results": 20,
    "explain": true
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "transformer interpretability",
        "sources": [
            "web",
            "academic",
            "hn"
        ],
        "num_results": 20,
        "explain": True
    },
    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": "transformer interpretability",
    "sources": [
      "web",
      "academic",
      "hn"
    ],
    "num_results": 20,
    "explain": true
  }),
});
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": "transformer interpretability",
      "sources": [
        "web",
        "academic",
        "hn"
      ],
      "num_results": 20,
      "explain": true
    }
  }
}
```

Tutorials and documentation only, with two sites left out and one moved up:

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "rate limiting with a token bucket",
    "page_types": ["tutorials", "documentation"],
    "exclude_domains": ["example.com", "example.net"],
    "boost_domains": ["example.org"],
    "safe_search": "strict",
    "max_chars_per_result": 300
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "rate limiting with a token bucket",
        "page_types": [
            "tutorials",
            "documentation"
        ],
        "exclude_domains": [
            "example.com",
            "example.net"
        ],
        "boost_domains": [
            "example.org"
        ],
        "safe_search": "strict",
        "max_chars_per_result": 300
    },
    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": "rate limiting with a token bucket",
    "page_types": [
      "tutorials",
      "documentation"
    ],
    "exclude_domains": [
      "example.com",
      "example.net"
    ],
    "boost_domains": [
      "example.org"
    ],
    "safe_search": "strict",
    "max_chars_per_result": 300
  }),
});
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": "rate limiting with a token bucket",
      "page_types": [
        "tutorials",
        "documentation"
      ],
      "exclude_domains": [
        "example.com",
        "example.net"
      ],
      "boost_domains": [
        "example.org"
      ],
      "safe_search": "strict",
      "max_chars_per_result": 300
    }
  }
}
```

## Response

```json
{
  "data": {
    "results": [
      {
        "title": "Hydration levels for a sourdough starter, measured",
        "url": "https://example.org/starter-hydration",
        "site": "example.org",
        "source": "web",
        "snippet": "At 100% hydration the starter peaks in four to six hours...",
        "highlights": ["At 100% hydration the starter peaks in four to six hours..."],
        "published_date": null,
        "page_type": "articles",
        "topic": "food",
        "popularity": { "rank": null, "bucket": "long-tail" },
        "risk": null,
        "position": 1,
        "score": 1.0,
        "extra": { "author": "A. Baker" },
        "language": "en",
        "traffic_trend": "steady",
        "popular_in": null,
        "site_tech": ["WordPress"]
      }
    ],
    "summary": {
      "returned": 10,
      "removed": { "popularity": 37, "blocked": 0, "duplicates": 3, "risk": 0, "safe_search": 0, "filters": 0 }
    },
    "warnings": []
  },
  "usage": { "credits": 1, "cost_usd": 0.001, "breakdown": { "search": 1 } },
  "warnings": [],
  "request_id": "req_..."
}
```

The values are an illustration and the list is cut to one result; the shape is exact.

### A result

| Field | Type | Notes |
|---|---|---|
| `title` | string |  |
| `url` | string |  |
| `site` | string or null | The host name |
| `source` | `web`, `news`, `smallweb`, `discussions`, `hn`, `social`, `communities`, `podcasts`, `academic`, `medical`, `law`, `finance`, `contracts` | A source slug. `GET /v1/sources` describes each one. |
| `snippet` | string | The passage of the page that matches the query. |
| `highlights` | array of strings | The snippet as a one-item list. With `max_highlights`: up to that many passages that best answer the query, best first. |
| `highlight_spans` | array of objects | Only with `max_highlights`: one entry per highlight, in the same order. |
| `content` | object or null | Only with `include_content`: the page's text, or null when we hold none for this result. |
| `language` | string or null | The result's language as a two-letter code, or null when not known. Stored by the source for `news`, `hn`, `social`, `podcasts` and `academic`; detected from the result's text for `web`, where a result whose language cannot be told has null and does not pass a `language` filter. |
| `traffic_trend` | `rising`, `spiking`, `steady`, `falling`, `dropped`, `new` or null | How visits to the result's site are moving, or null when not known. |
| `popular_in` | array of strings, up to 12 or null | The countries (two-letter codes) where the result's site is among the popular sites, or null when not known. |
| `site_tech` | array of strings, up to 8 or null | What the result's site is built with, for example `[WordPress, WooCommerce]`. An empty list when we looked and recognised nothing; null when we have not looked. |
| `published_date` | string or null | `YYYY-MM-DD`, or a year, when the source knows it. Web results have no date. |
| `page_type` | string or null | A page-type slug from `GET /v1/sources`. |
| `topic` | string or null | A topic slug from `GET /v1/sources`. |
| `popularity` | object |  |
| `risk` | object or null |  |
| `position` | integer, 1 or more |  |
| `score` | number | Rank-based, from 1.0 for the first result downwards. Not comparable across calls. |
| `extra` | object | A few fields that only some sources have, such as `authors`, `venue`, `year`, `citations`, `points` or `filer`. Values are strings, numbers or booleans. |
| `why` | array of strings | Only with `explain`: why this result is here, at this position. |
| `signals` | object | Only with `explain`. |

`popularity`:

| Field | Type | Notes |
|---|---|---|
| `rank` | integer or null | The site's popularity rank (1 is the most popular), or null when it is outside the top 1,000,000 or unknown. |
| `bucket` | `top-100`, `top-1k`, `top-10k`, `top-100k`, `top-1m`, `long-tail`, `unknown` |  |

`risk` is `null` for most sites. When a site carries a risk label:

| Field | Type | Notes |
|---|---|---|
| `level` | `labelled`, `demoted`, `blocked` |  |
| `categories` | array of strings |  |

`signals`, present only with `explain`:

| Field | Type | Notes |
|---|---|---|
| `text_rank` | integer or null | Position by text relevance alone. |
| `link_authority` | number, 0 to 10 or null | How well linked the site is, 0 to 10. Null when the source has none for the result. |
| `words` | integer or null | Length of the page in words. |

### Summary

`data.summary.returned` is the number of results in the list. `data.summary.removed` counts what was taken out, by reason:

| Field | Type | Notes |
|---|---|---|
| `popularity` | integer | Removed by `remove_top_sites` or `only_top_sites`. |
| `blocked` | integer | Removed by `exclude_domains` (`block_domains`), `exclude_page_types` or `exclude_topics`. |
| `duplicates` | integer |  |
| `risk` | integer |  |
| `safe_search` | integer |  |
| `filters` | integer | Removed by `popularity_buckets`, `traffic_trend`, `popular_in`, `site_tech` or `exclude_risky`. |

For some sources, `web` and `news` among them, the popularity cut and the domain lists are applied before results are counted, so `popularity` and `blocked` can be 0 when the filter plainly worked. Judge by the results that came back.

### Usage

| Field | Type | Notes |
|---|---|---|
| `credits` | number | Credits charged for this call. |
| `cost_usd` | number | The same amount in US dollars. |
| `breakdown` | object | Credits by line item, for example `search` and `additional_results`. |

### Warnings

A warning is a notice that did not fail the call. The same list appears as `data.warnings` and as the top-level `warnings`.

| Field | Type | Notes |
|---|---|---|
| `code` | `option_not_supported`, `source_unavailable`, `short_results`, `filter_not_applied`, `language_detected`, `content_partial`, `content_unavailable` |  |
| `message` | string |  |
| `option` | string |  |
| `source` | string |  |
| `filter` | string | The request field that was not applied. |
| `sources` | array of strings | The sources it was not applied to. Absent when it was not applied at all. |
| `requested` | integer |  |
| `returned` | integer |  |
| `with_content` | integer |  |

A search with a [`space`](https://millionshort.com/docs/spaces#warnings) can also carry a `space_sites_cut` warning or a `space_setting_not_applied` warning.

## Freshness

Most sources are kept current: `social` and `hn` within minutes, `news` every hour, `podcasts` twice a day, and `academic`, `medical`, `contracts` and `communities` every day; `law` statutes and regulations every day and court opinions every quarter; `finance` in batches, so its newest filings can be some days old. Results from those sources carry a `published_date` when the source knows it, and the date filters work on them.

The web source is different. It is a large snapshot that is rebuilt from time to time, not continuously. A page that changed recently may show its earlier text, and a page published after the snapshot is not there yet. Web results carry no date: `published_date` is `null`. For recent material, add a source that is kept current to the same call.

[`GET /v1/sources`](https://millionshort.com/docs/api-reference/sources) says how fresh each source is, and for the web source the dates between which its pages were captured, when they are published.

## Cost

1 credit per source searched, which covers the first 10 results of the call. Each further 10 results, or part of 10, adds 0.5. `explain`, highlights and every filter are free. `include_content` adds 1 for the page text of up to 10 results, and 1 more for each further 10 with text. A call that fails or is refused costs nothing. [Credits and limits](https://millionshort.com/docs/credits-and-limits) has the worked examples.

## Errors

`400 INVALID_PARAM`, `400 UNSUPPORTED_OPTION`, `401`, `429` (`RATE_LIMITED`, `CAPACITY` or `INSUFFICIENT_CREDITS`) and `502 SEARCH_UNAVAILABLE`. With `space`, also `404 SPACE_NOT_FOUND` for a Space that does not exist. See [Errors](https://millionshort.com/docs/errors).
