Official Python SDK for the Turing Verify API
Project description
turingverify
Official Python SDK for the Turing Verify document verification API.
Install
pip install turingverify
Requires Python 3.9+. Depends only on httpx and pydantic.
Quickstart
from turingverify import TuringVerify
client = TuringVerify(api_key="tv_live_sk_...")
with open("diploma.pdf", "rb") as f:
ver = client.verifications.create(file=f, filename="diploma.pdf")
print(ver.verdict, ver.confidence)
# → 'ACCEPT' 0.94
Async
import asyncio
from turingverify import AsyncTuringVerify
async def main():
async with AsyncTuringVerify(api_key="tv_live_sk_...") as client:
ver = await client.verifications.retrieve("ver_abc...")
print(ver.verdict)
asyncio.run(main())
Verifying webhook signatures
from turingverify import verify_signature, SignatureVerificationError
@app.post("/hooks/turing-verify")
async def receive(request):
body = await request.body()
sig = request.headers["X-TuringVerify-Signature"]
try:
verify_signature(body, sig, SECRET, tolerance=300)
except SignatureVerificationError:
return 400, "bad signature"
# ...process event
Errors
Every error inherits TuringVerifyError:
from turingverify import (
TuringVerifyError, # base class
APIError, # generic non-2xx
AuthenticationError, # 401
InvalidRequestError, # 400 / 422
RateLimitError, # 429 — exposes .retry_after
IdempotencyConflictError,# 409
SignatureVerificationError, # webhook HMAC failed
)
Retry behavior
- 5xx, 429, and network errors retry with exponential backoff (+ jitter).
Retry-Afteris honored when the server sends it.max_retries=3by default — passmax_retries=0to disable.
Idempotency
Every POST /v1/verifications call gets an automatic UUID4 Idempotency-Key
header. Pass idempotency_key="..." to use your own. Replays within 24h
return the cached response.
CLI
# Environment variables:
export TURING_VERIFY_API_KEY=tv_live_sk_...
turingverify verify path/to/diploma.pdf
turingverify tokens create --name ci-pipeline --env live
turingverify webhooks list
turingverify webhooks send-test whk_abc...
turingverify --json tokens list
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 turingverify-0.1.0.tar.gz.
File metadata
- Download URL: turingverify-0.1.0.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbc18d4b7a8195a54af34211a295b7e58d3f22f6bfe8f29b6916aa2ff403aca9
|
|
| MD5 |
9da76832a15cb076395646d8ba2ef9ae
|
|
| BLAKE2b-256 |
e7d364d3458dc95b4304fc67e99f8c6105e00f40869bafee5647d52eaa756dd3
|
File details
Details for the file turingverify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: turingverify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6965cf94aeda8c7d4f5e1b5fe119c2ce368db5547c1554b5b66dfb27f09b6166
|
|
| MD5 |
0fc336142b010b9d46de7f68e71ece44
|
|
| BLAKE2b-256 |
62b0b14be4a61591e876123bffffad635c7119aee0708a059ab58591d175f39d
|