Skip to main content

API reference

fetch()

Fetch a single URL with anti-bot bypass

13 min read


Crawling a whole site? Use client.crawl() instead — it handles discovery, fetching, and optional extraction in one call. Use fetch() when you only need a single page.

Endpoint

POST /api/v1/organizations/{org_id}/evadr/fetch

Description

Fetch a single URL with automatic anti-bot bypass. The engine works out, per site, how to get the page: plain HTTP where that is enough, a browser, a residential exit or a challenge solver where the site needs them, trying another approach when one is refused. Returns HTML and an artifact for chaining with extract().

Request body

| Field | Type | Required | Default | Description | |-------|------|----------|---------|-------------| | url | string | Yes | — | Target URL | | force_browser | boolean | No | false | Skip HTTP, go straight to Chrome | | use_proxy | boolean | No | false | Accepted, with no effect on the fetch | | session_artifact_id | string | No | null | A login session (synchronous fetch only; see below). The fetch then runs under the session's protections | | include_resources | array of strings | No | [] | The page's extras to load when a browser fetches it: any of images, media, fonts, stylesheets, tracking. Left out or empty: none are loaded, to save data. Also on …/evadr/fetch/async. See extras | | robots_acknowledged_hosts | array of strings | No | null | Hosts whose robots.txt stop you acknowledge, for this request only: the host of the 409 that stopped it. Recorded. Also on …/evadr/fetch/async. See When robots.txt stops a request |

Response

{
  "success": true,
  "url": "https://example.com",
  "status_code": 200,
  "tier_used": 3,
  "html": "<html>...</html>",
  "vendor_detected": null,
  "anti_bot_bypassed": false,
  "artifact": { "artifact_id": "art-abc123", "type": "FETCHED_CONTENT" },
  "error": null,
  "auth_required": false,
  "discovery_id": null,
  "login_options": null,
  "session": null,
  "page_category": "content",
  "unverified_html": null,
  "shell_links": null,
  "related_page": null
}

Response fields

| Field | Type | Description | |-------|------|-------------| | success | boolean | Whether the page was fetched. Check it: a failed fetch is still HTTP 200 (below) | | url | string | The URL you asked for | | status_code | integer | HTTP status of the page; 0 when no page was fetched | | tier_used | integer | Rough indication of how the page was fetched: 1 plain HTTP, 2 TLS client, 3 headless browser, 4 headed browser, 5 through a proxy, 0 unknown. A failed fetch reports 1 | | html | string or null | Page HTML; empty when the fetch failed. A page that asks for a login is still returned (auth_required is a hint, not a refusal) | | vendor_detected | string or null | Anti-bot vendor (e.g. "cloudflare") | | anti_bot_bypassed | boolean | Whether anti-bot was bypassed | | artifact | object or null | Reusable artifact (artifact_id, type); the SDKs expose it as artifact_id | | error | string or null | Error message if failed | | auth_required | boolean | The page asks for a login: a login form, or a page that says its content needs one. html still holds the page; see login_options | | discovery_id | string or null | An interactive login already started for the page. Set only when the page showed a login form and you sent no session_artifact_id; poll it as an auth-chain discovery | | login_options | object or null | When auth_required is true: how to log in with your own account (below) | | session | object or null | When you sent session_artifact_id and the session was paused or refused its turn: pause_reason (logged_out, rate_limited, challenged) or refused (hourly_cap, busy), with a message (Fetchyr) | | page_category | string or null | content (a verified page), application_shell (a near-empty page whose scripts did not draw its content; returned unverified), or null | | unverified_html | string or null | For an application shell: the page as served, not verified as content | | shell_links | string list or null | For an application shell: pages on the same site it links to | | related_page | object or null | For an application shell: the linked page KLOAKD tried next (url, verified, status_code, bytes) |

When the page asks for a login

auth_required: true means the page showed a login form or said its content needs a login. The fetch still returns the page in html, and login_options says how to log in with your own account:

{
  "reason": "login_page",
  "message": "This page needs a login. You can log in with your own account; …",
  "options": [
    {
      "method": "interactive",
      "start": "POST /api/v1/organizations/{org_id}/fetchyr/login-sessions",
      "body": { "target_url": "https://example.com/account", "method": "interactive" },
      "description": "…",
      "discovery_id": "…",
      "status_url": "GET /api/v1/organizations/{org_id}/fetchyr/auth-chain/{discovery_id}/status",
      "credentials_url": "POST /api/v1/organizations/{org_id}/fetchyr/auth-chain/{discovery_id}/resume-credentials",
      "mfa_url": "POST /api/v1/organizations/{org_id}/fetchyr/auth-chain/{discovery_id}/resume-mfa"
    },
    {
      "method": "cookies",
      "start": "POST /api/v1/organizations/{org_id}/fetchyr/login-sessions",
      "body": { "target_url": "https://example.com/account", "method": "cookies", "cookies": "[your browser's cookies for the site]", "user_agent": "[your browser's navigator.userAgent]" },
      "description": "…"
    }
  ],
  "then": "Pass the session_artifact_id you get to /evadr/fetch, /webgrph/crawl or /kolektr/extract."
}

