Python
← Full documentation
Python integration guide
Add spam detection to Flask, Django, FastAPI, or any Python application. Uses the standard requests library — no additional dependencies.
install
pip install requests
Authentication: All requests need a Bearer token in the
Authorization header. Generate one in Settings → API Tokens.
Basic example
import requests
KIREIFILTER_TOKEN = "your_token_here"
def check_spam(content: str, ip: str = "") -> dict:
response = requests.post(
"https://kireifilter.net/api/v1/spam-check",
headers={"Authorization": f"Bearer {KIREIFILTER_TOKEN}"},
json={
"type": "comment",
"content": content,
"metadata": {"ip": ip},
},
timeout=5,
)
response.raise_for_status()
return response.json()
Flask contact form example
from flask import request, jsonify, abort
@app.route("/contact", methods=["POST"])
def contact():
data = request.get_json()
result = check_spam(
data["message"],
request.remote_addr,
)
if result["isSpam"]:
abort(422, "Spam detected")
# process the message...
return jsonify({"status": "sent"})
Response fields
| Field | Type | Description |
|---|---|---|
| isSpam | boolean | True if score ≥ 0.5 |
| score | float | 0.0 (clean) to 1.0 (spam). Spam threshold is 0.5. |
| reasons | list | Detection signals that contributed to the score |