# Search quickstart

A first search, then one more field at a time until it is the search you want.

You need a key in `MILLIONSHORT_API_KEY`. The [Quickstart](https://millionshort.com/docs/quickstart) gets you one in a minute, and the Free plan needs no card. Each step below is a complete request.

## 1. Search the web

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "restoring a cast iron skillet" }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "restoring a cast iron skillet"
    },
    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": "restoring a cast iron skillet"
  }),
});
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": "restoring a cast iron skillet"
    }
  }
}
```

With no `sources`, the search asks `web`. The answer is `data.results`: each result has a `title`, a `url`, a `snippet`, the `source` it came from, and the `popularity` and `risk` of its site. `usage` says what the call cost.

## 2. Leave out the most popular sites

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "restoring a cast iron skillet", "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": "restoring a cast iron skillet",
        "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": "restoring a cast iron skillet",
    "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": "restoring a cast iron skillet",
      "remove_top_sites": 10000
    }
  }
}
```

The 10,000 most popular sites are gone from the list, and what is left is what usually sits beneath them. [Remove top sites](https://millionshort.com/docs/search/remove-top-sites) says how to choose the number.

## 3. Ask the specialists

```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
  }'
```

```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
    },
    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
  }),
});
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
    }
  }
}
```

Up to five [sources](https://millionshort.com/docs/search/sources) in one call, merged into one list. Each source searched costs one credit.

## 4. Keep only the kinds of page you want

```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"]
  }'
```

```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"
        ]
    },
    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"
    ]
  }),
});
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"
      ]
    }
  }
}
```

[Topics and page types](https://millionshort.com/docs/search/topics-and-page-types) lists the slugs. Filters are free and combine.

## 5. Get the passages, or the page

```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,
    "max_highlights": 3,
    "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,
        "max_highlights": 3,
        "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,
    "max_highlights": 3,
    "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,
      "max_highlights": 3,
      "include_content": true,
      "max_characters": 4000
    }
  }
}
```

`max_highlights` returns the passages of each result that best answer the query, free. `include_content` adds the page text we hold for web and news results, for 1 credit a call, which covers up to 10 results. See [Highlights and page text](https://millionshort.com/docs/search/highlights).

## Next

- [Parameters](https://millionshort.com/docs/search/parameters): every field, and the whole response.
- [Filters](https://millionshort.com/docs/search/filters): all of them on one page, with recipes for agents.
- [Guides](https://millionshort.com/docs/search/guides): retrieval for a model, search as an agent's tool, long-tail research.
- [MCP server](https://millionshort.com/docs/mcp): the same search as a tool, with no code.
