API reference
crawl()
Map and crawl an entire website
29 min read
New to KLOAKD? Use the high-level client.crawl() orchestrator instead of the raw webgrph.crawl() endpoint. It handles discovery, fetching, and optional extraction in a single call — no polling required. See the Quickstart for a 30-second example.
High-level orchestrator: client.crawl()
The crawl() orchestrator chains discovery (webgrph.crawl()), fetching (evadr.fetch()), and optional extraction (kolektr.page()) into a single call. It returns a SiteCrawlResult with every page fetched and ready to use.
Parameters
| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| url | string | Yes | — | Root URL to crawl |
| max_depth | integer | No | your plan's maximum; 3 with Java's CrawlOptions.build() | Maximum crawl depth |
| max_pages | integer | No | your plan's maximum; 100 with Java's CrawlOptions.build() | Maximum pages to crawl |
| extract_schema | object or list | No | null | Schema for structured extraction on every page: {field: "css:selector"} (prefix optional) or a fields list |
| session_artifact_id | string | No | null | Authenticated session from Fetchyr |
| include_external_links | boolean | No | false | Follow links to other domains |
Examples
from kloakd import Kloakd
client = Kloakd(api_key="sk-live-...", organization_id="your-org-id")
# Crawl + extract in one call
result = client.crawl(
"https://example.com",
max_depth=2,
extract_schema={"title": "h1", "content": "article"},
)
print(f"Crawled {result.total_pages_discovered} pages")
for page in result.pages:
print(f" {page.url} — {page.status_code}")
if page.structured_data:
print(f" Title: {page.structured_data.get('title')}")
import { Kloakd } from 'kloakd-sdk';
const client = new Kloakd({
apiKey: 'sk-live-...',
organizationId: 'your-org-id',
});
const result = await client.crawl('https://example.com', {
maxDepth: 2,
extractSchema: { title: 'css:h1', content: 'css:article' },
});
console.log(`Crawled ${result.totalPagesDiscovered} pages`);
for (const page of result.pages) {
console.log(` ${page.url} — ${page.statusCode}`);
}
result, _ := client.Crawl(ctx, "https://example.com",
&kloakd.CrawlOrchestratorOptions{
MaxDepth: 2,
ExtractSchema: map[string]string{"title": "css:h1", "content": "css:article"},
})
fmt.Printf("Crawled %d pages\n", result.TotalPagesDiscovered)
for _, page := range result.Pages {
fmt.Printf(" %s — %d %v\n", page.URL, page.StatusCode, page.StructuredData)
}
SiteCrawlResult result = client.crawl("https://example.com",
CrawlOptions.builder()
.maxDepth(2)
.extractSchema(Map.of("title", "css:h1", "content", "css:article"))
.build());
System.out.printf("Crawled %d pages%n", result.totalPagesDiscovered());
for (CrawlPage page : result.pages()) {
System.out.printf(" %s — %d %s%n", page.url(), page.statusCode(), page.structuredData());
}
Streaming: client.crawlStream()
Get real-time progress events as the crawl discovers and fetches pages:
for event in client.crawl_stream("https://example.com", max_depth=2):
print(f"[{event.type}] {event.url or ''}")
for await (const event of client.crawlStream('https://example.com', { maxDepth: 2 })) {
console.log(`[${event.type}] ${event.url ?? ''}`);
}
CrawlProgressEvent types
| Event type | Description |
|------------|-------------|
| discovery_started | Crawl discovery started (Python and TypeScript only) |
| discovery_complete | All pages discovered |
| page_fetching | Started fetching a page |
| page_fetched | Page fetched successfully |
| page_failed | Page fetch failed |
| crawl_complete | Crawl finished, results ready |
Low-level API: webgrph.crawl()
The raw endpoint for direct API calls or when you need fine-grained control over polling and pagination.
Endpoint
POST /api/v1/organizations/{org_id}/webgrph/crawl
Description
Crawl a website breadth-first, building its page hierarchy. Each page is fetched by the same engine as fetch(), which works out per site how to get past its protection.
A crawl maps the site: it finds the pages and how they link, without pulling data from them. To also get the items on each page (products, prices, articles) into rows you can download, use a crawl-extract job (POST …/webgrph/crawl-extract). It takes the same url, max_depth and max_pages, and takes longer than a crawl, because every page it fetches is also extracted.
Request body
| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| url | string | Yes | — | Root URL to crawl |
| max_depth | integer | No | your plan's maximum | Maximum crawl depth, 1 to 100 |
| max_pages | integer | No | your plan's maximum | Maximum pages to crawl, 1 to 100000 |
| include_external_links | boolean | No | false | Follow links to other domains |
| session_artifact_id | string | No | null | Authenticated session from Fetchyr. Without one the crawl does not follow sign-in, sign-up and captcha links |
| capture_mode | string | No | content | structure, content or visual: what the crawl captures of each resource. visual always loads images and stylesheets (extras) |
| scope | object | No | null | Which URLs the crawl may follow: same_host (default true), same_domain, allowed_subdomains, allowed_domains, excluded_paths, include_patterns, exclude_patterns (globs). Other keys are ignored |
| budget | object | No | null | Resource limits: max_resources, max_depth, max_file_size and max_total_bytes (bytes), max_failures, max_redirects. Other keys are ignored |
| fast_mode | boolean | No | false | Deprecated; has no effect |
| use_session_manager | boolean | No | false | Deprecated; has no effect |
| include_resources | array of strings | No | [] | The extras pages may load: any of images, media, fonts, stylesheets, tracking. Left out or empty: none are loaded |
| max_data_mb | number | No | none | The most data this crawl may use, in MB (1 MB = 1,000,000 bytes). See the data limit |
| estimate_id | string | No | null | The estimate_id of the estimate you saw before starting |
| cost_acknowledged | boolean | No | false | You accepted the estimate's data use and risks. See consent |
| urls | array of strings | No | null | Fetch exactly these pages (same site as url, at most max_pages); depth is not followed. See map the site first |
| include_paths | array of strings | No | null | Follow only links whose path starts with one of these prefixes (each starts with /). The start page is always fetched |
| robots_acknowledged_hosts | array of strings | No | null | Hosts whose robots.txt stop you acknowledge, for this crawl only: the host of the 409 that stopped it. Recorded. See robots.txt |
max_depth and max_pages are capped at your plan's maximum, which is also
the default when you leave them out:
| Plan | max_pages | max_depth |
|------|-------------|-------------|
| Free | 500 | 5 |
| Pro | 500 | 7 |
| Pro+ | 2,000 | 10 |
| Enterprise | 100,000 | 100 |
At 0.7.0 the Python, TypeScript and Go SDKs send max_depth and max_pages
only when you set them (in Go, when they are above 0), so the API applies
your plan's maximum. The Java SDK sends them when they are above 0, and
CrawlOptions.build() fills an unset maxDepth or maxPages with 3 or
100, so client.crawl() with options from build(), or with null
options, sends 3 and 100 unless you set other values. buildAsSet()
leaves them unset, and so do the webgrph() methods that take the limits as
int arguments when you pass 0. Earlier versions differ: Python 0.6.0 sent
3 and 100 unless you passed other values, and the TypeScript SDK and Go's
client.Crawl did the same before 0.5.0.
Sign-in and captcha pages
A crawl made without your session (session_artifact_id) does not follow a link, or a sitemap URL, whose path has a whole segment naming a sign-in, sign-up, sign-out or captcha page: login, log-in, signin, sign-in, signup, sign-up, register, registration, logout, log-out, signout, sign-out or captcha, with or without an extension (/login.php). Without your session such a page answers with a login wall or a challenge, so fetching it would spend data and time for no content. Only a whole segment counts: /blog/how-to-register-a-domain is crawled. Pages you list in urls are always fetched, and a crawl with your session follows these links as any other. The skipped links are not listed in the crawl's answer.
Extras are off by default
A page is more than its text. Besides the page itself, its scripts and its data, a browser would also load its extras:
| Extra | What it is |
|-------|------------|
| images | Pictures, photos and icons |
| media | Video and audio |
| fonts | Web fonts |
| stylesheets | The page's styling |
| tracking | Analytics and advertising scripts |
None of them hold the content or data a crawl is for, and together they are often most of a page's weight. A crawl or crawl-extract job does not load them unless you name them in include_resources, for example "include_resources": ["images"]. Nothing else that is not content or data is loaded either. The estimate says how much each extra would add (data.saving_by_category_mb), so you can see what leaving it out saves.
The same default applies to fetch (POST …/evadr/fetch and …/evadr/fetch/async) and extract (POST …/kolektr/extract and …/kolektr/extract/html): each takes the same optional include_resources.
One exception: a crawl with capture_mode: "visual" captures how pages look, so it always loads images and stylesheets, whatever include_resources says. The estimate lists them in include_resources_locked and does not offer them as savings, and its include_resources is the full set that will load. The app shows them ticked and greyed out, with the note "Visual capture loads images and stylesheets".
The data limit
max_data_mb caps the data one job may use, in MB (1 MB = 1,000,000 bytes; 1,000 MB = 1 GB). When the job reaches it, no new page is started, pages already being fetched finish, and the job ends partial with partial_reason: "data_limit" and the message "Stopped at your data limit of N MB. Continue with a higher limit to fetch more." Continue it with a higher max_data_mb to fetch the rest.
The status of a crawl (GET …/webgrph/crawl/{crawl_id}) and of a crawl-extract job (GET …/webgrph/crawl-extract/{job_id}) reports data_used_mb, max_data_mb and include_resources.
Through the API, a job without max_data_mb has no limit of its own: only your organisation's data allowance limits it. The app always sets one, filled in with the estimate's suggested_max_data_mb.
Estimate before you start
POST /api/v1/organizations/{org_id}/webgrph/crawl/estimate takes the same body as the crawl and says what that crawl would do, without starting it. POST …/webgrph/crawl-extract/estimate does the same for a crawl-extract job (it needs the Kolektr module, as the job does). url, max_depth, max_pages, capture_mode and include_resources (and extract for crawl-extract) are what it estimates; send the same values when you start.
An estimate is not metered: it uses no data allowance and no work slot. It needs your API key and is rate-limited per organisation. It looks at the site for at most 12 seconds; when it cannot, you still get an estimate, from your limits only.
curl -X POST https://api.kloakd.dev/api/v1/organizations/$ORG_ID/webgrph/crawl/estimate \
-H "Authorization: Bearer sk-live-..." \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/", "max_depth": 2, "max_pages": 10}'
{
"mode": "crawl",
"url": "https://example.com/",
"max_depth": 2,
"max_pages": 10,
"plan_limits": {"max_depth": 5, "max_pages": 500, "plan_tier": "free"},
"clamped": false,
"site": {"reachable": true, "sitemap_pages": 1234, "homepage_links": 57, "probe_error": null},
"est_pages": {"low": 10, "high": 10, "source": "sitemap"},
"will_hit_page_cap": true,
"time_budget_s": 150,
"est_duration_s": {"low": 40, "high": 150},
"est_gb": 0.03,
"gb_remaining": 4.2,
"will_exhaust_quota": false,
"warning": null,
"explanation": "A crawl maps the site: it finds the pages and how they link, without pulling data from them."
}
| Field | Description |
|-------|-------------|
| max_depth, max_pages | The values the crawl would use, after your plan's limits |
| plan_limits | Your plan's maximum depth and pages, and its tier |
| clamped | true when a value you sent was lowered to the plan's limit |
| site | What the probe found: sitemap_pages (null without a sitemap), homepage_links (links to the same host on the start page; null when it was not fetched), probe_error (null, or why the probe found less: for example "the site did not answer within 12 s", or "the sitemap could not be read within 12 s: no page of it counted" when a large sitemap was not counted in time, which does not mean the site has none). The probe takes at most 12 s in all |
| est_pages | Pages the crawl would fetch, low to high. source says where the number came from: sitemap (the site's sitemap), homepage_links (links on the start page) or limit (the size of the site is unknown, so only your max_pages is known) |
| will_hit_page_cap | The site seems larger than max_pages |
| time_budget_s | The crawl's time budget, exactly what the crawl would get |
| est_duration_s | How long it may take, low to high seconds; high is at most time_budget_s |
| est_gb, gb_remaining | Data it may use, and what you have left (null when unknown) |
| will_exhaust_quota | est_gb is more than you have left |
| warning | A sentence when something needs your attention, else null |
| explanation | What the mode does, in one or two sentences |
The estimate also says what data the crawl may use, in MB:
{
"include_resources": [],
"data": {
"source": "root_page",
"per_page_mb": {"typical": 1.2, "high": 4.0},
"total_mb": {"low": 3.0, "typical": 12.0, "high": 40.0},
"total_mb_all_resources": {"typical": 30.0, "high": 120.0},
"saving_mb": {"typical": 18.0, "high": 80.0},
"by_category_mb_per_page": {"document": 0.3, "script": 0.6, "data": 0.1, "images": 1.1, "media": 0.0, "fonts": 0.1, "stylesheets": 0.08, "tracking": 0.05},
"saving_by_category_mb": {"images": 11.0, "media": 0.0, "fonts": 1.0, "stylesheets": 0.8, "tracking": 0.5}
},
"share_of_remaining": {"typical": 0.01, "high": 0.04},
"consent_required": false,
"risks": ["Some sites block automated visitors; a page that cannot be fetched still uses the data received while trying."],
"suggested_max_data_mb": 40.0,
"estimate_id": "…"
}
| Field | Description |
|-------|-------------|
| include_resources | The extras this estimate counts as loaded: yours and the locked ones |
| include_resources_locked | Extras that cannot be turned off for this crawl (images and stylesheets for capture_mode: "visual"); they are left out of the savings |
| data.source | Where the page weight came from: site_profile (pages of this site measured before), root_page (the site's start page and what it references) or typical (typical page sizes) |
| data.total_mb | The data the crawl may use: low, typical and high |
| data.total_mb_all_resources | The same with every extra loaded |
| data.saving_mb, data.saving_by_category_mb | What leaving the extras out saves, in all and for each |
| share_of_remaining | typical and high as a share of the data you have left (0.04 is 4%) |
| consent_required | The app asks you to accept the estimate before it starts. See consent |
| risks | What can go wrong, in plain words |
| suggested_max_data_mb | A data limit: total_mb.high, rounded up |
| estimate_id | Send it back with the start. Valid for 30 minutes |
est_gb is total_mb.typical in GB.
The app shows this estimate before every crawl and crawl-extract job: the time, the data as typical and high, the share of what you have left as a bar, and the risks. It has a "Load these extras" checkbox for each extra, all unticked, each with what leaving it out saves; a data limit filled in with suggested_max_data_mb; and Start, Adjust (change the depth and the page limit, and see the estimate again) and Cancel.
Consent
Not every crawl succeeds: a site can refuse automated visitors, its start page may not be reachable, or a page may be too large to load, and the data received while trying still counts. When a crawl may use a large share of what you have left (consent_required: the high estimate is 10% or more of your remaining data, or it would use it all up), the app asks you to tick "I understand and accept" before Start, and sends estimate_id and cost_acknowledged: true with the start.
A start from a signed-in dashboard session whose estimate requires consent, without a valid estimate_id and cost_acknowledged: true, is refused with 409 and {"error": "cost_acknowledgement_required"}. Requests with an API key are not refused: a program cannot tick a box, so set max_data_mb to bound what it may use. The acknowledgement is kept with the job.
Map the site first
POST /api/v1/organizations/{org_id}/webgrph/map shows the site's sections before you crawl it. It reads the site's robots.txt, its sitemaps and the links on its start page, and fetches no other page. It is metered like a crawl (it uses a little data) and needs the same plan.
curl -X POST https://api.kloakd.dev/api/v1/organizations/$ORG_ID/webgrph/map \
-H "Authorization: Bearer sk-live-..." \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/", "max_urls": 5000}'
{
"url": "https://example.com/",
"source": "both",
"total_urls": 1234,
"truncated": false,
"data_used_mb": 0.8,
"branches": [{"path": "/products/", "url_count": 800, "sample_urls": ["…"], "children": []}]
}
source is sitemap, links or both. The branches form a tree by path, up to 3 levels, largest first; a level shows at most 50, and the rest are grouped as "other".
Then crawl only what you want:
include_paths: the crawl follows only links under these path prefixes, for example["/products/"]. The start page is always fetched.urls: the crawl fetches exactly these pages, and no others. The first one counts as the root of the tree.
Both work for crawl and crawl-extract, and are kept when the crawl is continued. In the app, "Map the site first" shows the tree with its counts and a checkbox for each section (open a section to tick single pages), and the chosen ones go through the same estimate and confirmation. "Try one page first" runs crawl and extract on the start page only (urls: [the start page]), so you can check the result before crawling more.
robots.txt
A crawl reads each site's robots.txt before it fetches a page of it, as every route does (When robots.txt stops a request).
- The start page. When robots.txt stops the start page, the crawl is not
started: the API answers
409ROBOTS_DISALLOWEDwith thehost, thereasonand therule. A bare domain is crawled from the address the site answers on, so thehostmay bewww.example.comwhen you sentexample.com: acknowledge thehostthe409names. To crawl anyway, send the same request again with that host inrobots_acknowledged_hosts. The acknowledgement is for this crawl only; it is recorded, and the next crawl of the site stops again unless it names the host too. - Other pages. A page robots.txt does not allow, on a host you did not
acknowledge, is skipped, not fetched. The finished crawl's
robotssays what was skipped:skipped_count,by_reason,hosts,skipped(each page, host, reason and rule) andacknowledged_hosts. It isnullwhen robots.txt changed nothing. - When KLOAKD could not check. At the start, a
503ROBOTS_CHECK_UNAVAILABLE(withreason: "exits_refused"when every exit refused to connect to the site): not a stop, nothing to acknowledge, nothing was crawled; retry later. During a crawl, the pages KLOAKD could not check wait: the crawl ends partial withpartial_reason: "robots_unavailable", and you can continue it to fetch them.
Time budget
Each crawl gets a time budget from the pages it is asked for: max_pages × 15 seconds, at least 10 minutes and at most 10 hours. A crawl of up to 40 pages gets 10 minutes; one of 100 pages gets 25 minutes; one of 1,000 pages gets 4 hours 10 minutes; one of 2,400 pages or more gets 10 hours. 15 seconds a page is what a measured run took with every page fetched by the full engine, three at a time per site. Many crawls end well before their budget; the budget is the upper bound.
The crawl runs in parts and keeps its place between them. When the whole budget is used before every page found was fetched, the crawl ends completed with is_partial: true, partial_reason: "time_budget" and resumable: true, and you can continue it.
Response
Returns 202 Accepted with a crawl_id (and success, url, total_pages: 0); the crawl runs asynchronously. Poll GET /api/v1/organizations/{org_id}/webgrph/crawl/{crawl_id}:
{
"crawl_id": "crawl-abc123",
"status": "crawling",
"organization_id": "your-org-id",
"total_pages": 17,
"max_depth_reached": 2,
"artifact_id": null,
"error": null,
"message": null,
"pages_discovered": 17,
"pages_fetched": 15,
"pages_unfetched": 2,
"is_partial": false,
"partial_reason": null,
"resumable": false,
"error_code": null,
"time_budget_s": 1500,
"elapsed_s": 312.4,
"est_remaining_s": 1187.6
}
While it runs, status is created, queued, starting or crawling (just after the start it can briefly read running). It ends as completed, failed or cancelled. held_quota is neither: the crawl is held until you have data again, with what to do in message and error left null; keep polling or stop, but do not treat it as failed. An unknown crawl_id answers 404.
total_pages is the number of pages the crawl found. The folders the site tree adds to group pages (such as https://example.com#path-catalogue) and the API and asset nodes are display only: they are not counted. The outcome fields say what the crawl really did with those pages; each is null until the crawl has reported it:
| Field | Type | Description |
|-------|------|-------------|
| pages_discovered | integer or null | Pages found |
| pages_fetched | integer or null | Of those, pages fetched |
| pages_unfetched | integer or null | Pages asked for and not obtained |
| is_partial | boolean or null | The crawl stopped before asking for every page it found. Its status is still completed |
| partial_reason | string or null | time_budget, max_pages, data_limit (the data limit), robots_unavailable (robots.txt) or error |
| resumable | boolean or null | true when …/continue can fetch the rest |
| error_code | string or null | For a crawl that did not complete: crawl_failed, root_unfetched (the start page could not be fetched), cancelled or held_quota |
| message | string or null | For held_quota: what to do |
| time_budget_s | integer or null | The crawl's whole time budget, in seconds |
| elapsed_s | number or null | Seconds the crawl has used of it |
| est_remaining_s | number or null | Seconds of the budget left |
| data_used_mb | number or null | Data the crawl has used, in MB |
| max_data_mb | number or null | Its data limit; null when none was set |
| include_resources | array | The extras it loads |
| resource_bytes | object or null | What its pages weighed, in bytes, by request category: document, script, data, images, media, fonts, stylesheets, tracking. Every attempt counts, failed ones included, and a page asked for again by a continue adds to its count. On the crawl's status only, outside_pages counts the crawl's requests that belong to no page (robots.txt, sitemaps, API probes), summed across a continue, so the categories come close to the crawl's data use (the robots.txt reads made before the crawl starts are not counted). A page's own metadata has no outside_pages. null until a page has reported it |
| blocked_requests | object or null | The requests its pages' extras would have made and the crawl blocked (the extras you left out of include_resources), by the same categories. null until a page has reported it |
A completed crawl is therefore not always a whole one: check is_partial, and compare pages_fetched with pages_discovered.
resource_bytes and blocked_requests say where a crawl's data went and what leaving extras out saved. The crawl's data use is still data_used_mb.
Then read the pages, cursor by cursor, from GET /api/v1/organizations/{org_id}/webgrph/crawl/{crawl_id}/pages?limit=500&cursor=…:
| Query parameter | Default | Description |
|-----------------|---------|-------------|
| limit | 100 | Nodes per page, 1 to 1000; outside that range answers 422 |
| cursor | — | The next_cursor of the previous page; anything else that is not a non-negative integer answers 422 |
| include_grouping | false | Also return the tree's grouping folders (metadata.is_grouping: true). They were not fetched. By default they are left out and each page is listed under the page the crawl found it on |
{
"crawl_id": "crawl-abc123",
"nodes": [
{
"id": "…",
"url": "https://example.com",
"parent_url": null,
"children_urls": ["https://example.com/about"],
"depth": 0,
"category": "page",
"classification_confidence": 0.0,
"metadata": { "title": "Example Site", "is_content": true, "is_api_node": false, "fetch_status": "fetched", "fetch_error": null }
}
],
"next_cursor": "100",
"total": 42
}
A crawl's pages are kept for 2 hours after it is written. After that
…/pages answers 404 ("not found or expired"), though the status still
answers. Read the pages you need soon after the crawl ends.
POST /api/v1/organizations/{org_id}/webgrph/crawl/{crawl_id}/cancel stops a running crawl (partial results are kept); it answers 409 when the crawl is already cancelled or not found. GET …/crawl/{crawl_id}/events streams its progress (SSE streaming).
Continue a partial crawl
A crawl that ends with is_partial: true can be continued when it stopped at its time budget (partial_reason: "time_budget", resumable: true), or when it stopped at its page limit (partial_reason: "max_pages") and you give it a larger max_pages:
curl -X POST https://api.kloakd.dev/api/v1/organizations/$ORG_ID/webgrph/crawl/$CRAWL_ID/continue \
-H "Authorization: Bearer sk-live-..."
The body is optional. Without it the crawl continues with the same limits and a new time budget. To give it more room, send higher limits:
curl -X POST https://api.kloakd.dev/api/v1/organizations/$ORG_ID/webgrph/crawl/$CRAWL_ID/continue \
-H "Authorization: Bearer sk-live-..." \
-H "Content-Type: application/json" \
-d '{"max_pages": 2000, "max_depth": 4}'
| Field | Type | Description |
|-------|------|-------------|
| max_pages | integer | Optional. The new page limit. Capped at your plan's maximum |
| max_depth | integer | Optional. The new depth. Capped at your plan's maximum |
| max_data_mb | number | Optional. A higher data limit. A crawl stopped by its data limit needs one to go on |
The new values can only raise the limits: a lower one answers 422 with {"error": "continue_cannot_lower"}. The new time budget follows the new max_pages, less the time the crawl has already used.
It answers 202 with {"success": true, "crawl_id": "…", "status": "queued"}. The crawl goes back to queued and continues from where it stopped; pages already fetched are not fetched again. Pages an earlier part asked for and did not get (fetch_status: "unfetched") are asked for again, within max_depth, and each attempt uses data like any other fetch. A page the site said does not exist (HTTP 404 or 410), a page robots.txt stopped, and files and API endpoints are not asked for again. A page got on a later part becomes fetched; one refused again carries this part's fetch_error. Poll the status as before. It answers 409, with an error code and a message, when the crawl has not ended, is already being continued, or cannot be continued (for example a crawl stopped by its page limit with no larger max_pages, or whose place was not kept). A continued crawl uses a work slot and data like any other, and the same quota checks as a new crawl apply. From 0.7.0 the SDKs call it with webgrph.continue_crawl(crawl_id) (continueCrawl in TypeScript and Java, ContinueCrawl in Go) and wait again with webgrph.wait_for_crawl (waitForCrawl, WaitForCrawl).
A crawl-extract job is continued with POST …/webgrph/crawl-extract/{job_id}/continue and the same optional body (max_pages, max_depth, max_data_mb). It works when the job ended completed and its crawl stopped at its time budget, its page limit or its data limit (the job status's crawl.partial_reason). The job's crawl goes on from where it stopped (asking again for the pages it did not get, as above), then the pages not yet extracted are extracted; rows already written stay, and no page is extracted twice. It answers 202, and the job's status goes back to crawling: poll GET …/webgrph/crawl-extract/{job_id} as before (there is no new event stream).
The refusals, with the code in detail.error:
| Status | error | Meaning |
|--------|---------|---------|
| 422 | continue_cannot_lower | A value was lower than the job's current limit |
| 409 | continue_needs_more_pages | The crawl stopped at its page limit: send a larger max_pages |
| 409 | continue_needs_more_data | The crawl stopped at its data limit: send a larger max_data_mb |
| 409 | not_continuable | The job did not end completed, or its crawl did not stop at one of those limits |
| 409 | already_continuing | The job has not ended, or is already being continued |
The same codes apply to a crawl's own …/crawl/{crawl_id}/continue.
Page object
| Field | Type | Description |
|-------|------|-------------|
| id | string | Node ID |
| url | string | Page URL |
| parent_url | string or null | The page it was found on |
| children_urls | string list | URLs of child pages |
| depth | integer | Depth from root (0 = root) |
| category | string | Page category from the link classifier, for example content, listing, detail, navigation, static (an about, contact, privacy, terms or help page), downloadable (a file link, not fetched as a page) or blocked_robots (a link robots.txt stops, not fetched); a value outside the classifier's list is other, and a page stored with none is page |
| classification_confidence | number | Confidence of category |
| metadata | object | title, link_text, link_context, is_navigation, is_content, estimated_importance, is_api_node, api_endpoint, record_count, api_data, is_grouping (true for a grouping folder, listed only with include_grouping=true), fetch_status (fetched; unfetched: asked for and not obtained; not_requested: found, and the crawl stopped before asking), fetch_error (why a page is unfetched), resource_bytes and blocked_requests (the page's own, by category, every attempt's; absent when not reported) |
Examples
The SDKs' webgrph.crawl() starts the crawl, waits for it and returns its pages; start_crawl() returns the crawl_id at once for your own polling.
Python
import time
from kloakd import Kloakd
client = Kloakd(api_key="sk-live-...", organization_id="your-org-id")
crawl_id = client.webgrph.start_crawl("https://example.com", max_depth=3, max_pages=100)
while True:
status = client.webgrph.get_crawl_status(crawl_id)
print(status["status"], status["total_pages"])
if status["status"] in ("completed", "failed", "cancelled"):
break
time.sleep(3)
for page in client.webgrph.crawl_all_pages(crawl_id):
print(page.url, page.depth)
TypeScript
import { Kloakd } from 'kloakd-sdk';
const client = new Kloakd({
apiKey: 'sk-live-...',
organizationId: 'your-org-id',
});
const crawl = await client.webgrph.crawl('https://example.com', { maxDepth: 3, maxPages: 100 });
console.log(crawl.status, crawl.totalPages);
for (const page of crawl.pages) console.log(page.url, page.depth);
Go
crawl, _ := client.Webgrph.Crawl(ctx, "https://example.com",
&kloakd.CrawlOptions{
MaxDepth: 3,
MaxPages: 100,
})
fmt.Printf("Crawl %s: %d pages\n", crawl.CrawlID, crawl.TotalPages)
status, _ := client.Webgrph.GetCrawlStatus(ctx, crawl.CrawlID)
fmt.Println(status["status"])
cURL
curl -X POST https://api.kloakd.dev/api/v1/organizations/$ORG_ID/webgrph/crawl \
-H "Authorization: Bearer sk-live-..." \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "max_depth": 3, "max_pages": 100}'
Artifact chaining
Chain webgrph.crawl() with kolektr.page() to get structured data from every page:
crawl = client.webgrph.crawl("https://example.com", max_depth=2)
for page in crawl.pages:
data = client.kolektr.page(
page.url,
schema={"title": "h1", "content": "article"},
)
print(f"{page.url}: {len(data.records)} records")
Errors
| Status | Error | When |
|--------|-------|------|
| 401 | AuthenticationError | Missing or invalid API key |
| 400 | ApiError | URL_NOT_ALLOWED on start: the start page is not a public web address (a loopback, private or link-local address, a cloud metadata host, or a name that resolves to one). Nothing is recorded, queued or fetched. The same for a crawl-extract job |
| 402 | PaymentRequiredError | The plan's last payment failed |
| 403 | NotEntitledError / ForbiddenError | Not in the plan (NotEntitledError), or another organisation's ID (ForbiddenError) |
| 404 | ApiError | Crawl not found, or (for …/pages) its pages have expired |
| 422 | ApiError | The request failed validation; for …/pages, a limit outside 1–1000 or a cursor that is not one the API returned |
| 409 | ApiError | ROBOTS_DISALLOWED on start: the site's robots.txt stopped the start page; nothing was crawled. Acknowledge it with robots_acknowledged_hosts (robots.txt) |
| 409 | ConcurrencyLimitError / ApiError | concurrent_limit on start (ConcurrencyLimitError): all of your plan's work slots stayed in use for 10 seconds, by crawls or other calls (Rate limits); on cancel: already cancelled or not found; on continue: not a crawl that can be continued |
| 422 | ApiError | The request body failed validation (for example max_depth: 0) |
| 429 | QuotaExceededError / RateLimitError | GB allocation used up, a request-rate limit where one applies, or queue_full (too many of your requests are already waiting for a slot; Retry-After: 30) |
| 502 | UpstreamError | The crawl could not be started |
| 503 | BillingUnavailableError | Usage could not be checked; retry after Retry-After |
| 503 | ApiError | ROBOTS_CHECK_UNAVAILABLE on start: KLOAKD could not check the site's robots.txt (reason: exits_refused: every exit refused to connect). Not a stop and nothing to acknowledge; retry later |
A crawl that runs but cannot fetch the site ends with status: "failed", the reason in error and error_code: "root_unfetched" or "crawl_failed"; it is not an HTTP error. A crawl that runs out of data mid-way is held (held_quota), not failed. If the start page's address cannot be looked up within 5 seconds, the crawl is accepted and its worker checks the address again before it fetches anything; a crawl refused there ends failed with an error that starts URL not allowed.
SSE streaming
GET /api/v1/organizations/{org_id}/webgrph/crawl/{crawl_id}/events streams the crawl as Server-Sent Events. Each event has an id: (its sequence), an event: name and a JSON data::
| Event | When |
|-------|------|
| pipeline_step | Progress: a stage started, moved on or finished |
| pipeline_error | A stage failed; error carries the details |
| pipeline_complete | The crawl ended; the stream closes |
The data object has pipeline_id (the crawl_id), event_type, stage_id, status (pending, in_progress, completed, failed, skipped), phase, message, sub_status, progress_pct, duration_ms, metadata, error, timestamp and sequence. On pipeline_error, error has error_code, category, severity, technical_message, user_message and recovery_actions. For a crawl that has already ended, the stream sends a single pipeline_complete and closes. Lines starting with : are keep-alives.
To resume after a dropped connection, reconnect with the last sequence you received, as ?last_sequence=N or a Last-Event-ID: N header (browsers' EventSource sends it for you); events up to N are skipped.
The SDKs' webgrph.crawl_stream() / crawlStream() start a crawl and yield its events (the event name is type in Python, eventType in TypeScript); crawl_events(crawl_id, last_sequence=N) / crawlEvents(crawlId, N) reattach to one already running:
for event in client.webgrph.crawl_stream("https://example.com", max_depth=2):
print(f" [{event.type}] {event.sub_status or ''}")
Learn more
- Quickstart —
client.crawl()in 30 seconds - Webgrph module — status, pages, SSE streaming
- Batch extraction guide — crawl then extract pattern
- Pagination guide — handling large crawls
