문서 · 가이드
긴 초안 다루기
공개 키는 스트림이나 나눠 보내기, 계약 매체는 비동기 작업과 웹훅
공개 키
/check는 6,000자까지입니다(넘으면 413, 하루 건수에서 빼 줍니다). 더 긴 초안은 스트림(20,000자까지)으로 보내거나 나눠 보내세요.계약 매체: 비동기 작업
6,000자가 넘으면 202와 job_id를 돌려줍니다(최대 100,000자).
POST /check→ 202,job_id- GET /jobs/{job_id}를 1~2초 간격으로 조회.
status:queued·running·done(result) ·failed(error) - 결과는 1시간 동안 조회할 수 있습니다. 받았으면 DELETE /jobs/{job_id}로 지워도 됩니다.
curl -X GET 'https://api.neta-ai.com/fact-check/v1/jobs/{job_id}' \
-H "X-API-Key: $FC_KEY"웹훅
계약 때 https 주소와 비밀키를 등록한 매체에 POST {"job_id", "status", "result"}로 보냅니다. 서명은 두 머리로 확인하세요.
X-FC-Timestamp: 보낸 시각(유닉스 초)X-FC-Signature:hex(HMAC-SHA256(비밀키, "{timestamp}.{원본 본문 바이트}"))
파싱 전 바이트로 계산해 상수 시간으로 비교하고, 5분 넘은 타임스탬프는 버리세요. 실패하면 3번까지 다시 보냅니다.
Python: 서명 확인
import hashlib, hmac, time
def verify(secret: str, ts: str, body: bytes, signature: str, tolerance: int = 300) -> bool:
if abs(time.time() - int(ts)) > tolerance:
return False
expected = hmac.new(secret.encode(), ts.encode() + b"." + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)