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.
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
- API reference: https://siftfy.io/docs
- Pricing: https://siftfy.io/pricing
- Status: ping
https://api.siftfy.io/health - Issues: https://github.com/siftfy/siftfy-python/issues
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file siftfy-0.1.1.tar.gz.
File metadata
- Download URL: siftfy-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2f7cfefb5d01d211f7b489ca2f517666fb87daf210bd4cfb368a7adb0bd827a
|
|
| MD5 |
cba1ec0e613ab595ac587cb8d7d631e4
|
|
| BLAKE2b-256 |
93c0af25c63fc390bc4144bb4956c24df40c2754177091ff17326e8b9b63c7d6
|
Provenance
The following attestation bundles were made for siftfy-0.1.1.tar.gz:
Publisher:
publish.yml on siftfy/siftfy-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
siftfy-0.1.1.tar.gz -
Subject digest:
c2f7cfefb5d01d211f7b489ca2f517666fb87daf210bd4cfb368a7adb0bd827a - Sigstore transparency entry: 1438725959
- Sigstore integration time:
-
Permalink:
siftfy/siftfy-python@51cac6a970399b135d54e021d848db202b12c2a0 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/siftfy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@51cac6a970399b135d54e021d848db202b12c2a0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file siftfy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: siftfy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a14b4c433df4d8bb87c516dea7bf92edacc88eb5a7b9063899061c25702f01c7
|
|
| MD5 |
2f1438a92930519b6f47117c8d5afa82
|
|
| BLAKE2b-256 |
d927d685891c49d8bacd8c7db5dcc8514fde9d24dbb2900f4571db599624559d
|
Provenance
The following attestation bundles were made for siftfy-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on siftfy/siftfy-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
siftfy-0.1.1-py3-none-any.whl -
Subject digest:
a14b4c433df4d8bb87c516dea7bf92edacc88eb5a7b9063899061c25702f01c7 - Sigstore transparency entry: 1438725993
- Sigstore integration time:
-
Permalink:
siftfy/siftfy-python@51cac6a970399b135d54e021d848db202b12c2a0 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/siftfy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@51cac6a970399b135d54e021d848db202b12c2a0 -
Trigger Event:
push
-
Statement type: