# Labels on extracted pages

Every page Extract returns says what it is about, what kind of page it is, and which source holds pages like it.

A page that comes back from Extract carries three labels, in every mode, at no charge:

```text
"topic": "health",
"page_type": "articles",
"source_hint": "medical",
"label_confidence": { "topic": 0.93, "page_type": 0.71, "source_hint": 0.71 }
```

| Label | What it says | Values |
|---|---|---|
| `topic` | What the page is about | One of the 24 [topic slugs](https://millionshort.com/docs/search/topics-and-page-types) |
| `page_type` | What kind of page it is | One of the 23 [page-type slugs](https://millionshort.com/docs/search/topics-and-page-types) |
| `source_hint` | The [source](https://millionshort.com/docs/search/sources) that holds pages like this one | A source slug |
| `label_confidence` | How sure each label is | 0 to 1 each, or `null` |

## One vocabulary across the endpoints

The labels are the same ones everywhere, so a program can treat a page it found, a page it fetched and a page it was told about with one rule:

- **Search** results carry `topic` and `page_type`, and a search can filter by them. See [Topics and page types](https://millionshort.com/docs/search/topics-and-page-types).
- **Extract** labels every page it returns, described here.
- **Monitor** events carry the same labels for each new result or changed page. See [Labels on monitor events](https://millionshort.com/docs/monitor/labels).

`source_hint` tells an agent where to search for more of the same: a paper is `academic`, or `medical` when it is about health; a news article is `news`; a forum thread is `discussions`; a personal blog is `smallweb`. It does not say that we hold the page.

## Keep only some pages

`topics`, `page_types` and `source_hints` on the request take lists of slugs. A page left out stays in `results`, in its place, with `filtered: true` and none of its content.

```bash
curl https://api.millionshort.com/v1/extract \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": ["https://example.org/a", "https://example.org/b"],
    "mode": "live",
    "topics": ["health"],
    "page_types": ["articles", "research"]
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/extract",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "urls": [
            "https://example.org/a",
            "https://example.org/b"
        ],
        "mode": "live",
        "topics": [
            "health"
        ],
        "page_types": [
            "articles",
            "research"
        ]
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/extract', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "urls": [
      "https://example.org/a",
      "https://example.org/b"
    ],
    "mode": "live",
    "topics": [
      "health"
    ],
    "page_types": [
      "articles",
      "research"
    ]
  }),
});
if (!res.ok) throw new Error(`POST /v1/extract failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

- **A page left out is still charged for its fetch.** It had to be fetched to be labelled. The lists save your program the reading, not the fetch.
- A page is never left out for a label it does not have: a `null` label passes.
- Labels never fail a call and never change its price.

The full rules, with the entry a filtered page leaves behind, are under [Parameters](https://millionshort.com/docs/extract/parameters#labels).
