Metadata-Version: 2.4
Name: coreclaw-client
Version: 1.0.1
Summary: CoreClaw Python SDK client.
Author: CoreClaw maintainers
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24

# CoreClaw Python SDK

CoreClaw Python SDK for running scraper scripts and reading run results.

## Install

```bash
pip install coreclaw-client
```

## Run a Scraper

```python
from coreclaw import CoreClawClient

client = CoreClawClient(api_key="YOUR_API_KEY")

run = client.scraper("SCRAPER_SLUG").run(
    input={
        "parameters": {
            "system": {
                "proxy_region": "US",
                "cpus": 0.125,
                "memory": 512,
                "execute_limit_time_seconds": 1800,
                "max_total_charge": 0,
                "max_total_traffic": 0,
            },
            "custom": {
                "keyword": "python",
            },
        }
    },
)

print(run["run_slug"])
client.close()
```

To run a specific version:

```python
run = client.scraper("SCRAPER_SLUG").run(
    input={...},
    version="v1.0.1",
)
```

If `version` is not provided, CoreClaw uses the latest available version.

## Get Run Results

```python
from coreclaw import CoreClawClient

client = CoreClawClient(api_key="YOUR_API_KEY")

results = client.run("RUN_SLUG").list_results(limit=10, offset=0)

print(results["count"])
for item in results["list"]:
    print(item)

client.close()
```

## Async Usage

Run a scraper:

```python
from coreclaw import CoreClawAsyncClient

client = CoreClawAsyncClient(api_key="YOUR_API_KEY")
run = await client.scraper("SCRAPER_SLUG").run(input={...})
await client.close()
```

Get run results:

```python
from coreclaw import CoreClawAsyncClient

client = CoreClawAsyncClient(api_key="YOUR_API_KEY")
results = await client.run("RUN_SLUG").list_results(limit=10, offset=0)
await client.close()
```

## More

- Chinese README: [README.zh-CN.md](README.zh-CN.md)
- Run scraper demo: [examples/run_scraper.py](examples/run_scraper.py)
- Get results demo: [examples/get_results.py](examples/get_results.py)
- Async run scraper demo: [examples/async_run_scraper.py](examples/async_run_scraper.py)
- Async get results demo: [examples/async_get_results.py](examples/async_get_results.py)
