bytekit-sdk
Official Python SDK for the ByteKit API.
The PyPI distribution is bytekit-sdk; the import name is bytekit.
Generated from the OpenAPI spec using openapi-python-client, filtered to the stable v0.1 operations.
Installation
pip install bytekit-sdk
The installed version is available as bytekit.__version__.
Quick start
from bytekit import AuthenticatedClient
from bytekit.api.scrape import create_scrape
from bytekit.models.scrape_request import ScrapeRequest
from bytekit.models.scrape_success_envelope import ScrapeSuccessEnvelope
# base_url defaults to https://api.bytekit.com, so only the token is required.
client = AuthenticatedClient(token="sk_live_your_api_key_here")
result = create_scrape.sync(client=client, body=ScrapeRequest(url="https://example.com"))
if isinstance(result, ScrapeSuccessEnvelope):
# formats.markdown is str | Unset — only set when "markdown" was among the
# requested formats.
print(result.formats.markdown)
See Error handling for what result can be when the request fails.
Error handling
The SDK has a two-tier error contract. Both tiers are safe: an operation never raises
a bare json.JSONDecodeError, even when a server returns an HTML error page.
| Situation | What you get |
|---|---|
A status the OpenAPI spec documents for that operation (e.g. a 422 or 500 on create_scrape), with a JSON body |
The typed Error model is returned, not raised. Check with isinstance(result, Error) and read result.error.code / result.error.message. |
| An undocumented status, or a non-JSON body on a documented status (HTML error page, load-balancer text, empty body) | errors.UnexpectedStatus is raised, carrying .status_code and the raw .content. When the body is the documented Error envelope, .code / .message are populated too. |
Either of the above, with raise_on_unexpected_status=False |
Nothing is raised; the operation returns None. |
from bytekit import AuthenticatedClient
from bytekit.api.scrape import create_scrape
from bytekit.errors import UnexpectedStatus
from bytekit.models.error import Error
from bytekit.models.scrape_request import ScrapeRequest
from bytekit.models.scrape_success_envelope import ScrapeSuccessEnvelope
client = AuthenticatedClient(token="sk_live_your_api_key_here")
try:
result = create_scrape.sync(client=client, body=ScrapeRequest(url="https://example.com"))
except UnexpectedStatus as err:
# Undocumented status, or a non-JSON body on a documented one. Never a JSONDecodeError.
print(f"request failed with status {err.status_code}: {err.code} {err.message}")
else:
if isinstance(result, Error):
# Documented 4xx/5xx with a JSON body: RETURNED as a typed model, not raised.
print(f"api error {result.error.code}: {result.error.message}")
elif isinstance(result, ScrapeSuccessEnvelope):
print(result.formats.markdown)
else:
# 202 ScrapeQueuedEnvelope — poll get_scrape with this id until it completes.
print(f"queued as {result.id}")
Defaults
The client ships with production-ready defaults so AuthenticatedClient(token=...) works out of the box:
| Setting | Default | Notes |
|---|---|---|
base_url |
https://api.bytekit.com |
Pass base_url= to target staging or a proxy. |
timeout |
120s (httpx.Timeout(120.0)) |
Finite by default — requests no longer hang indefinitely. Pass timeout= to override. |
raise_on_unexpected_status |
True |
Undocumented statuses raise errors.UnexpectedStatus instead of silently returning None. Pass raise_on_unexpected_status=False to restore the old opt-out. |
Explicit constructor arguments always win over these defaults (explicit arg > default).
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(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())
Available operations
| Module | Method | Description |
|---|---|---|
api.scrape |
create_scrape, get_scrape |
Web content extraction |
api.screenshots |
create_screenshot, get_screenshot |
Page screenshots |
api.bulk |
create_bulk, get_bulk, delete_bulk, list_bulk_screenshots |
Bulk screenshot jobs |
api.scrape_bulk |
create_scrape_bulk, get_scrape_bulk |
Bulk scrape jobs |
api.fetch |
get_fetch, post_fetch |
Raw HTTP fetch |
api.fetch_bulk |
create_fetch_bulk, get_fetch_bulk |
Bulk fetch jobs |
api.monitors |
create_monitor, list_monitors, get_monitor, update_monitor, delete_monitor, list_monitor_captures |
Page-change monitors (screenshot + scrape) |
api.sitemap |
create_sitemap, get_sitemap |
Sitemap crawl |
api.search |
create_search (or the AuthenticatedClient.search(...) convenience method) |
Web search |
api.usage |
get_usage, get_usage_daily, get_usage_by_endpoint |
Account usage & billing |
api.webhooks |
list_webhook_deliveries, retry_webhook_delivery |
Webhook delivery log & retry |
api.account |
get_account |
Account details |
License
MIT — see LICENSE.
Release files for bytekit-sdk 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bytekit_sdk-0.3.2.tar.gz | 140.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bytekit_sdk-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 350.9 kB
Release files / bytekit_sdk-0.3.2.tar.gz
| Download URL | bytekit_sdk-0.3.2.tar.gz |
|---|---|
| Size | 140.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b240e37810d910e6f72f24ee05a010984b59b497cf7fa2dc34c2ac69f7d9eef
|
|
BLAKE2b-256 checksum How to use checksums |
a64637245f5a342f3ffb8d7c61fc92f0baa5eb127a925c2a642739b59ef5d237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / bytekit_sdk-0.3.2-py3-none-any.whl
| Download URL | bytekit_sdk-0.3.2-py3-none-any.whl |
|---|---|
| Size | 210.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0702db8d7b6c600cc737ba44b0def6f775c585dd01359033198ecb39eecdeaa
|
|
BLAKE2b-256 checksum How to use checksums |
a997a9f11588b02b2a7222762caa8e9dac6bc383b20bfbd3d8fcc6f009e6d6ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|