Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 4.0.1 instead.
Reason given by maintainers: contains unintended key material — superseded by 4.0.1

optropic

Official Python SDK for Optropic product authentication.

PyPI version Python License: MIT

Features

  • Simple Authentication - Single API key for all operations
  • Type-Safe - Full type annotations with py.typed support
  • Fast Integration - Copy-paste quickstart, production-ready
  • Vertical Agnostic - Same API for pharma, luxury, art, and more
  • Error Transparency - Clear error codes, actionable messages

Installation

pip install optropic

Quick Start

from optropic import OptropicClient

# Initialize the client
client = OptropicClient(api_key="op_live_xxxxxxxxxxxx")

# Verify an asset
result = client.verify("asset-id-or-short-id")

if result.signature_valid:
    print("Product is genuine!")
    print(f"Security level: {result.security_level}")
else:
    print("Warning: verification failed")

# Or use as a context manager
with OptropicClient(api_key="op_live_xxxxxxxxxxxx") as client:
    result = client.verify("asset-id-or-short-id")
    print(result.status)

API Reference

OptropicClient

The main client class for all SDK operations.

Constructor

client = OptropicClient(
    api_key="op_live_xxx",       # Required: Your API key
    base_url="https://...",      # Optional: For self-hosted deployments
    timeout=30.0,                # Optional: Request timeout in seconds (default: 30)
)

Methods

verify(asset_id: str) -> VerifyResult

Verify an asset by ID or short_id.

result = client.verify("asset-id-or-short-id")

# Result fields
result.id                  # str: Asset ID
result.status              # str: Verification status
result.security_level      # str: 'signed', 'sealed', etc.
result.signature_valid     # bool: Whether signature is valid
result.verification_count  # int: Number of times verified
result.last_verified_at    # str: ISO timestamp of last verification
result.revocation_status   # str: 'active' or 'revoked'
result.verification_mode   # str: 'online' or 'offline'
result.provenance_valid    # Optional[bool]: Provenance chain validity
result.evidence            # Optional[VerificationEvidence]: Detailed evidence

Error Handling

All errors extend OptropicError with clear error codes:

from optropic import (
    OptropicClient,
    OptropicError,
    AuthenticationError,
    NotFoundError,
)

try:
    result = client.verify("asset-id")
except NotFoundError:
    print("Asset not found in system.")
except AuthenticationError:
    print("Invalid API key.")
except OptropicError as e:
    print(f"Error {e.code}: {e}")
    print(f"HTTP status: {e.status}")

Error Types

Error Code Description
AuthenticationError INVALID_API_KEY API key is invalid or missing
NotFoundError NOT_FOUND Asset doesn't exist in the system
OptropicError varies Base error for all other API errors

Types

All types are frozen dataclasses with full type annotations:

from optropic import VerifyResult, VerificationEvidence
  • VerifyResult - Result of verifying an asset
  • VerificationEvidence - Structured evidence from verification

Environment Variables

Recommended setup for production:

# .env
OPTROPIC_API_KEY=op_live_xxxxxxxxxxxx
import os
from optropic import OptropicClient

client = OptropicClient(api_key=os.environ["OPTROPIC_API_KEY"])

Examples

Flask Backend

from flask import Flask, request, jsonify
from optropic import OptropicClient, NotFoundError

app = Flask(__name__)
client = OptropicClient(api_key=os.environ["OPTROPIC_API_KEY"])

@app.route("/api/verify", methods=["POST"])
def verify():
    try:
        result = client.verify(request.json["asset_id"])
        return jsonify({
            "status": result.status,
            "signature_valid": result.signature_valid,
            "security_level": result.security_level,
        })
    except NotFoundError:
        return jsonify({"error": "Asset not found"}), 404

Django View

import os
from django.http import JsonResponse
from optropic import OptropicClient

client = OptropicClient(api_key=os.environ["OPTROPIC_API_KEY"])

def verify_asset(request, asset_id):
    result = client.verify(asset_id)
    return JsonResponse({
        "status": result.status,
        "signature_valid": result.signature_valid,
    })

Support

License

MIT - Optropic GmbH i.Gr.

Download files

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

Source Distribution

optropic-4.0.0.tar.gz (52.1 kB view details)

Uploaded Source

Built Distribution

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

optropic-4.0.0-py3-none-any.whl (40.4 kB view details)

Uploaded Python 3

File details

Details for the file optropic-4.0.0.tar.gz.

File metadata

  • Download URL: optropic-4.0.0.tar.gz
  • Upload date:
  • Size: 52.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for optropic-4.0.0.tar.gz
Algorithm Hash digest
SHA256 3f2b47652f8e200c1c4018c35b104bb721d10182bae31fff67b039cfe0fa1763
MD5 bd5f80b3996f150e098351b2bfc9c2d6
BLAKE2b-256 6e02d7336b51411b88a343aec8c0c788f61f4bfc4b662a42ac282fbba733a329

See more details on using hashes here.

File details

Details for the file optropic-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: optropic-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 40.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for optropic-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 071ab212788d6f38cf1a2d164410bec059fc697d86581098f920e7cff0b2ce67
MD5 29668e62f12b258fc1943628c5565f3e
BLAKE2b-256 59fb2cbba2293b62a4fc7a9b906cf6272b2e6caf303c54b79b19ece4b35b4ebb

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 Sentry Error logging StatusPage Status page