The interactive option carries discovery_id and its three URLs only when a login was already started for the page (the discovery_id of the response). reason is logged_out when the session you sent was signed out by the site. Either way, log in with your own account and fetch again with the session_artifact_id you get.

When a fetch fails

A fetch that reaches the engine but cannot get the page is not an HTTP error. The API answers 200 with success: false, the reason in error, status_code: 0 and an empty html:

{
  "success": false,
  "url": "https://example.com",
  "status_code": 0,
  "tier_used": 1,
  "html": "",
  "artifact": null,
  "error": "…",
  "auth_required": false,
  "discovery_id": null
}

(The fields added for logins and application shells are null here.) So check success on every result. HTTP error codes mean something else: 422 is a request body that failed validation, and 502 means the request could not be run or handed to a job (Errors).

When robots.txt stops a request

KLOAKD reads a site's robots.txt before it asks for a page, on every route that fetches a site: fetch, scan, extract, crawl, crawl and extract, the site map and the others. When the file does not allow the page, or cannot be read (the site answers it with a 5xx, a timeout or a failed connection), the request stops and nothing is fetched. A missing file (404 or another 4xx) allows everything. A page that redirects is judged again where it ended.

The stop is a 409 with the code ROBOTS_DISALLOWED:

{
  "detail": {
    "error": "ROBOTS_DISALLOWED",
    "code": "ROBOTS_DISALLOWED",
    "reason": "disallowed",
    "host": "www.example.com",
    "url": "https://www.example.com/private/page",
    "rule": "Disallow: /private",
    "message": "The robots.txt of www.example.com does not allow this page (rule: Disallow: /private).",
    "acknowledge_field": "robots_acknowledged_hosts",
    "terms_version": "draft-2026-11-19"
  }
}

reason is disallowed (the file forbids the page; rule is the line that decided) or unreadable (the file could not be read; rule is null). A stop after a redirect also has redirected_from.

Acknowledging a stop

To go on, send the same request again with the stopped host in robots_acknowledged_hosts:

curl -X POST https://api.kloakd.dev/api/v1/organizations/$ORG_ID/evadr/fetch \
  -H "Authorization: Bearer sk-live-..." \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.example.com/private/page", "robots_acknowledged_hosts": ["www.example.com"]}'
  • What it means. By naming a host you confirm you have the right to access its content despite its robots.txt, and accept responsibility for doing so under the Terms.
  • Per request. It counts for that request alone and for exactly the hosts it names. Nothing is remembered: the next request to the host stops again unless it names the host too.
  • Recorded. Each acknowledgement that is used is recorded before the page is fetched: who, the organisation, the host, when, the reason shown and the terms version. If the record cannot be written, nothing is fetched and the API answers 503 with robots_acknowledgement_not_recorded.
  • Bare hosts. Each entry is a host name as the 409 gave it (www.example.com, with a port when the address has one), not a URL, a path or a wildcard; at most 50. Anything else is a 422.

The SDKs (0.7.0) have no parameter for robots_acknowledged_hosts yet; send the request over HTTP as above.

When KLOAKD could not check robots.txt

A 503 with the code ROBOTS_CHECK_UNAVAILABLE is not a stop: KLOAKD could not ask the site for its robots.txt, so nothing is known about it yet. There is nothing to acknowledge, and robots_acknowledged_hosts does not change it. Nothing was fetched. Retry later; the answer has Retry-After: 30.

{
  "detail": {
    "reason": "exits_refused",
    "error": "ROBOTS_CHECK_UNAVAILABLE",
    "code": "ROBOTS_CHECK_UNAVAILABLE",
    "host": "www.example.com",
    "message": "KLOAKD could not check the robots.txt of www.example.com: every exit KLOAKD may use refused to open a connection to the site, so the site was never asked. This is not the site's answer, and there is nothing for you to acknowledge. Nothing was fetched. Please try again later.",
    "retry_after_s": 30
  }
}

reason: "exits_refused" means every exit KLOAKD may use refused to connect to the site, so the site was never asked; a site that is down or whose name does not resolve can answer this way too. Without a reason, a temporary capacity problem on KLOAKD's side stopped the check.

Long fetches: 202 and a job to poll

A synchronous fetch answers within about 85 seconds. Most pages finish well inside that. Some heavily protected sites take longer: the engine tries several approaches in turn, and each costs time. When a fetch is still running at the limit, you get 202 Accepted instead of the page. The fetch carries on as a job, and you collect the result by polling:

