Skip to main content

Official Python client for the Siftfy spam-classification API.

Project description

siftfy-python

Official Python client for the Siftfy spam-classification API. POST text, get a calibrated spam probability back. One round-trip, no queues, no models to host.

PyPI version Python versions License: MIT

Install

pip install siftfy

Quick start

from siftfy import Siftfy

client = Siftfy(api_key="sk_live_...")

result = client.predict("Win a free iPad — click here!")
print(result.spam_probability)  # 0.97
print(result.likelihood)        # "high"

Get an API key at siftfy.io — the free tier covers 10,000 requests/month at no cost.

Async

import asyncio
from siftfy import AsyncSiftfy

async def main() -> None:
    async with AsyncSiftfy(api_key="sk_live_...") as client:
        result = await client.predict("hello, world")
        print(result.spam_probability)

asyncio.run(main())

Calibrated probabilities

Every spam_probability is a calibrated value between 0 and 1 — at 0.7, roughly 70% of inputs with that score are actually spam. Pick a threshold appropriate to your use case (a help-desk form tolerates more false positives than a marketplace listing); the same model serves both.

The likelihood field is a coarse bucket ("low", "medium", "high") derived from the probability. Handy for quick branches, but for production decisions thread on the raw probability and your own threshold.

Errors

from siftfy import (
    Siftfy,
    AuthenticationError,  # 401 — bad / revoked key
    RateLimitError,       # 429 — over your tier limit; .retry_after available
    APIError,             # any other 4xx/5xx
    SiftfyError,          # network / request transport errors
)

try:
    result = client.predict(text)
except RateLimitError as e:
    sleep_for = e.retry_after or 1.0
    ...
except AuthenticationError:
    ...
except APIError as e:
    log(f"siftfy error {e.status_code}: {e} (request_id={e.request_id})")

The client retries idempotent failures (HTTP 408 / 429 / 5xx, network errors) with exponential backoff and jitter, honouring Retry-After when present. Tune with max_retries=N (default 2; set 0 to disable).

Configuration

client = Siftfy(
    api_key="sk_live_...",
    base_url="https://api.siftfy.io",  # override for self-hosted / staging
    timeout=10.0,                       # seconds, applied per attempt
    max_retries=2,                      # 0 disables retries
)

You can also pass your own httpx.Client (or httpx.AsyncClient for the async client) via http_client=... if you want connection pooling, custom transports, or to share a client across services.

Resources

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

siftfy-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

siftfy-0.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file siftfy-0.1.0.tar.gz.

File metadata

  • Download URL: siftfy-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for siftfy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 05caad46ac1fd759a6bd10f84e0d529a87a07355de07f3817c6852650f32cb68
MD5 f55b1ca72c7e0d94ead85afcecd17c3a
BLAKE2b-256 470e35c03cca06c06b99f4d9725d4386084d0975b1d8ff6687901fdf94151105

See more details on using hashes here.

Provenance

The following attestation bundles were made for siftfy-0.1.0.tar.gz:

Publisher: publish.yml on GipsyChef/siftfy-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file siftfy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: siftfy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for siftfy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 938ca62bd69ca9b004210abb74e9510d5d126987b81f08fe7d842010384a016d
MD5 23aa0b7bfe9a675e647d140a7bfbbd17
BLAKE2b-256 1f2ed33e9de5ed46ff28b893af5eda7d60a2bb93a64fc52b7694eca9f11c455b

See more details on using hashes here.

Provenance

The following attestation bundles were made for siftfy-0.1.0-py3-none-any.whl:

Publisher: publish.yml on GipsyChef/siftfy-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page