Metadata-Version: 2.4
Name: renderkit-sdk
Version: 1.0.0
Summary: Official Python SDK for RenderKit — screenshots, PDFs, and LLM-ready markdown from one API.
License: ISC
Project-URL: Homepage, https://renderkit.tech
Project-URL: Documentation, https://renderkit.tech/docs
Keywords: renderkit,screenshot,pdf,markdown,html-to-pdf,url-to-markdown,scraping,api
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# renderkit (Python)

Official Python SDK for [RenderKit](https://renderkit.tech) — screenshots, PDFs,
and LLM-ready markdown from one API. Standard library only, Python 3.9+.

```bash
pip install renderkit
```

```python
import os
from renderkit import RenderKit

rk = RenderKit(os.environ["RK_KEY"])  # or set RENDERKIT_API_KEY

# Screenshot → hosted PNG
shot = rk.screenshot(url="https://stripe.com", full_page=True, block_ads=True)
print(shot["url"])

# PDF → hosted PDF
pdf = rk.pdf(url="https://example.com", page_format="A4")

# Extract → markdown inline
doc = rk.extract(url="https://paulgraham.com/greatwork.html", format="markdown", chunk=True)
print(doc["content"])
```

## Auth

Pass your key to `RenderKit(key)` or set `RENDERKIT_API_KEY`. Keys look like
`rk_live_…` / `rk_sandbox_…` and are sent as the `x-api-key` header.

## Methods

| Method | Endpoint | Returns |
|---|---|---|
| `rk.screenshot(**opts)` | `POST /v1/screenshot` | render dict with hosted `url` |
| `rk.pdf(**opts)` | `POST /v1/pdf` | render dict with hosted `url` |
| `rk.extract(**opts)` | `POST /v1/extract` | render dict with inline `content` |
| `rk.get_job(id)` | `GET /v1/jobs/:id` | render dict |
| `rk.render(type, **opts)` | submits `async` + polls to completion | finished render dict |

Options mirror the [API reference](https://renderkit.tech/docs). Methods return
the `data` object as a plain `dict`.

## Save a screenshot

```python
import urllib.request
shot = rk.screenshot(url="https://stripe.com", full_page=True)
urllib.request.urlretrieve(shot["url"], "stripe.png")
```

## Errors

Failures raise `RenderKitError` with `.code`, `.status`, and `.request_id`:

```python
from renderkit import RenderKitError
try:
    rk.screenshot(url="https://x.com")
except RenderKitError as e:
    if e.code == "QUOTA_EXCEEDED":
        ...  # top up
    print(e.status, e.code, e.request_id)
```

## Config

```python
RenderKit(key, base_url="https://api.renderkit.tech", timeout=120.0)
```
