Skip to main content

The official Python SDK for the KLOAKD API

Project description

kloakd-sdk — Official Python SDK for KLOAKD

PyPI Python License: MIT

The KLOAKD SDK gives Python developers typed access to all 7 KLOAKD modules. Modules compose like Unix pipes — the artifact output of one becomes the input to the next, eliminating redundant fetches.

Installation

pip install kloakd-sdk

Requires Python 3.9+ and httpx>=0.27 (installed automatically).

Quickstart

from kloakd import Kloakd

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

# Step 1: Fetch with anti-bot bypass
fetch = client.evadr.fetch("https://books.toscrape.com")
print(f"Fetched via tier {fetch.tier_used}")

# Step 2: Crawl site hierarchy — reuse the Evadr artifact, no double-fetch
crawl = client.webgrph.crawl(
    "https://books.toscrape.com",
    max_depth=2,
    session_artifact_id=fetch.artifact_id,
)
print(f"Found {crawl.total_pages} pages")

# Step 3: Extract structured data — reuse the Evadr artifact again
data = client.kolektr.page(
    "https://books.toscrape.com",
    schema={"title": "css:h3 a", "price": "css:p.price_color"},
    fetch_artifact_id=fetch.artifact_id,
)
for book in data.records[:3]:
    print(book)

The 7 Modules

Namespace Module Purpose
client.evadr Evadr Anti-bot bypass (5-tier escalation)
client.webgrph Webgrph Site mapping & BFS crawl
client.skanyr Skanyr Two-phase API discovery
client.nexus Nexus 5-layer strategy engine
client.parlyr Parlyr Conversational NLP → extraction intent
client.fetchyr Fetchyr RPA, authentication, MFA, workflows
client.kolektr Kolektr Structured data extraction

Artifact Chaining

Artifacts are the composition primitive — the output of one module becomes the input to another:

evadr.fetch()    → artifact_id (FETCHED_CONTENT)
  └─→ kolektr.page(fetch_artifact_id=...)       # skip re-fetch
  └─→ webgrph.crawl(session_artifact_id=...)    # authenticated crawl

fetchyr.login()  → artifact_id (AUTHENTICATED_SESSION)
  └─→ evadr.fetch(session_artifact_id=...)      # authenticated fetch
  └─→ webgrph.crawl(session_artifact_id=...)

webgrph.crawl()  → artifact_id (SITE_HIERARCHY)
  └─→ skanyr.discover(site_hierarchy_artifact_id=...)   # skip Phase 1

skanyr.discover() → artifact_id (API_MAP)
  └─→ kolektr.page(api_map_artifact_id=...)     # API-backed extraction

Async Client

from kloakd import AsyncKloakd

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

async def main():
    fetch = await client.evadr.fetch("https://books.toscrape.com")
    data  = await client.kolektr.page("https://books.toscrape.com",
                                       fetch_artifact_id=fetch.artifact_id)

    # SSE stream
    async with client.webgrph.crawl_stream("https://books.toscrape.com") as events:
        async for event in events:
            print(event.type, event.url)

Error Handling

from kloakd.errors import KloakdError, RateLimitError, AuthenticationError
import time

try:
    result = client.evadr.fetch("https://example.com")
except RateLimitError as e:
    time.sleep(e.retry_after)
except AuthenticationError:
    # Rotate API key
    raise
except KloakdError as e:
    print(f"Error {e.status_code}: {e.message}")

Error types:

Class HTTP Cause
AuthenticationError 401 Invalid or expired API key
NotEntitledError 403 Plan doesn't include this module
RateLimitError 429 Quota exceeded (has retry_after seconds)
UpstreamError 502 Target site unreachable
ApiError 4xx/5xx Any other API error

Pagination

# Manual pagination
result = client.skanyr.discover("https://api.example.com", limit=100, offset=0)
print(result.has_more, result.total)

# Auto-paginate (recommended)
all_endpoints = client.skanyr.discover_all("https://api.example.com")
all_records   = client.kolektr.page_all("https://example.com")
all_pages     = client.webgrph.crawl_all("https://example.com")

Fetchyr — RPA & Authentication

# Login and produce a reusable session
session = client.fetchyr.login(
    url="https://app.example.com/login",
    username_selector="#email",
    password_selector="#password",
    username="user@example.com",
    password="secret",
)

# Detect and handle MFA
mfa = client.fetchyr.detect_mfa("https://app.example.com/mfa",
                                  session_artifact_id=session.artifact_id)
if mfa.mfa_detected:
    result = client.fetchyr.submit_mfa(mfa.challenge_id, code="123456")

# Detect forms, run workflows, deduplicate records
forms  = client.fetchyr.detect_forms("https://example.com/signup")
dedup  = client.fetchyr.check_duplicates(records, domain="example.com")

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kloakd_sdk-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kloakd_sdk-0.1.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file kloakd_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: kloakd_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kloakd_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34ba749f741eebcd5964a5877db85f7aa3be7be83c4765279f53ac95b90fad46
MD5 dc044105bbeb81e937e06ff2444590e3
BLAKE2b-256 19646c62ceab162e35c6885961bdd824072e52c6a12db66d830965bbf19e8c56

See more details on using hashes here.

Provenance

The following attestation bundles were made for kloakd_sdk-0.1.0.tar.gz:

Publisher: publish.yml on kloakd-dev/kloakd-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kloakd_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kloakd_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kloakd_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dadbf88edbe2a51d11d0d73c4cd66def0115f933bf0af401c507b111baebf18
MD5 053384c1668f06cf08bf91d35ec40df7
BLAKE2b-256 d5f87c043e7b525e783da45f097080fb30cb7a933db3aed2d10c7de1ae16551e

See more details on using hashes here.

Provenance

The following attestation bundles were made for kloakd_sdk-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kloakd-dev/kloakd-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page