Skip to main content

AuraGyt Python SDK for biometric authentication and identity verification

Project description

AuraGyt Python SDK

Python SDK for AuraGyt biometric authentication and identity verification API.

Installation

pip install auragyt-sdk

Or install from source:

git clone https://github.com/auragyt/auragyt-app.git
cd auragyt-app/sdk/python
pip install -e .

Quick Start

from auragyt_sdk import AuraGytSDK

# Initialize SDK
sdk = AuraGytSDK({
    "base_url": "http://localhost:8000",
    "api_key": "your-api-key"  # Optional
})

# Register a new user
user = sdk.auth.register("user@example.com", "password123")

# Login
tokens = sdk.auth.login("user@example.com", "password123")

# Enroll face
enrollment_result = sdk.auth.enroll_face("path/to/face_image.jpg")

# Verify face
verification_result = sdk.auth.verify_face("path/to/face_image.jpg")
print(f"Match: {verification_result.is_match}, Score: {verification_result.similarity_score}")

# Detect faces
faces = sdk.face.detect("path/to/image.jpg")
for face in faces:
    print(f"Confidence: {face.confidence}, BBox: {face.bbox}")

# Check liveness
liveness_result = sdk.liveness.check(["frame1.jpg", "frame2.jpg", "frame3.jpg"])
print(f"Live: {liveness_result.is_live}, Score: {liveness_result.liveness_score}")

# Calculate risk score
risk_result = sdk.risk.calculate_risk_score(
    device_fingerprint="device123",
    ip_address="192.168.1.1"
)
print(f"Risk Score: {risk_result.risk_score}, Level: {risk_result.risk_level}")

Configuration

from auragyt_sdk import AuraGytSDK

sdk = AuraGytSDK({
    "api_key": "your-api-key",        # API key for authentication
    "base_url": "https://api.auragyt.com",  # API base URL
    "timeout": 30,                     # Request timeout in seconds
    "retries": 3,                      # Number of retries
    "retry_delay": 1,                  # Delay between retries in seconds
    "access_token": "token"            # Access token (set automatically after login)
})

Features

Face Recognition

  • Face Detection: Detect faces in images
  • Face Embedding: Extract face embeddings for comparison
  • Face Verification: Verify if two faces match (1:1)
  • Face Search: Search for similar faces in database (1:N)
# Detect faces
faces = sdk.face.detect("image.jpg")

# Extract embedding
embedding = sdk.face.embed("image.jpg")

# Verify two faces
result = sdk.face.verify("image1.jpg", "image2.jpg", threshold=0.6)

# Search for similar faces
search_result = sdk.face.search("image.jpg", top_k=5, threshold=0.6)

Liveness Detection

  • Liveness Check: Check if face is live from video frames
  • Spoofing Detection: Detect spoofing attempts
# Check liveness from video frames
result = sdk.liveness.check(["frame1.jpg", "frame2.jpg"], challenge_type="blink")

# Detect spoofing
spoof_result = sdk.liveness.detect_spoofing("image.jpg")

Authentication

  • User Registration: Register new users
  • Login/Logout: Authenticate users
  • Token Management: Handle access and refresh tokens
  • Face Enrollment: Enroll face templates for users
  • Face Verification: Verify faces against enrolled templates
# Register
user = sdk.auth.register("user@example.com", "password")

# Login
tokens = sdk.auth.login("user@example.com", "password")

# Enroll face
enrollment = sdk.auth.enroll_face("face.jpg", quality_threshold=0.7)

# Verify face
verification = sdk.auth.verify_face("face.jpg", threshold=0.6)

# Get current user
user = sdk.auth.get_current_user()

# Refresh token
tokens = sdk.auth.refresh_token()

# Logout
sdk.auth.logout()

Risk Management

  • Risk Scoring: Calculate risk scores for transactions
  • Blacklist Checking: Check if users/devices/IPs are blacklisted
# Calculate risk score
risk = sdk.risk.calculate_risk_score(
    user_id="user123",
    device_fingerprint="device123",
    ip_address="192.168.1.1"
)

# Check blacklist
blacklist = sdk.risk.check_blacklist(
    user_id="user123",
    device_fingerprint="device123",
    ip_address="192.168.1.1"
)

Error Handling

The SDK provides custom exceptions for different error types:

from auragyt_sdk import (
    AuraGytError,
    NetworkError,
    AuthenticationError,
    ValidationError,
    ServiceUnavailableError
)

try:
    result = sdk.face.detect("image.jpg")
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except ValidationError as e:
    print(f"Validation error: {e}")
except NetworkError as e:
    print(f"Network error: {e}")
except AuraGytError as e:
    print(f"API error: {e}")

Type Hints

The SDK is fully typed with type hints for better IDE support:

from auragyt_sdk import (
    FaceDetectionResult,
    FaceVerificationResult,
    LivenessCheckResult,
    EnrollmentResult,
    User,
    AuthTokens
)

faces: list[FaceDetectionResult] = sdk.face.detect("image.jpg")
result: FaceVerificationResult = sdk.face.verify("img1.jpg", "img2.jpg")

Examples

See the examples/ directory for more detailed examples.

API Reference

Full API reference documentation is available at https://github.com/auragyt/auragyt-app.

License

MIT License

Support

For issues and questions, please visit https://github.com/auragyt/auragyt-app/issues.

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

auragyt_sdk-1.0.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

auragyt_sdk-1.0.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file auragyt_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: auragyt_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for auragyt_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fda5da2dd25c704113622ba20557aa76b6cac4ea6d306ad6692b7886d965190d
MD5 617488b093876f1178d3d5e3f95fec4f
BLAKE2b-256 ccaab7be4c9d3991a77a17eab0403bd042a91959afd30294ed8e47610b0fde33

See more details on using hashes here.

File details

Details for the file auragyt_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: auragyt_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for auragyt_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 daf2266b06ee33e64b01709303bdbf58eb3c6cbbd752bee8ba00e575b1e7a3bb
MD5 b2ca9450117640c34f06fe6e2b4da57a
BLAKE2b-256 7971771080dd7bd4fdceee6a16f8501a40806da6a2cfeafd67d52aee55755a08

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