{
  "job_id": "5f0c7f9e-0d6b-4d0e-9a52-6a1d3c1e2b47",
  "status": "running",
  "reason": "sync_limit_reached",
  "waited_seconds": 85,
  "poll_url": "/api/v1/organizations/{org_id}/evadr/jobs/5f0c7f9e-0d6b-4d0e-9a52-6a1d3c1e2b47",
  "message": "The fetch is still running and continues as a job. Poll poll_url, or stream poll_url + '/events', for the result."
}
  • Poll GET poll_url every few seconds until status is completed or failed. The completed job's result has the same fields as a synchronous response.
  • Or stream progress from GET poll_url + "/events" (Server-Sent Events).
  • The SDKs follow the hand-off for you. If they give up waiting (JobTimeoutError, which carries job_id), resume with client.wait_for_handoff(job_id) / client.waitForHandoff(jobId); get_handoff / getHandoff reads the state once. Both use GET /api/v1/organizations/{org_id}/handoff/{job_id}, which the other routes' 202 answers point to.
  • Results are kept for one hour; after that the poll answers 404.
  • A job whose fetch did not get the page still ends completed: look at result.success. failed means the job itself broke (error says why).
  • reason is site_last_exceeded_sync_limit when your last fetch of the same site ran past the limit. Then the job is returned at once, so you don't wait first.
  • A fetch made while all of your plan's work slots are in use is queued, not refused: it waits for a slot inside the same 85 seconds and, if it is still waiting then, answers this 202. Its job stays pending until a slot frees, and ends failed if none frees within 15 minutes.

Always handle 202. Treat it as "not finished yet", never as a failure. If you already know a site is slow, call POST …/evadr/fetch/async directly: it returns the job straight away. The async route does not use session_artifact_id, so fetch authenticated pages with the synchronous fetch().

The limit exists because the API sits behind Cloudflare, which closes any request that has had no response for 100 seconds. Without the hand-off, your client would get a 524 error while the fetch went on running. Usage is counted for the work done either way, so collect the job's result rather than retrying the synchronous call.

Examples

Python

from kloakd import Kloakd

client = Kloakd(api_key="sk-live-...", organization_id="your-org-id")

result = client.evadr.fetch("https://example.com")
if result.success:
    print(f"Status: {result.status_code}")
    print(f"HTML length: {len(result.html or '')}")
    print(f"Artifact ID: {result.artifact_id}")
else:
    print(f"Fetch failed: {result.error}")

TypeScript

import { Kloakd } from 'kloakd-sdk';

const client = new Kloakd({
  apiKey: 'sk-live-...',
  organizationId: 'your-org-id',
});

const result = await client.evadr.fetch('https://example.com');
if (result.success) {
  console.log(`Status: ${result.statusCode}`);
  console.log(`Artifact ID: ${result.artifactId}`);
} else {
  console.log(`Fetch failed: ${result.error}`);
}

Go

result, err := client.Evadr.Fetch(ctx, "https://example.com", nil)
if err != nil {
    log.Fatal(err)
}
if !result.Success {
    fmt.Printf("Fetch failed: %v\n", *result.Error)
} else {
    fmt.Printf("Status: %d\n", result.StatusCode)
    if result.ArtifactID != nil {
        fmt.Printf("Artifact ID: %s\n", *result.ArtifactID)
    }
}

cURL

curl -X POST https://api.kloakd.dev/api/v1/organizations/$ORG_ID/evadr/fetch \
  -H "Authorization: Bearer sk-live-..." \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com"}'

Artifact chaining

The returned artifact_id can be passed to extract() to skip re-fetching:

page = client.evadr.fetch("https://example.com")

# Extract structured data — reuses the fetched HTML
data = client.kolektr.page(
    "https://example.com",
    schema={"title": "h1"},
    fetch_artifact_id=page.artifact_id,
)

Force browser mode

Start with a browser rather than plain HTTP:

result = client.evadr.fetch("https://example.com", force_browser=True)

Authenticated fetch

Pass a session from Fetchyr to access pages behind login (the synchronous fetch only: fetch/async does not use the session):

client.fetchyr.store_credentials("acme", username="user@example.com", password="pass")
session = client.fetchyr.authenticate("acme", target_url="https://example.com/login")

result = client.evadr.fetch(
    "https://example.com/dashboard",
    session_artifact_id=session.artifact_id,
)

Errors

| Status | Error | When | |--------|-------|------| | 200 with success: false | — (not an HTTP error) | The page could not be fetched: see error (above) | | 202 | — (not an error) | Still running at the limit: poll the job (above) | | 401 | AuthenticationError | Missing or invalid API key | | 402 | PaymentRequiredError | The plan's last payment failed | | 403 | NotEntitledError / ForbiddenError | Not in the plan (NotEntitledError), or another organisation's ID (ForbiddenError) | | 409 | ApiError | ROBOTS_DISALLOWED: the site's robots.txt stopped the request; nothing was fetched. Acknowledge it with robots_acknowledged_hosts (above) | | 422 | ApiError | The request body failed validation (a missing or mistyped field) | | 429 | QuotaExceededError / RateLimitError | GB allocation used up (gb_exhausted), a request-rate limit where one applies, or queue_full: all of your work slots are in use and too many requests are already waiting (Retry-After: 30; Rate limits). A fetch over the limit is otherwise queued, not refused. A fetch that uses up the allowance while it runs is also answered 429 gb_exhausted | | 502 | UpstreamError | The request could not be run or handed to a job. detail is the fixed text Fetch failed: the cause is logged on our side, not sent | | 503 | BillingUnavailableError | Usage could not be checked; retry after Retry-After | | 503 | ApiError | ROBOTS_CHECK_UNAVAILABLE: 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 (above) |

Learn more

Was this page helpful?