Text, web pages and S3¶
Besides file uploads, Pagelore ingests text sent in the request, web pages and S3 objects, and can re-read the web and S3 ones later.
Every source takes metadata, on_conflict, chunking, process and
background (Ingestion) and answers
like an upload, plus stats and warnings.
Text and JSON¶
Each item becomes a document. Send up to 1000 items per request.
curl -X POST localhost:8000/api/v1/projects/1/documents/text -H 'Content-Type: application/json' \
-d '{"metadata": {"origin": "crm"},
"items": [{"text": "# FAQ\n...", "format": "markdown", "external_id": "faq"},
{"json": {"sku": "A1", "price": 9.5}, "file_name": "a1"}]}'
| Item field | |
|---|---|
text or json |
One of them. json is any JSON value, stored as a .json document and chunked by the json strategy |
format |
text, markdown or html, for text. Default: from file_name's extension, else text |
file_name |
Shown in results and citations. Default: text-<hash>.<ext> |
external_id |
Your id for it; sending it again makes a new version. Default: the file name |
metadata |
Merged over the request's metadata |
Web pages¶
# One page
curl -X POST localhost:8000/api/v1/projects/1/documents/url -H 'Content-Type: application/json' \
-d '{"urls": ["https://example.com/pricing"]}'
# A whole site: links up to 3 clicks away and its sitemaps, at most 200 pages
curl -X POST localhost:8000/api/v1/projects/1/documents/url -H 'Content-Type: application/json' \
-d '{"urls": ["https://docs.example.com/"], "max_depth": 3, "use_sitemaps": true,
"max_pages": 200, "include": ["/guide/*"], "background": true}'
A URL can be an HTML page, any supported file type (PDF, DOCX, ...), or an XML sitemap, whose pages are imported.
| Option | Default | |
|---|---|---|
urls |
required | 1 to 100 pages, files or sitemaps |
max_depth |
0 |
Follow links this many clicks away (0 to 10; 0 = only the given URLs) |
max_pages |
URL_MAX_PAGES (500) |
Most pages fetched (at most URL_MAX_PAGES) |
same_domain |
true |
Follow links only on the given URLs' hosts (www. included) |
include |
none | Only URLs matching one of these globs, on the full URL or its path (/docs/*) |
exclude |
none | Skip URLs matching any of these globs |
use_sitemaps |
false |
Also import each site's sitemaps (from robots.txt, else /sitemap.xml) |
respect_robots_txt |
true |
Obey robots.txt, its Crawl-delay, and robots meta tags |
How the crawl works¶
- Order: breadth first, so pages near the start URLs are fetched first.
If
max_pagesis reached, a warning says how many URLs were found but not fetched. - Politeness: requests are spaced by
URL_CRAWL_DELAY_MS(250) or the site'sCrawl-delay, and identify asURL_USER_AGENT(PageloreBot/0.1). - Content: HTML is read as served, without running JavaScript, and converted to Markdown with its headings; scripts, styles and embedded objects are dropped. Other files go to their loader.
- Unchanged pages: a page fetched before is requested with its
ETag/Last-Modified, and a304answer givesunchanged. - Final URL:
source_uriis the URL after redirects, and theexternal_iddefaults to the requested URL.
Safety: SSRF protection¶
A URL import makes your server send requests, so an API user could aim it at internal services (a cloud metadata endpoint, an admin panel).
- URLs that resolve to private, loopback or link-local addresses are refused (403), also after every redirect.
- The server connects only to the address it checked, so a second DNS answer cannot point somewhere else (DNS rebinding).
- Only
httpandhttpsare allowed.
Set URL_ALLOW_PRIVATE_NETWORKS=true only if every API user is trusted, for
example to import from an intranet.
| Setting | Default |
|---|---|
URL_FETCH_TIMEOUT_SECONDS |
30 |
URL_MAX_PAGES |
500 |
URL_CRAWL_DELAY_MS |
250 |
URL_ALLOW_PRIVATE_NETWORKS |
false |
URL_USER_AGENT |
PageloreBot/0.1 |
S3 and S3-compatible storage¶
Needs uv sync --extra s3. Works with AWS S3, MinIO, Cloudflare R2,
Backblaze B2, Wasabi and other S3-compatible stores.
# Every PDF under a prefix
curl -X POST localhost:8000/api/v1/projects/1/documents/s3 -H 'Content-Type: application/json' \
-d '{"bucket": "contracts", "prefix": "2025/", "include": ["*.pdf"]}'
# Exactly these objects
curl -X POST localhost:8000/api/v1/projects/1/documents/s3 -H 'Content-Type: application/json' \
-d '{"bucket": "contracts", "keys": ["2025/acme.pdf", "2025/globex.pdf"]}'
| Option | Default | |
|---|---|---|
bucket |
required | |
prefix |
"" |
Import every object under it ("" = the whole bucket) |
keys |
none | Exactly these objects (up to 1000) instead of a prefix |
include |
none | Only keys matching one of these globs, on the key or its last part (*.pdf) |
exclude |
none | Skip keys matching any of these globs |
max_objects |
S3_MAX_OBJECTS (1000) |
At most S3_MAX_OBJECTS |
- Credentials come only from the server's
S3_*settings, or boto3's default chain (environment,~/.aws, an instance role), never from requests. - Allowed buckets:
S3_BUCKETS(comma separated) limits the buckets requests may read; others return 403. - Unchanged objects: an object whose ETag has not changed since its
import is
unchangedand is not downloaded again. - The
external_iddefaults tos3://bucket/key.
| Setting | Default | |
|---|---|---|
S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEY / S3_SESSION_TOKEN |
empty | Empty: boto3's default chain |
S3_REGION |
empty | |
S3_ENDPOINT_URL |
empty | For MinIO, R2, B2, Wasabi, ... |
S3_ADDRESSING_STYLE |
auto |
auto, path (MinIO) or virtual |
S3_BUCKETS |
empty (all) | Buckets requests may read |
S3_MAX_OBJECTS |
1000 |
Most objects per request |
Sync¶
Sync re-reads the project's web and S3 documents, re-indexes what changed, and reports what is gone.
curl -X POST localhost:8000/api/v1/projects/1/sync -H 'Content-Type: application/json' \
-d '{"delete_missing": true}'
| Option | Default | |
|---|---|---|
document_ids |
all web and S3 documents | Only these documents |
delete_missing |
false |
Delete documents whose page or object is gone |
background |
false |
Return at once with a job_id, and sync as a background job |
- Unchanged pages and objects (by
ETag,Last-Modifiedor content hash) are left alone. - Changed ones become a new version, chunked like the version they replace.
- Gone ones (HTTP 404 / 410, no such key) are
missing, ordeletedwithdelete_missing.
Note
Sync re-reads the documents a project already has. It does not find new
pages or objects; import the URL or prefix again for those (existing,
unchanged ones are reported as unchanged).