Skip to content
smallPict

Resmi Python SDK

Senkron ve asenkron (asyncio) desteğine sahip modern Python kütüphanesi.

Python 3.9+ ile uyumlu olup Django ve betikler için senkron arayüzün yanı sıra FastAPI ve aiohttp için asenkron (asyncio) istemci sunar.


Kurulum

Shell
pip install smallpict# veya poetry ilepoetry add smallpict

Kapsamlı Kullanım Örneği

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. Yerel görseli optimize edinwith 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"Tasarruf Oranı: {result.savings_percentage}%")
# 2. Kotayı kontrol edinquota = client.get_quota()print(f"Plan: {quota.plan} - Kalan: {quota.remaining}")