Python 연동
Python은 패키지나 의존성 없이도 완전히 보호할 수 있습니다. 검증은 HTTPS 호출 한 번입니다.
저희는 Python SDK를 제공하지 않습니다. 이는 배포 방식에 대한 이야기일 뿐 보호 수준과는 무관합니다. SDK가 하는 일을 아래 호출이 표준 라이브러리만으로 처리합니다.
1. 위젯 삽입
스크립트가 브라우저에서 행동을 측정하고 모든 양식에 숨김 필드를 넣습니다. 페이지 헤더에 한 번만 추가하십시오.
HTMLhtml
<!-- Add to <head> with SRI for security -->
(function () {
var KEY = "YOUR_API_KEY";
var SITE = location.hostname;
var V = "2025.09.1";
var s = document.createElement('script');
s.src = "https://api.silentshield.io/client.js?k=" + encodeURIComponent(KEY)
+ "&v=" + encodeURIComponent(V)
+ "&site=" + encodeURIComponent(SITE);
s.async = true;
s.crossOrigin = "anonymous";
document.head.appendChild(s);
})();2. 서버에서 검증
전송 시 숨김 필드를 읽어 제출을 수락하기 전에 저희에게 문의하십시오. 이 단계가 없으면 브라우저만 판단하게 되며, JavaScript를 실행하지 않는 봇은 그대로 통과합니다.
Pythonpython
# No package required — the check is one HTTPS POST.
# Standard library only: nothing to install, nothing to keep updated.
import json
import os
import urllib.error
import urllib.request
VERIFY_URL = "https://api.silentshield.io/api/v1/captcha/verify-nonce"
API_KEY = os.environ["SILENTSHIELD_KEY"] # never hard-code it
def is_human(nonce: str) -> bool:
"""Ask SilentShield about one submission.
The hidden field `behavior_nonce` is injected by client.js;
read it from the posted form and hand it over unchanged.
"""
if not nonce:
return False
request = urllib.request.Request(
VERIFY_URL,
data=json.dumps({"nonce": nonce}).encode(),
headers={
"Content-Type": "application/json",
"X-Api-Key": API_KEY,
# Tells us which integration is in use, exactly like the SDKs do.
"X-SS-SDK": "python-inline/1",
},
method="POST",
)
try:
with urllib.request.urlopen(request, timeout=5) as response:
data = json.loads(response.read())
except (urllib.error.URLError, TimeoutError, ValueError):
# We are unreachable. Let the visitor through: a real customer turned
# away costs more than a bot let in. Flip this to False only if you
# would rather lose submissions than accept one unchecked.
return True
return (
data.get("ok") is True
and data.get("verdict") == "human"
and data.get("confidence", 0) >= 0.7
)
# --- Flask ---------------------------------------------------------------
# @app.post("/contact")
# def contact():
# if not is_human(request.form.get("behavior_nonce", "")):
# abort(400, "Please submit the form again.")
# ...
# --- Django --------------------------------------------------------------
# def contact(request):
# if not is_human(request.POST.get("behavior_nonce", "")):
# return HttpResponseBadRequest("Please submit the form again.")
# ...
# --- FastAPI -------------------------------------------------------------
# @app.post("/contact")
# async def contact(behavior_nonce: str = Form("")):
# if not is_human(behavior_nonce):
# raise HTTPException(status_code=400, detail="Please submit the form again.")
# ...Flask, Django, FastAPI
위 함수는 프레임워크와 무관합니다. 호출 위치 세 곳이 코드 끝에 주석으로 있습니다. Flask는 양식 사전에서, Django는 POST 데이터에서, FastAPI는 양식 매개변수에서 읽습니다.
저희에게 연결할 수 없을 때
이 코드는 방문자를 통과시킵니다. 잘못 거절된 고객의 손실이 통과된 봇보다 크기 때문입니다. 반대를 원하시면 오류 분기에서 거짓을 반환하십시오. 그러면 장애 시 제출을 잃게 됩니다.
AI 에이전트
에이전트 관측도 같은 방식으로 텔레메트리 엔드포인트에 보고합니다. POST 한 번, 헤더도 동일합니다.
규칙의 로컬 적용은 Python에서는 불가능합니다. 규칙 묶음에 대한 Ed25519 서명 검증이 필요하기 때문입니다. 엔포서를 사이드카로 애플리케이션 앞에 두거나 Cloudflare Worker를 사용하십시오.