Crawl
Crawl guides
The jobs Crawl is built for, each as the requests that do it.
Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)
One section of a site
Start at the section's first page and keep the crawl inside it with include:
curl https://api.millionshort.com/v1/crawl \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.org/docs",
"max_pages": 200,
"max_depth": 4,
"include": ["^/docs/"],
"exclude": ["^/docs/archive/", "\\.pdf$"]
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/crawl",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"url": "https://example.org/docs",
"max_pages": 200,
"max_depth": 4,
"include": [
"^/docs/"
],
"exclude": [
"^/docs/archive/",
"\\.pdf$"
]
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch('https://api.millionshort.com/v1/crawl', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"url": "https://example.org/docs",
"max_pages": 200,
"max_depth": 4,
"include": [
"^/docs/"
],
"exclude": [
"^/docs/archive/",
"\\.pdf$"
]
}),
});
if (!res.ok) throw new Error(`POST /v1/crawl failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);includeandexcludeare regular expressions on the path.^/docs/keeps the paths that start with/docs/.- The start page is crawled even when it does not match
include. - The sitemap is read at the start, so pages of the section that nothing links to are found too.
"sitemap": "skip"follows links only. - Not sure what the section holds? Map it first with the same
include. A map of 200 URLs costs 20 credits and shows what a crawl would fetch.
Poll, and page through the results
A poll returns up to 50 results and a next cursor. Wait for the crawl to end, then follow next until it is null:
import os
import time
from millionshort import MillionShort
client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])
job = client.crawl(url="https://example.org/docs", max_pages=200, include=["^/docs/"])
while job.status in ("queued", "running"):
time.sleep(5)
job = client.get_crawl(job.id)
pages = []
while True:
for page in job.results:
if page["status"] == "ok":
pages.append(page)
if not job.next:
break
job = client.get_crawl(job.id, cursor=job.next)
print(len(pages), "pages,", job.credits_used, "credits,", job.stop_reason)import { MillionShort } from 'millionshort';
const client = new MillionShort({ apiKey: process.env.MILLIONSHORT_API_KEY });
let job = await client.crawl('https://example.org/docs', { maxPages: 200, include: ['^/docs/'] });
while (job.status === 'queued' || job.status === 'running') {
await new Promise((resolve) => setTimeout(resolve, 5000));
job = await client.getCrawl(job.id);
}
const pages = [];
for (;;) {
for (const page of job.results ?? []) {
if (page.status === 'ok') pages.push(page);
}
if (!job.next) break;
job = await client.getCrawl(job.id, { cursor: job.next });
}
console.log(pages.length, 'pages,', job.credits_used, 'credits,', job.stop_reason);You can read results while the crawl runs too: a poll returns up to 50 of the pages finished so far, and while the crawl is running, next is where to carry on from once any page has been read, even when no more pages are there yet (before the first page finishes it is null: poll again without a cursor). Poll again with it and you get only the pages that finished since, or none yet; you never read a page twice. Pages come in the order they finished, so a cursor stays good. next is null once the crawl has ended and you have read its last page. Polling is free. Keep it to one poll every few seconds: the limit is 120 a minute for your team.
Be told when it ends
Register a webhook endpoint once, verify it, and name it on the crawl:
curl https://api.millionshort.com/v1/crawl \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: docs-2026-11-20" \
-d '{
"url": "https://example.org/docs",
"max_pages": 200,
"webhook_id": "wh_01jd3v9x7k2m4n6p8q0r2s4t6v"
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/crawl",
headers={
"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"],
"Idempotency-Key": "docs-2026-11-20",
},
json={
"url": "https://example.org/docs",
"max_pages": 200,
"webhook_id": "wh_01jd3v9x7k2m4n6p8q0r2s4t6v"
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch('https://api.millionshort.com/v1/crawl', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': 'docs-2026-11-20',
},
body: JSON.stringify({
"url": "https://example.org/docs",
"max_pages": 200,
"webhook_id": "wh_01jd3v9x7k2m4n6p8q0r2s4t6v"
}),
});
if (!res.ok) throw new Error(`POST /v1/crawl failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);When the crawl ends, the endpoint receives crawl.completed, or crawl.failed for a crawl that failed, with the crawl's id, status, stop_reason and counts. The event does not carry the pages. Fetch them with GET /v1/crawl/{id} and page through them as above.
The Idempotency-Key makes a retry safe: sending the same request again within 24 hours returns the crawl that was started, and starts no second one.
A crawl of stored copies
With mode: "cached", the pages come from the copies we already hold. The site is asked for its robots.txt and its sitemaps (with sitemap: "skip", its robots.txt alone), and for no page at all:
curl https://api.millionshort.com/v1/crawl \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.org/", "mode": "cached", "max_pages": 100 }'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/crawl",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"url": "https://example.org/",
"mode": "cached",
"max_pages": 100
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch('https://api.millionshort.com/v1/crawl', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"url": "https://example.org/",
"mode": "cached",
"max_pages": 100
}),
});
if (!res.ok) throw new Error(`POST /v1/crawl failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);- The URLs are the sitemap's and the ones our index holds for the site. Links are not followed, because a stored copy carries none.
- A page we hold comes back with
mode_used: "cached". Itsfetched_atis the earliest day the copy can have been captured, andcaptured_beforethe latest. - A page we do not hold comes back as
NOT_IN_CACHE, free. Read those with Extractlive, or run alivecrawl. - A site whose robots.txt closes the start page to our bot is not served from stored copies either: the crawl ends
failedwithROBOTS_DISALLOWED, and costs nothing. When the robots.txt cannot be read, it ends withROBOTS_UNAVAILABLE. The copies themselves are served as Extract'scachedserves them: robots.txt is not asked about each page. - Its pages do not count towards your daily limit for the site, because none is fetched. Stored copies are looked up at about 60 a minute per team.
cached is switched off for now, as it is for Extract, and may not ship.
Use the labels
Every page that comes back says what it is, at no charge: topic, page_type and source_hint, each with a confidence. Two ways to use them:
- Sort after the crawl. Route pages by
page_typein your own code: documentation to one index, blog posts to another. - Keep only some pages. With
page_types,topicsorsource_hintson the request, a page that does not match comes back withfiltered: trueand no content, so nothing unwanted reaches your model:
curl https://api.millionshort.com/v1/crawl \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.org/",
"max_pages": 300,
"page_types": ["documentation", "tutorials", "faqs"]
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/crawl",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"url": "https://example.org/",
"max_pages": 300,
"page_types": [
"documentation",
"tutorials",
"faqs"
]
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch('https://api.millionshort.com/v1/crawl', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"url": "https://example.org/",
"max_pages": 300,
"page_types": [
"documentation",
"tutorials",
"faqs"
]
}),
});
if (!res.ok) throw new Error(`POST /v1/crawl failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);A filtered page was fetched to be labelled, so it is charged. When the unwanted pages live under their own paths, exclude is cheaper: a path that is excluded is never fetched.
Staying polite
A crawl follows the rules every fetch of ours follows, and you cannot switch them off:
- robots.txt. Every page we fetch is checked. A page it closes to our bot comes back as
ROBOTS_DISALLOWED, free. A site that closes everything gives a crawl that fails with that code and costs nothing, incachedas well. - Pace. A site gets at most one page a second from all our customers together, and one account at most 30 pages of one site a minute. Plan for about two seconds a page: 100 pages in three to four minutes, 1,000 in about 35. A large crawl takes hours.
- The daily limit. A team may fetch 2,000 pages of one site a day, the sitemap files a crawl reads included. A page fetched again and found unchanged counts once, so crawling the same section again the same day uses the limit only for what changed. At the limit a crawl ends with
stop_reason: "site_daily_limit"and keeps its pages, whatever your plan'smax_pagesceiling. - Two crawls of the same site share that pace. Run them one after the other.
Follow links off the site
By default a crawl stays on the host you named. "include_subdomains": true widens it to the site's other hosts. "same_domain": false lets it follow links to other sites:
curl https://api.millionshort.com/v1/crawl \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.org/links",
"max_pages": 100,
"max_depth": 1,
"same_domain": false,
"remove_top_sites": 10000
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/crawl",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"url": "https://example.org/links",
"max_pages": 100,
"max_depth": 1,
"same_domain": False,
"remove_top_sites": 10000
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch('https://api.millionshort.com/v1/crawl', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"url": "https://example.org/links",
"max_pages": 100,
"max_depth": 1,
"same_domain": false,
"remove_top_sites": 10000
}),
});
if (!res.ok) throw new Error(`POST /v1/crawl failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);This reads a page of links and the pages it points at. remove_top_sites leaves out links to the 10,000 most popular sites, the same cut Search has, so the crawl spends its pages on the primary sources and not on the large platforms every page links to. Keep max_depth small: off the site, the number of links grows fast, and max_pages is what stops it.
Cancel, and what is charged
curl -X DELETE https://api.millionshort.com/v1/crawl/$CRAWL_ID \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY"import os
import requests
r = requests.delete(
f"https://api.millionshort.com/v1/crawl/{os.environ['CRAWL_ID']}",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch(`https://api.millionshort.com/v1/crawl/${process.env.CRAWL_ID}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`DELETE /v1/crawl/… failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);- The pages that came back before the cancel are kept, can still be read for 7 days, and stay charged.
- The rest of the hold is handed back at once.
- Pages that were being fetched at that moment are dropped, and are not charged.
From an agent, over MCP
The MCP server has four tools for this: map, crawl, crawl_status and crawl_cancel. crawl takes the scope and mode fields of a crawl request (not formats, max_chars, json or webhook_id: pages come back as Markdown) and returns the job:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "crawl",
"arguments": { "url": "https://example.org/docs", "max_pages": 30, "include": ["^/docs/"] }
}
}A line for your agent's instructions: "To read a section of a site, call crawl with a small max_pages, then call crawl_status with the crawl's id as crawl_id every few seconds until its status is no longer queued or running. Each page costs a credit, so ask for no more pages than you will read."