Library API
import { openCrawler } from "polite-crawler";The package is ESM only, and it includes its TypeScript declarations.
openCrawler(options)
Section titled “openCrawler(options)”The function opens a crawler on a folder and gives a HybridCrawler. It is an OpenedCrawler (a PoliteCrawler that has discover, crawl, diff, watch and extract) with hybrid search: hybrid, embed and rankWithin. These members are optional in PoliteCrawler, so an object of your own that implements the interface of 0.1.1 or 0.1.2 stays correct.
| Option | Type | Default | What it does |
|---|---|---|---|
dir |
string |
(necessary) | The folder of the capture log, the bodies and the index. |
token |
string |
"PoliteCrawler" |
The product token that robots.txt rules match. |
userAgent |
string |
PoliteCrawler/ |
The full User- header. |
contact |
string |
none | An address for the User-. An email address goes into the From header too. |
renderer |
Renderer | false |
a Playwright renderer | The browser for pages that need JavaScript. false turns rendering off. |
maxActive |
number |
16 |
The number of hosts that get requests at one time. |
onBehalfOf |
string[] |
[] |
More product tokens whose robots.txt rules apply, for example ["Claude-. |
dispatcher |
Dispatcher |
an undici agent |
The dispatcher for the requests, for a proxy or a test. |
egress |
EgressOptions |
public addresses only | The addresses that the crawler fetches. { allowPrivate: true } permits loopback and private addresses. |
politeness |
PolicyOptions |
DEFAULT_ |
The limits of the policy, for each host or for some hosts. |
hostState |
HostStateStore |
the file hosts.sqlite in dir |
The pace, the counts and the stops of each host. The processes on one store share the file. |
clock |
Clock |
the real clock | The time of the crawler and the index, for a test. |
scope |
string |
none | A label for each capture record. |
onEvent |
(event) = |
none | A function that gets each request, response, wait, stop and skip. |
extractors |
Record<string, Extractor> |
the recipe page |
The readers of the recipes of an application. |
recipes |
Recipe[] |
none | The recipes of defineRecipe. reindex reads their captures. |
watchFloor |
a duration, for example "1h" |
"1h" |
The shortest every of a watch. |
embedder |
Embedder |
none | The local model of hybrid search: transformersEmbedder, ollamaEmbedder or your own. |
createRuntime(options) takes the same options, and your own log, blobs and index in place of dir. It gives the parts of the runtime that openCrawler uses. Then use catchUpIndex(runtime), as openCrawler does at open. It rebuilds a stale index. When the index is behind the log, it adds the captures that the index missed.
PoliteCrawler
Section titled “PoliteCrawler”The crawler of openCrawler has these methods. find, read, verify, extract, versions and diff read the store and send no request.
fetch(url, options?)
Section titled “fetch(url, options?)”The method fetches a page, reads it and adds it to the index. It gives a PageResult.
| Option | Type | Default |
|---|---|---|
render |
"auto" | "never" | "always" |
"auto" |
maxAge |
a count of milliseconds, or a text, for example "30m", "24h" or "7d" |
"24h" |
onBehalfOf |
string[] |
[] |
signal |
AbortSignal |
none |
scope, labels |
a text, and a record of texts | none |
fallback |
"archive" | "none" |
"none" |
archiveDespiteRobots |
boolean |
false |
The value "0" of maxAge asks the site again, and "auto" uses the freshness that the server gave.
With fallback: "archive", a page that the site refuses, or a site that is down, gets a copy from the Wayback Machine or Common Crawl. The result then has archived: the archive, the date of the copy and its URL there. Its outcome stays the outcome of the live fetch. By default, a page that the current robots.txt disallows gets no copy, and archiveDespiteRobots changes that.
interface PageResult { url: string; doc: string | null; // the document id, for read and verify outcome: string; // ok, not-modified, skipped, blocked, rate-limited and others status: number; title: string | null; chars: number; rendered: boolean; structured: string[]; // the schema.org types of the JSON-LD links: number; captures: string[]; // the capture ids behind the text, 10 or fewer capture: string | null; // the capture of the text to cite capture_count: number; fetched_at: string | null; // when the crawler fetched this text from_cache: boolean; // true when the store answered with no request held_back: boolean; // true when the page asked not to be AI input note: string | null; // for example "robots.txt disallows it for PoliteCrawler" archived?: { source: "wayback" | "commoncrawl"; timestamp: string; url: string; original: string }; // an archived copy, not a fresh fetch}find(q, options?)
Section titled “find(q, options?)”The method searches the stored documents with SQLite FTS5 and BM25, and gives a promise. It sends no request. The options are limit (default 10), kind (for example "page" or "pdf") and rank. Each result has doc, kind, title, url, snippet, score, ai_input, capture and fetched_at.
-
rankis"exact"(the default),"fast"or"hybrid"."fast"makes a long question faster."hybrid"also finds by meaning, and each hit then haspassage. Hybrid search tells how. -
Text in double quotes is a phrase, and
bake*is a prefix. -
The documents that hold each word come first, then the documents that hold one word.
-
Case, accents and Unicode forms do not change a match. Chinese, Japanese and Thai words match too.
-
A page that refuses AI input is not in the results.
read(doc, options?)
Section titled “read(doc, options?)”The method gives a range of the text of a document. The options are from (default 0), length (default 4000), capture, at and userProvided. A from or a length less than 0 is an error. The result names the capture and the fetched_at of its text. With capture, the method reads the text of that capture, not the current text.
With at (an ISO 8601 time or a Date), the method reads the version that was current at that time. The rules that choose the current version apply to the versions of that time. The result gives at. When at is before the first capture, before_first is true, the text is empty, and the note gives the time of the first capture. Give capture or at, not the two.
When a page refuses AI input, the title and the text are empty, and held_back is true, unless userProvided is true. A capture of a version that refused AI input is held back too. The crawler records each userProvided read. The MCP server sets it only with a signal from a person: read the rule.
verify(doc, quote, options?)
Section titled “verify(doc, quote, options?)”The method finds a quote in a stored document, and gives a promise. It ignores case, spaces, typographic punctuation, soft hyphens and Unicode forms. It gives found, the start and end positions, an excerpt, and the capture, blob and fetched_at of the text that holds the quote.
- With no option, it examines the current text first, then the earlier texts.
staleis true when only an earlier capture holds the quote. - With
capture, it examines the text of that capture only. A citation of that capture thus stays true after a new fetch. - With
at, it examines only the version that was current at that time. A time before the first capture givesfound: falseandbefore_first: true. - A page that refuses AI input gives
found: falseandheld_back: true, unlessuserProvidedis true. - An earlier version that refused AI input stays held back after a later capture drops the signal. With no option, the method does not examine it, and the note says so.
extract(doc, fields, options?)
Section titled “extract(doc, fields, options?)”The method checks the values that you propose for the fields of a stored document, and gives a promise. It does not make values. It only checks and locates the values that it gets. It sends no request.
const result = await crawler.extract(page.doc!, { price: { value: "4.50 EUR", kind: "money" }, since: { value: "2026-03-04", kind: "date" }, offer: { value: "4.50", kind: "json-ld:Product.offers.price" },});// a page that says "€4,50" gives "normalized", with the span of "€4,50" and its captureconst { status, normalization, span, capture } = result.fields["price"]!;| Option | Type | What it does |
|---|---|---|
capture |
string |
Check the version of this capture, not the current version. |
at |
string | Date |
Check the version that was current at this time. Give capture or at, not the two. |
userProvided |
boolean |
Check a page that refuses AI input. Use it only for a URL that a person gave. The crawler logs it. |
Each field has a value (a text or a number) and a kind: text, number, money, date, url, email, phone or json-ld:<path>. The result of each field gives these values:
status:verified(the exact text),normalized(a different form),ambiguous(more than one meaning),not-found,held-backorinvalid.span(start,endandin) orpath, the stored text (raw), anexcerptand thereadingthat matched.normalization: the names of the normalizations, joined with+, for examplethousands-separator+number-form.candidates: the places of an ambiguous field, each with itsreadings. The method does not choose one.captureandfetched_atof the text that the method read.
A normalized match must have one meaning. 1,234, 03/04/2026 and $12 for USD 12 give ambiguous, and the method does not guess. A page that refuses AI input gives held-back for each field, with no position, unless userProvided is true. The README of the package gives each normalization.
checkFields(source, fields) does the same check on a text and its metadata, with no store.
versions(doc)
Section titled “versions(doc)”The method gives the versions of a document, the newest first: the capture, the blob, the fetch time and the length of each text. A version that refused AI input shows no title.
discover(site, options?)
Section titled “discover(site, options?)”The method finds the pages of a site from its sitemaps and its feeds, and gives a promise. It fetches the files that list the pages, not the pages. Each file is a polite fetch with its capture.
| Option | Default | What it does |
|---|---|---|
maxFiles |
20 |
The most sitemap and feed files to read. |
maxUrls |
10000 |
The most URLs to give. |
maxBytes |
10 MiB | The most bytes of one file, after decompression. |
maxNesting |
3 |
The most levels of sitemap index to follow. |
budgetMs |
60000 |
The longest time of the discovery. No request starts after it. |
sameSite, allowHosts |
the site of site |
The hosts whose URLs discovery keeps. |
feeds, sitemaps |
none | More feeds and sitemaps to read. |
linkedFeeds |
true |
Read the page at site for the feeds that it links. |
maxAge, onBehalfOf, signal, scope, labels |
as for fetch |
These options apply to each file. |
The result gives urls (each with url, lastmod, changefreq, via and source), the newest lastmod first. It also gives sources (what discovery did with each file), dropped (the URLs that it did not keep, for each reason), stopped and note. Discovery keeps a URL only when robots.txt permits it.
crawl(seeds, options?)
Section titled “crawl(seeds, options?)”The method fetches the seeds, then follows the links of each page on the same site. It gives a CrawlRun: a for await loop gets each page when its fetch ends, and summary resolves at the end.
| Option | Default | What it does |
|---|---|---|
maxPages |
100 |
The most pages that the crawl gives. |
maxDepth |
3 |
The most links from a seed to a page. |
budgetMs |
600000 |
The longest time of the crawl. No request starts after it. |
sameSite, allowHosts |
the sites of the seeds | The hosts that the crawl follows. |
include, exclude |
none | Patterns: / matches a path, and a RegExp tests the whole URL. |
useSitemaps |
false |
Add the pages of the sitemaps, the newest first. |
render, maxAge, onBehalfOf, signal, scope, labels |
as for fetch |
These options apply to each page. |
Each page is a PageResult with depth, source (seed, sitemap or link) and referrer. The summary gives the counts of the pages and of the links that the crawl did not follow, and stopped and reason. The crawl keeps one request at a time for each host, at its pace. Its state is in memory, for one call.
diff(doc, options?)
Section titled “diff(doc, options?)”The method compares two versions of a stored document, and gives a promise. It sends no request.
| Option | Default | What it does |
|---|---|---|
from |
the version before to of the same kind |
The old version: a capture id, or { at } for the version that was current at a time. |
to |
the newest version | The new version: a capture id, or { at }. |
limits |
DIFF_ |
The bounds of the diff: characters, lines, steps, hunk lines and changes of the metadata. |
The result gives from and to (the capture, the fetch time and the length of each version) and summary (the counts of the lines, the words and the changes of the metadata). It also gives hunks and meta:
hunksgive the text as a line diff with 2 lines of context. Achangedline pairs a removed line with an added line, and itswordsgive the word diff.metagives the changes of the title, the URL and the metadata at their paths, for examplemeta.jsonld[0].openingHours.- The line diff uses the algorithm of Myers, with a budget of steps. A large change stays bounded. Then
exactis false ortruncatedis true, and the note tells why. - When a version or the document is held back, the result has no text and no title, and
sameis null.
The watch list keeps the pages that the crawler checks again on a schedule, in the file watch.sqlite of the store.
await crawler.watch.add("https://example.com/hours", { every: "6h" });
const run = crawler.watch.run({ budgetMs: 120_000 });for await (const event of run) console.log(event.kind, event.suspected, event.confirmed, event.url);console.log(await run.summary);| Method | What it does |
|---|---|
add(url, options?) |
It adds a page, or changes the options of its watch. The options are every (default 24h, floor 1h), confirm (2 or 1, default 2), render, labels, scope, onBehalfOf and keepSchedule. A new entry is due at once. |
remove(url) |
It removes a page. It gives false when the list does not have the page. |
list() |
It gives the entries, the first due first, with the last confirmed capture and a suspected change. |
run(options?) |
It checks the due entries through the normal fetch, to budgetMs (10 minutes) and maxPages (100). It gives a WatchRun. |
reschedule(url, { at }) |
It changes the time of the next check of a page, not before one floor after the last check. It gives the entry, or undefined. It is beta. |
Each event has the kind of the check: new, changed, unchanged, gone, refused or error. It also has the capture of the check, the last confirmed capture (previous) and the counts of the diff.
- With
confirm: 2, a change issuspectedat its first check. The next check givesconfirmedwhen it sees the same version. - A check that finds a stopped host is due again at the end of the stop.
- A run claims each entry with a lease, so two processes do not check one entry two times.
- A scheduler of the operator starts
watch.run, or the daemon starts it on a schedule.
reindex()
Section titled “reindex()”The method builds the index again from the capture log and the blobs, with no request. It builds a new index beside the old one, so a rebuild that fails keeps the old index. It gives the counts of the captures, the documents and the URLs, the damaged lines, the missing bodies and the readers that failed. The documents of a recipe that it cannot read stay.
close()
Section titled “close()”The method closes the browser, the log files and the index. A second close does nothing, and a method after the close rejects.
Recipes
Section titled “Recipes”A recipe tells the crawler what to fetch and how to read it into documents. The package has two recipes, and an SDK for a recipe of your own. Each fetch of a recipe is a fetch of the crawler, so robots.txt, the pace, the stops and the capture log apply.
The recipe reader starts the readers of the two recipes in your browser. Write a recipe starts a recipe of your own.
readVenue, readProduct and runRecipe take a crawler or a runtime of createRuntime. The option onBehalfOf of openCrawler does not apply to them: give onBehalfOf to each call.
readVenue(crawler, url, options?)
Section titled “readVenue(crawler, url, options?)”The function reads the opening hours of a venue from its own site. It reads the JSON-LD and the text of the home page, and of the pages that most likely hold hours or a menu.
import { compareHours, readVenue } from "polite-crawler";
const venue = await readVenue(crawler, "https://forno-esempio.example/", { name: "Forno Esempio", osm: "Mo-Fr 07:00-15:00; Sa 08:00-13:00; Su off",});console.log(venue.best?.hours, venue.best?.capture, venue.disagree);const change = compareHours(keptWeek, venue.from_site!.week);| Option | Default | What it does |
|---|---|---|
pages |
3 |
The pages after the home page that the recipe reads, from 0 to 8. |
name |
none | The name of the venue. names_ tells if the home page names it. |
requireName |
false |
With true, a home page that does not name the venue gives no reading. |
location |
none | The address, or lat and lon, of the venue, for a page that lists more than one location. |
osm |
none | An OpenStreetMap opening_ value. The recipe sends no request to OpenStreetMap. |
render, maxAge, onBehalfOf, signal, scope, labels, job |
as for fetch |
These options apply to each page. |
budget |
none | No request starts after this time. |
userProvided, fallback, archiveDespiteRobots |
as for read and fetch |
The rule for a held-back page, and the archived copies. |
- Each reading gives
from(jsonld,textorosm),rank,label,week,hours,inferred,partial,seasonandraw. It names itsurl,docandcapture. bestis the best reading of the opening hours.from_siteis the best reading of the site itself, with no guess.disagreenames the days where the readings disagree.- The result also gives
pages,menus,phone,captures,movedandheld_back. venueReadingsOf(doc)reads one stored document or version with no request.compareHours(kept, reading, { skipSplit })compares two weeks, day by day. It givesstatus(same,changedornew) and thedaysthat changed.
readProduct(crawler, url, options?)
Section titled “readProduct(crawler, url, options?)”The function reads the schema.org Product data of a product page. It takes the options of readVenue that apply to one page.
import { readProduct } from "polite-crawler";
const product = await readProduct(crawler, "https://bottega-campione.example/products/olio-esempio");console.log(product.wall, product.name, product.price, product.price_to, product.availability);- The result gives
name,brand,sku,gtin,price,price_to,availability,availabilities,variant,seller,image,docandcapture. - A price is
{ amount, currency, raw }, with an ISO 4217 currency.price_tois the highest price of a range. - The recipe picks the product of the page, not a related product.
variantis the variant that the URL names. - A shop that refuses the crawler gives
wall: trueand a note. The crawler does not try a different identity. productOf(records, url)reads JSON-LD records with no request.
defineRecipe(definition)
Section titled “defineRecipe(definition)”The function declares a recipe of your own: its name, the request for an input and the extractor.
import { defineRecipe, openCrawler, runRecipe } from "polite-crawler";
const menu = defineRecipe({ name: "forno-menu", mode: "api", minInterval: "2s", fetch: (day: string) => `https://api.forno-esempio.example/menu?day=${day}`, extract: (body, capture) => (JSON.parse(new TextDecoder().decode(body)) as { items: { id: string; name: string }[] }).items.map((item) => ({ doc: `menu:forno-esempio/${item.id}`, kind: "menu-item", title: item.name, text: item.name, url: capture.url, meta: {}, })),});
const crawler = openCrawler({ dir: "./crawl", recipes: [menu] });const run = await runRecipe(crawler, menu, "mon");| Value | Default | What it does |
|---|---|---|
name |
(necessary) | The name that goes into each capture record. Do not change it. |
extract |
(necessary) | The pure function that reads a body into documents. |
fetch |
the input is the URL | The function that gives the request for an input. |
mode |
page |
page obeys robots.txt. api is a documented API. |
accept, minInterval, maxAge, maxBytes, description |
The Accept header, the pace of the source, the age of a stored copy and the size of a body. |
runRecipe(crawler, recipe, input, options?)givesoutcome,docs,capture,from_cache,held_back,errorandnote.reindexreads the captures of the recipe again.- An extractor is pure and sends no request. When it throws, the runtime reports the error, and the fetch continues.
readJson(body, capture)reads a body as JSON in its declared encoding, and names a body that is not JSON.- The name of a recipe is part of each capture id. The README of the package gives each rule.
Hybrid search
Section titled “Hybrid search”Hybrid search fuses the BM25 ranking with the ranking of the vectors of a local model. It is opt-in, and it needs the option embedder. How hybrid search ranks shows the two lists and their fusion.
import { ollamaEmbedder, openCrawler, transformersEmbedder } from "polite-crawler";
const crawler = openCrawler({ dir: "./crawl", embedder: transformersEmbedder() });// or: embedder: ollamaEmbedder({ model: "nomic-embed-text" })
await crawler.embed({ budget: "10m" });const hits = await crawler.find("a loaf with a dark crust", { rank: "hybrid" });const ranked = await crawler.rankWithin("rye", ["url:https://example.com/a"], { rank: "hybrid" });transformersEmbedder(options)uses transformers.js in the process. Install the optional peer@huggingface/transformers. The options aremodel(Xenova/bge-small-en-v1.5),quantized(true),cacheDir,localOnly,pooling,queryPrefix,documentPrefixandbatch.- The first use of a transformers.js model downloads it from the Hugging Face Hub, not through the polite crawler.
ollamaEmbedder(options)sends the texts to a local Ollama server. The options aremodel(nomic-embed-text),baseUrl(http://127.0.0.1:11434),batch(32),allowRemote(false),timeoutMsand the prefixes.- An
Embedderof your own hasid(the model and its version),dimensions,maxInputTokensandembed(texts, { signal, purpose }).
Option of find and rankWithin |
Default | What it does |
|---|---|---|
candidates |
50 |
The BM25 candidates. A candidate with no vectors gets them first. |
neighbors |
50 |
The documents with the closest chunks, from a brute-force cosine. |
fusionK |
60 |
The constant k of reciprocal rank fusion: 1 / (k + rank) for each list. |
signal |
none | An AbortSignal that stops the embedder. |
embed(options)gives vectors to each stored page that has none. The options arebudget("10m"),maxDocs,kindandsignal. The result counts the documents, the new texts, the reused vectors and the held-back pages, and givesstopped.- The vectors go into
vectors.sqlite, a projection beside the index. The key of a row is the hash of the text, the chunk and theidof the embedder, so a reindex keeps each vector. - A held-back page does not go to the embedder, and no result gives it.
- Without an embedder,
rank: "hybrid",embedandrankWithinwithrank: "hybrid"reject withNO_EMBEDDER.
Signed requests
Section titled “Signed requests”The option signer of openCrawler signs each request with HTTP Message Signatures, as the Web Bot Auth draft tells (draft-ietf-webbotauth-httpsig-protocol-00).
const crawler = openCrawler({ dir: "./crawl", signer: { privateKey: pem, signatureAgent: "https://bot.example.com" },});createWebBotAuthSigner(options)makes a signer from an Ed25519 key. The options areprivateKey,signatureAgent,agentType,keyId,lifetimeMsandlabel.keyDirectory(keys)makes the key directory to host at/.well-known/http-message-signatures-directory, with the typeapplication/http-message-signatures-directory+json.verifySignature(request, directory)checks the signature of a request. Use it to test your setup.
The User-Agent does not change. The README of the package tells how to host the key directory.
Export to a web archive
Section titled “Export to a web archive”exportWarc and exportWacz write the stored captures as WARC/1.1 or WACZ 1.1.1. Archive tools read them, for example warcio, pywb and ReplayWeb.page. They only read the store.
import { exportWacz, exportWarc } from "polite-crawler";
await exportWarc("./crawl", { out: "crawl.warc.gz" });const result = await exportWacz(crawler.runtime, { out: "site.wacz", host: "example.com" });| Option | Default | What it does |
|---|---|---|
out |
none | The archive to write. The export needs it. |
since, until |
none | Only the captures received at since or later, and before until. |
host |
none | Only the captures of this host and its subdomains. |
urlPrefix |
none | Only the captures whose URL starts with this text. |
ids |
none | Only the captures with these ids. |
includeRefusals |
false |
A metadata record for each capture with no body too. |
overwrite |
false |
Replace the file when it exists. |
The result counts the records of each type, the captures with no body, the missing bodies and the damaged lines of the log. A capture keeps only some headers, so the export rebuilds the HTTP header block and marks the record. The README of the package tells what goes into the archive and why.
The daemon
Section titled “The daemon”import { startDaemon } from "polite-crawler";
const daemon = await startDaemon({ dir: "./crawl", tick: "1m", onChange: (event) => console.log(event.url, event.kind, event.capture), mcp: { port: 9307 }, // the MCP tools over local HTTP, with a bearer token});await daemon.done; // after SIGINT, SIGTERM or daemon.stop()startDaemon checks the watch list on a schedule. Each tick is one watch.run, so each polite rule applies. The daemon, tick by tick shows a schedule. It takes the options of openCrawler and these options:
| Option | Default | What it does |
|---|---|---|
tick |
1m |
The longest wait between two ticks, 1s or more. A tick comes sooner when an entry is due sooner. |
jitter |
10s |
A random wait from 0 to this time after each tick. A check does not come before its time. |
budget |
10m |
The budget of the checks of one tick. |
maxPages |
100 |
The most checks of one tick. |
grace |
10s |
At a stop, the checks in progress get this time to end. Then they abort, and their leases end. |
events |
the standard output | A file or a function for the change lines, one JSON line for each change. false writes no line. |
onChange |
none | A function for each change. changeCommand(command) gives a function that starts a command of the operator. |
mcp |
none | The MCP server over HTTP: port, host, allowRemote, token, tokenFile, onBehalfOf and allowUserProvided. |
mcpHost |
mcpHttpHost of polite- |
The seam to the MCP server. A different MCP host can replace the default. The default needs the package polite-. |
signals |
true |
false installs no handler of SIGINT and SIGTERM. |
- A change is an event with
confirmed: true. TheDaemongivesstatus(),stop(grace?),done,crawler,mcpandstateFile. readDaemonState(dir)reads the state file of a store.scheduleWatches(watch, options)gives the schedule over the watch list of a crawler of your own.startMcpHttpServer(crawler, options)ofpolite-crawler-mcpserves the tools over HTTP. There,crawl_siteandcrawl_discoverare MCP tasks.
The MCP server
Section titled “The MCP server”The MCP server is the package polite-crawler-mcp, so polite-crawler loads no MCP SDK and no zod. Until 0.2.0, it was the entry point polite-crawler/mcp. Its nine tools are procedures on the shared MCP host of @procedures/mcp-server.
import { openCrawler } from "polite-crawler";import { createMcpServer, startMcpServer } from "polite-crawler-mcp";
await startMcpServer({ dir: "./crawl" }); // standard input and output
const server = createMcpServer(openCrawler({ dir: "./crawl" }));await server.connect(transport); // one transport of the MCP SDKThe server has no tool that adds a watch or writes an export. These are actions of the operator.
Option of createMcpServer |
Default | What it does |
|---|---|---|
onBehalfOf |
["Claude- |
The product tokens whose robots.txt rules apply to each fetch, with the token of the crawler. |
allowUserProvided |
false |
The opt-in of the operator: user_ works when the client cannot ask the user. |
renderOff |
none | The reason for a server with no browser. A page that needs JavaScript shows it in its note. |
startMcpServer takes the options of openCrawler and these options. It turns rendering off at start when no browser is installed. With the option embedder, the tool crawl_find takes rank: "hybrid".
The entry points
Section titled “The entry points”The package is ESM only. These are its entry points:
| Import | What it gives |
|---|---|
polite- |
openCrawler, and the parts of the runtime for an application. It needs Node.js. |
polite- |
parseRobots, decide, robotsFromStatus, robotsFromResponse, productToken: robots.txt as RFC 9309 specifies it. decide gives the rule that decided and its line. A robots.txt that is a web page is unreadable. |
polite- |
extractPage: the JSON-LD, the visible text, the links and the decision about JavaScript. It also gives the canonical URL, a quick redirect, the name of a bot check and notes about what it left out. |
polite- |
fromText, fromSchemaOrg, fromCompact, describeWeek and compareHours: opening hours. A reading tells its season and if it left out a rule (season, partial). |
polite- |
classify, parseRetryAfter: the outcome of a response. |
polite- |
HostScheduler, backoffMs, restAfter: one request in progress for each host, and the rest of a host after a request. |
polite- |
readSignals: content signals for AI input. |
polite- |
canonicalUrl, cacheKeyOf, siteOf, scopeTest: the canonical form of a URL, its cache key, its site and the scope of a crawl. It imports no module. |
polite- |
decodeBody, bodyEncoding: the text of a body in its declared encoding. It imports no module. |
polite- |
send, sendWithToken, tokenStore, readGrant, reactToOutcome: the polite send of a documented API, with the OAuth 2.0 client credentials grant, and the reaction of a host to an answer. It stores no page. |
The entry points below polite-crawler have no Node.js dependency, so they operate in a browser too. The MCP server is the package polite-crawler-mcp: createMcpServer, startMcpServer and startMcpHttpServer. It needs Node.js.
The main entry point also exports Crawler, CaptureLog, DocIndex, FileBlobStore, Extractors, fetchAndIndex, fetchPage, reindex and makeRecord, for an application that builds its own runtime. It exports the readers that such an application uses: extractPage, decodeBody, readPdf, the hours reader, parseRobots and decide.
The stable API is openCrawler with its results (extract too), the MCP server of polite-crawler-mcp, the reader entry points, and exportWarc and exportWacz. The recipes (readVenue, readProduct, compareHours) and the recipe SDK (defineRecipe, runRecipe) are stable too. The diff, the watch list, the command line and the store on disk are stable too. The parts of the runtime are the engine: before version 1.0.0, a minor version can change them, and the changelog says so. The declaration of each part of the engine has the tag @beta, so your editor shows it. The API review gives the tier of each export, and CI compares the public API with a report of it.