# Map

Give it a site and get the addresses of its pages, in one answer.

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

Map answers one question about a site: which pages does it have? Give it the address of a page of the site and it returns the URLs it found, without fetching their content. The call is synchronous: one request, one answer.

[Crawl](https://millionshort.com/docs/crawl) goes one step further. It returns the pages themselves as clean text, as a job that runs in the background.

## What it is for

- **Finding the right page before reading it.** The pricing page, the changelog, the docs for one function. `search` puts the URLs that match your words first.
- **Handing an agent the outline of a site.** A list of URLs with titles is small enough to read whole.
- **Choosing what to read.** Send the URLs you want to [Extract](https://millionshort.com/docs/extract), or let a [crawl](https://millionshort.com/docs/crawl) fetch a section.

## Where the URLs come from

Map looks in three places and merges what it finds. Each URL says which one named it first, in `from`.

| Source | What it is | What reaches the site |
|---|---|---|
| `sitemap` | The site's own sitemaps: the ones its robots.txt names, and `/sitemap.xml` | robots.txt and a few sitemap files |
| `links` | The page you named, and the links on it | One fetch of that page |
| `index` | The pages of the site that our own index holds, each with its title and labels | No page. Asked alone, its robots.txt |

The `index` source is what a list of links cannot give you: URLs come back with a `title`, a `topic` and a `page_type`, and no page of the site is requested for them.

## How we treat the site

Map fetches the way [Extract](https://millionshort.com/docs/extract) does. Requests carry our declared identity, `MillionShortBot`. robots.txt is honoured, and there is no option to ignore it. A sitemap file that robots.txt closes to our bot is not read, and a site whose robots.txt closes it to us is not mapped at all, not even from our index: when you ask for the index alone, we still read the site's robots.txt first. A caller cannot send cookies or headers to a site.

## In this section

| Part | Page |
|---|---|
| Quickstart | [List a site, search inside it, keep one section](https://millionshort.com/docs/map/quickstart) |
| Parameters | [Every request field, the sources, and the response](https://millionshort.com/docs/map/parameters) |
| Guides | [Map then read, search inside a site, what the sources give](https://millionshort.com/docs/map/guides) |
| Pricing and limits | [What a call costs, and the limits](https://millionshort.com/docs/map/pricing) |
| Errors | [What can fail, and what a failed source looks like](https://millionshort.com/docs/map/errors) |

## Map or a search inside a site

A search with `include_domains` finds the pages of a site that our index holds and that match a query:

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "pricing", "include_domains": ["example.org"], "num_results": 20 }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "pricing",
        "include_domains": [
            "example.org"
        ],
        "num_results": 20
    },
    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": "pricing",
    "include_domains": [
      "example.org"
    ],
    "num_results": 20
  }),
});
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": "pricing",
      "include_domains": [
        "example.org"
      ],
      "num_results": 20
    }
  }
}
```

It is not a list of every page the site has, which is what Map is for.

## With the other endpoints

[Crawl](https://millionshort.com/docs/crawl) uses the same sources to find pages and returns their text. [Extract](https://millionshort.com/docs/extract) reads URLs you already have. [Search](https://millionshort.com/docs/search) finds pages across every site.
