Metadata-Version: 2.5
Name: webpninja
Version: 1.0.0
Summary: Official Python client for the WebP Ninja image compression API
Project-URL: Homepage, https://webpninja.com
Project-URL: Documentation, https://webpninja.com/docs
Project-URL: Repository, https://github.com/yantrixlab/WebPNinja
Author: WebP Ninja
License-Expression: MIT
License-File: LICENSE
Keywords: avif,image-compression,jpeg,png,webp
Requires-Python: >=3.8
Requires-Dist: requests>=2.25
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Requires-Dist: responses>=0.23; extra == 'test'
Description-Content-Type: text/markdown

# webpninja

Official Python client for the [WebP Ninja](https://webpninja.com) Developer API — server-side
image compression for WebP, JPEG, PNG, and AVIF.

## Install

```bash
pip install webpninja
```

Requires Python 3.8 or later.

## Usage

```python
from webpninja import WebPNinja

client = WebPNinja("webpninja_live_your_key")
# or: client = WebPNinja()  # reads WEBPNINJA_API_KEY from the environment

client.compress_to_file("photo.png", "photo.webp", format="webp", quality=75)
```

Or get the compressed bytes directly:

```python
data = client.compress("photo.png", format="webp", quality=75)
```

`input` can be a file path or raw bytes.

## Error handling

```python
from webpninja import WebPNinja, RateLimitError, AuthenticationError

try:
    client.compress("photo.png", format="webp")
except RateLimitError as err:
    print(f"Quota: {err.used}/{err.quota}")
except AuthenticationError:
    print("Check your API key.")
```

All errors extend `WebPNinjaError` and carry `.status` (the HTTP status code) and `.message`.
See [webpninja.com/docs](https://webpninja.com/docs) for the full error reference.

## License

MIT
