Metadata-Version: 2.5
Name: sfwapi
Version: 0.1.0
Summary: Official Python client for the SFW API: nudity detection and image moderation with four content levels
Project-URL: Homepage, https://sfwapi.dev
Project-URL: Documentation, https://sfwapi.dev/docs/sdks/python
License-Expression: MIT
Keywords: content moderation,image moderation,nsfw,nsfw detection,nudity detection,sfwapi
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Graphics
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Provides-Extra: test
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# sfwapi

Official Python client for the [SFW API](https://sfwapi.dev): nudity detection and image moderation for
images, GIFs and videos. Every result carries one of four content levels (0 Everyday, 1 Revealing,
2 Implied nudity, 3 Explicit), a score per level, and flags for drawn content and adult objects. Media is
processed in memory and never stored.

```bash
pip install sfwapi
```

Get a free API key at [sfwapi.dev/console](https://sfwapi.dev/console).

```python
from sfwapi import SfwApi

api = SfwApi(api_key="sk_live_...")
r = api.analyze_url("https://example.com/photo.jpg", policy={"block_level": 2, "block_sex_objects": True})
print(r["nudity"]["level"], r["nudity"]["scores"], r["policy"]["blocked"], r["usage"]["balance"])

with open("clip.gif", "rb") as f:
    g = api.analyze_bytes(f.read(), max_frames=5, include_frames=True)
```

`AsyncSfwApi` offers the same methods with `await`. Errors raise `SfwApiError` with `.status`, `.code`,
`.message`, `.request_id`; 429/503/504 are retried twice honouring `Retry-After` (not for uploads).
A request costs 1 credit per image, or 1 per analysed frame for a GIF or video; failed requests are free.

Full reference: [sfwapi.dev/docs/sdks/python](https://sfwapi.dev/docs/sdks/python).
