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://parking.gr/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.0.tar.gz (6.6 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.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qrauth-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 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.0.tar.gz
Algorithm Hash digest
SHA256 167451550bbda5e470c8e743808170fd272a5664dcd274e7322726e1c8cdfc4a
MD5 e96ddbbf187e504f2ac58e7efb33899a
BLAKE2b-256 fb3b1c218f24973c17b8b04372605faa59698e05507ba7031edd48185ccdfbee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qrauth-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3ca4ff8a9d3e85253b765d512a551778a0877d0ffcbf22b227df7a314df6c4f
MD5 e4cfbf1296d0163446374588707d73ac
BLAKE2b-256 9a2072ed470037559a9a683abdf7a8797760041135281e2071649e844477c419

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