Search
Spaces
A saved scope for search. Describe a corner of the web once, then search it with one parameter.
Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)
A Space is a search scope with a name. It holds the things you would otherwise repeat on every request:
- sites, to search inside or to prefer;
- the popularity cut: remove the top N sites, or keep only them;
- page types and topics to keep or to leave out;
- a lens: sites, page types and topics to boost, bury or block;
- site filters:
traffic_trend,popular_in,site_tech,exclude_risky,popularity_buckets; - default sources and safe search.
You save it once and pass its name as space on POST /v1/search. Spaces are free, and a search with a Space costs what the search costs.
A vertical search engine in one parameter
A search engine for one subject is mostly a decision about scope: which sites count, which kinds of page, what to leave out. A Space is that decision, saved. The agent that uses it does not need to know the list. It sends a query and a name.
{ "query": "sourdough hydration", "space": "baking" }That is worth having when:
- The scope outlives the request. A product about one field, an assistant for one team, a customer's approved sites. Write the scope once, and every search of every agent uses the same one.
- The scope changes, and the code should not. Add a site to the Space and the next search has it. Nothing is deployed.
- A person chose the scope. A Space is the same object as a Space on the MillionShort search site. What someone built there by hand can be imported and handed to an agent.
- The prompt is crowded. A model that has to carry forty site names in its instructions spends tokens on them and still gets them wrong. A slug is one word.
For a scope that is used once, send the fields on the request. A Space saves nothing there.
Only, or boost
mode says what the list of sites means.
mode | The search | Use it when |
|---|---|---|
only | Returns results from these sites and no others. The default | The answer must come from a closed set: your documentation, approved publishers, a list of journals |
boost | Searches everything and moves these sites ahead | You trust some sites more but still want to hear from the rest |
only gives a short, clean list, and an empty one when those sites have nothing on the query. boost never comes back empty for that reason. If you are unsure, start with boost: it cannot hide a good result.
A Space does not need sites at all. One with no sites, remove_top_sites: 10000 and exclude_page_types: ["products", "listicles"] is a scope too: the long tail, without the shops.
A search inside a list uses the first 50 sites of a Space, and the answer says when a longer list was cut. The reference has the detail.
Curated Spaces
Some scopes we have made ourselves: Spaces for a subject, put together and kept by us. They are the same ones the MillionShort search site offers. Everyone can read them and search with them, with or without a key, and they are read-only.
{ "query": "cast iron seasoning", "space": "curated:home-cooking" }curated:home-cooking stands for any curated slug; GET /v1/spaces?scope=curated lists the real ones. To change a curated Space, read it and create your own from its fields.
The request wins
A Space is a set of defaults. A parameter you send on the request replaces the Space's value for that setting, and everything you do not send comes from the Space. So one search can step outside the scope without changing it:
{ "query": "sourdough hydration", "space": "baking", "remove_top_sites": 0 }Here the sites still come from the Space, and its popularity cut is switched off for this call. The answer lists what the Space supplied in data.space.applied and what the request replaced in data.space.overridden, so an agent can always see the scope it searched. The reference has the table of which parameter replaces which setting.
A worked example
A support assistant should answer from the product's documentation and two community sites, prefer tutorials, and never cite a shop page.
Create the Space once:
curl https://api.millionshort.com/v1/spaces \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Support",
"sites": ["docs.example.com", "example.org/community", "forum.example.net"],
"lens": {
"boost": ["type:tutorials", "type:documentation"],
"bury": ["type:forums"],
"block": ["type:products"]
},
"safe_search": "strict"
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/spaces",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"name": "Support",
"sites": [
"docs.example.com",
"example.org/community",
"forum.example.net"
],
"lens": {
"boost": [
"type:tutorials",
"type:documentation"
],
"bury": [
"type:forums"
],
"block": [
"type:products"
]
},
"safe_search": "strict"
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch('https://api.millionshort.com/v1/spaces', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Support",
"sites": [
"docs.example.com",
"example.org/community",
"forum.example.net"
],
"lens": {
"boost": [
"type:tutorials",
"type:documentation"
],
"bury": [
"type:forums"
],
"block": [
"type:products"
]
},
"safe_search": "strict"
}),
});
if (!res.ok) throw new Error(`POST /v1/spaces failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);The answer carries the Space with its id and the slug made from its name, support. Every search of the assistant then names it:
curl https://api.millionshort.com/v1/search \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "query": "rotate an API key without downtime", "space": "support", "max_highlights": 2 }'import os
from millionshort import MillionShort
client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])
r = client.search("rotate an API key without downtime", space="support", max_highlights=2)
for hit in r.results:
print(hit["position"], hit["site"], hit["page_type"], hit["title"])import { MillionShort } from 'millionshort';
const client = new MillionShort({ apiKey: process.env.MILLIONSHORT_API_KEY });
const r = await client.search('rotate an API key without downtime', {
space: 'support',
maxHighlights: 2,
});
for (const hit of r.results) {
console.log(hit.position, hit.site, hit.page_type, hit.title);
}Only those three sites are searched. Tutorials and documentation come first, forum threads last, and product pages are left out. When the documentation moves to a new host, change the Space with one PATCH; the assistant's code and prompt stay as they are.
When a question needs the wider web, the assistant sends the same query with no space. The scope is a choice per search, not a setting of the key.
With the other controls
- A Space saves what the lenses, the popularity cut, topics and page types and the site signals already do on a request. It adds no new filter; it gives a set of them a name.
- Over MCP, the
searchtool takesspace,list_spacesshows what there is, andcreate_spacemakes one with a key. - The Spaces reference has every field, the limits per plan, the endpoints and the errors.