Skip to content
smallPict

Officiële Python SDK

Moderne Python-bibliotheek met synchrone en asynchrone (asyncio) interfaces.

Geschikt voor Python 3.9+, inclusief synchrone methoden voor scripts en Django, plus asynchrone ondersteuning via asyncio voor FastAPI en aiohttp.


Installatie

Shell
pip install smallpict# of via poetrypoetry add smallpict

Compleet toepassingsvoorbeeld

Python
import osfrom smallpict import SmallPictClient
client = SmallPictClient(    api_key=os.environ.get("SMALLPICT_API_KEY"),    secret_key=os.environ.get("SMALLPICT_SECRET_KEY"))
# 1. Lokaal bestand optimaliserenwith open("banner.png", "rb") as f:    result = client.optimize(        file=f.read(),        filename="banner.png",        format="avif",        quality=80    )
print(f"CDN-URL: {result.url}")print(f"Besparingspercentage: {result.savings_percentage}%")
# 2. Quotum controlerenquota = client.get_quota()print(f"Pakket: {quota.plan} - Resterend: {quota.remaining}")