Metadata-Version: 2.4
Name: inksong
Version: 0.1.0
Summary: Official Inksong SDK for Python.
Author-email: Inksong <hello@inksong.app>
License: MIT
Project-URL: Homepage, https://inksong.app/docs/sdks
Project-URL: Repository, https://github.com/inksong-app/inksong
Project-URL: Issues, https://github.com/inksong-app/inksong/issues
Keywords: inksong,ai,humanizer,sdk
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"

# inksong (Python SDK)

Official Inksong SDK for Python. Talks to the Inksong REST API at `api.inksong.app`.

> **Status:** Source ships with each Inksong release. The first PyPI publish is a maintainer task — until then, install from the repo (`pip install <path/to/sdks/inksong-python>`).

## Install

```bash
# Once published to PyPI:
pip install inksong

# Today, from the repo:
pip install ./sdks/inksong-python
```

Requires Python 3.10+.

## Usage

```python
from inksong import InksongClient

with InksongClient(api_key="ink_...") as client:
    out = client.humanize_text(
        "Your AI-generated draft here",
        tone="balanced",
        humanness_level=50,
    )
    print(out["humanized_text"])

    for doc in client.list_documents(limit=10):
        print(doc["job_id"], doc["status"])
```

`InksongClient` is a context manager — `__exit__` closes the underlying `httpx.Client`. You can also call `client.close()` explicitly.

## Webhook signature verification

If you subscribe to webhooks at `/dashboard/webhooks`, every delivery is signed with HMAC-SHA256. Verify with:

```python
from inksong import verify_signature

raw_body = request.body  # bytes or str — both work
header = request.headers["Webhook-Signature"]

if not verify_signature(WEBHOOK_SECRET, raw_body, header):
    return Response(status_code=400)
```

`verify_signature` rejects timestamps older than 5 minutes by default; pass `max_age_seconds` to change that.

## Errors

The client raises `InksongError` on non-2xx responses. `err.status_code` is the HTTP status; `err.body` is the response text.

```python
from inksong import InksongError

try:
    client.humanize_text("...")
except InksongError as err:
    if err.status_code == 429:
        # back off
        ...
    raise
```

## Publish (maintainer)

```bash
# 1. Bump version in pyproject.toml
# 2. Build
python -m pip install build twine
python -m build
# 3. Verify
twine check dist/*
# 4. Upload
twine upload dist/*
```

## License

MIT
