Client Libraries

Python SDK

Official Python client for ByteKit, with sync and async support.

The official Python SDK is generated from the ByteKit OpenAPI spec, so its models and methods always match the API. Every operation ships in both synchronous and asynchronous form.

Install

pip install bytekit

Your first scrape

from bytekit import AuthenticatedClient
from bytekit.api.scrape import create_scrape
from bytekit.models.scrape_request import ScrapeRequest
from bytekit.models.scrape_request_formats_item import ScrapeRequestFormatsItem
from bytekit.models.scrape_success_envelope import ScrapeSuccessEnvelope

client = AuthenticatedClient(
    base_url="https://api.bytekit.com",
    token="sk_live_your_api_key_here",
)

# Request the markdown format explicitly — otherwise response.formats.markdown is UNSET.
body = ScrapeRequest(
    url="https://example.com",
    formats=[ScrapeRequestFormatsItem.MARKDOWN],
)
response = create_scrape.sync(client=client, body=body)

# .sync() returns None on a transport error, and a queued/error envelope on the
# async or failure paths. Only a ScrapeSuccessEnvelope carries populated formats.
if response is None:
    print("Request failed — no response returned.")
elif isinstance(response, ScrapeSuccessEnvelope) and isinstance(response.formats.markdown, str):
    print(response.formats.markdown)
else:
    # Queued (ScrapeQueuedEnvelope) or error (ScrapeErrorEnvelope) — inspect `response`.
    print(f"Scrape not complete: {response}")

Each operation exposes four call styles:

  • create_scrape.sync(...) — returns the parsed model (or None).
  • create_scrape.sync_detailed(...) — returns the full Response (status code, headers, body).
  • create_scrape.asyncio(...) — awaitable form of sync.
  • create_scrape.asyncio_detailed(...) — awaitable form of sync_detailed.

Async usage

import asyncio
from bytekit import AuthenticatedClient
from bytekit.api.screenshots import create_screenshot
from bytekit.models.screenshot_request import ScreenshotRequest

async def main():
    client = AuthenticatedClient(
        base_url="https://api.bytekit.com",
        token="sk_live_your_api_key_here",
    )
    body = ScreenshotRequest(url="https://example.com")
    response = await create_screenshot.asyncio(client=client, body=body)
    print(response)

asyncio.run(main())

What's available

Operations are grouped by capability under bytekit.api.*: scrape, scrape_bulk, screenshots, recordings, bulk, fetch, fetch_bulk, monitors, sitemap, and account.

See the Python SDK Reference for every module, function, and model.

Next steps