Skip to main content

Official Python SDK for QRAuth — cryptographic QR code verification

Project description

qrauth

Official Python SDK for QRAuth -- cryptographic QR code verification and anti-fraud infrastructure.

Install

pip install qrauth

Quick Start

from qrauth import QRAuth

qr = QRAuth(api_key="qrauth_xxx")

# Generate a verified QR code
code = qr.create(
    "https://municipal-parking.com/pay",
    location={"lat": 40.63, "lng": 22.94},
    expires_in="1y",
)

print(code["verification_url"])
# -> https://qrauth.io/v/xK9m2pQ7

# Verify a scanned QR code
result = qr.verify("xK9m2pQ7")
print(result["verified"])              # True
print(result["security"]["trustScore"])  # 94

API

QRAuth(api_key, *, base_url="https://qrauth.io")

Parameter Type Required Description
api_key str Yes Your API key (starts with qrauth_)
base_url str No API base URL. Defaults to https://qrauth.io

qr.create(destination, **kwargs)

Generate a cryptographically signed QR code.

code = qr.create(
    "https://example.com/pay",
    label="Parking Meter #42",
    location={"lat": 40.63, "lng": 22.94, "radiusM": 100},
    expires_in="30d",
)
Parameter Type Description
destination str Target URL
label str Human-readable label
location dict {"lat": ..., "lng": ..., "radiusM": ...} geo-fence
expires_in str Duration (30s, 5m, 6h, 30d, 1y) or ISO date
content_type str Content type: url, event, coupon, vcard, etc.
content dict Structured content (for non-URL types)

qr.verify(token, *, client_lat=None, client_lng=None)

Verify a QR code and get its trust score.

result = qr.verify("xK9m2pQ7", client_lat=40.63, client_lng=22.94)

qr.list(*, page=1, page_size=20, status=None)

List QR codes for your organization.

response = qr.list(page=1, page_size=20, status="ACTIVE")
for item in response["data"]:
    print(item["token"], item["status"])

qr.get(token)

Get details of a specific QR code.

qr.revoke(token)

Revoke a QR code so it no longer verifies.

qr.bulk(items)

Create up to 100 QR codes in a single request.

result = qr.bulk([
    {"destination": "https://example.com/1", "label": "Meter 1"},
    {"destination": "https://example.com/2", "label": "Meter 2"},
])

Context Manager

The client can be used as a context manager to ensure the HTTP connection pool is properly closed:

with QRAuth(api_key="qrauth_xxx") as qr:
    code = qr.create("https://example.com")

Error Handling

from qrauth import QRAuth, AuthenticationError, RateLimitError

try:
    qr.create("https://example.com")
except AuthenticationError:
    print("Bad API key")
except RateLimitError as err:
    print(f"Rate limited. Retry after {err.retry_after}s")
Exception HTTP Status Description
ValidationError 400 Request validation failed
AuthenticationError 401 Invalid or missing API key
AuthorizationError 403 Insufficient permissions
NotFoundError 404 Resource not found
RateLimitError 429 Rate limit exceeded
QuotaExceededError 429 Plan quota exceeded
QRAuthError * Base class for all errors

License

MIT

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

qrauth-0.1.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

qrauth-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file qrauth-0.1.1.tar.gz.

File metadata

  • Download URL: qrauth-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for qrauth-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ad9bed7bec6d4ca3748727f6f467a706a10a81707687f523cf4bcad913c6faaa
MD5 3ec38e41fddb2bc085edc3eae1c9cfb4
BLAKE2b-256 723ad11e40cc7f936f4a6adda3e3a4a5c76c586387ef77a451cbd67b0a43c248

See more details on using hashes here.

File details

Details for the file qrauth-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: qrauth-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for qrauth-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b335576be5613164106fce9da6f75d8569e08381fe944e709271d13b17d398b1
MD5 99c75117c77408af5a97d8c914a2227b
BLAKE2b-256 aae814e01224e1abe2af8fd6a52f946102fca20187a5a24658cc79ebbb6527f5

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