Skip to main content

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-After is honored when the server sends it.
  • max_retries=3 by default — pass max_retries=0 to 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turingverify-0.2.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turingverify-0.2.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file turingverify-0.2.0.tar.gz.

File metadata

  • Download URL: turingverify-0.2.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for turingverify-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d3f15dc92051d8afcfd6126728c8dde31118e4fc14f4bcc4b5d5d73ff781b57c
MD5 fb3c89114ee33bdfe0a08832ab14af76
BLAKE2b-256 20e5a583d8609e96641d707a029e3a4de801ce486daf266abaabb461ac8a52ac

See more details on using hashes here.

File details

Details for the file turingverify-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: turingverify-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for turingverify-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9c99ed70a14062cc748783766c10e2b9f0850a9fcd526c09e3c9dbed02dc7a4
MD5 665cb77ec8862ec384dc45a5d0eba31d
BLAKE2b-256 24e4c9e59ccabf29427eb331157ae20fbdb34169226cf763f5b217bcf3ee03b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page