Skip to main content

Python Wrapper for Idegrity's Identity services

Project description

Idegrity IDentity Product Python Wrapper

This library provides a wrapper to access Idegrity's IDentity services

Features

  • Easy authentication
  • Handles both image streams and image file
  • Provides results in JSON or TOML

Installation

Install this package with pip:

pip install idegrity-identity

Usage

This library provides both synchronous and asynchronous clients to interact with the VerifyAPI. Here's how you can use each of them.

Synchronous Usage

The synchronous version of the API can be used in scripts where asynchronous programming is not a requirement. Here's an example of how to use it:

from idegrity_identity import IdentityAPI

# Initialize the API client with your credentials
identity_api = IdentityAPI(user_id=123, key="your_api_key", key_secret="your_api_secret")

# Use the client to upload images
try:
    response = identity_api.verify_images("path/to/id_image.png", "path/to/face_image.png")
    print(response)  # Process the response
except Exception as e:
    print(f"An error occurred: {e}")

Asynchronous Usage

The asynchronous client is suitable for applications that are designed to take advantage of asynchronous programming, making your I/O-bound tasks more efficient. Here's how to use the asynchronous client:

from idegrity_identity import AsyncIdentityAPI
import asyncio

async def main():
    # Initialize the API client with your credentials
    async_identity_api = AsyncIdentityAPI(user_id=123, key="your_api_key", key_secret="your_api_secret")
    # async_identity_api = AsyncIdentityAPI(user_id=123, key="your_api_key", key_secret="your_api_secret", endpoint_url="https://customurl.local") # optionally provide a custom API endpoint
    
    # Use the client to asynchronously upload images
    try:
        response = await async_identity_api.verify_images("path/to/id_image.png", "path/to/face_image.png")
        print(response)  # Process the response
    except Exception as e:
        print(f"An error occurred: {e}")

# Run the async main function
asyncio.run(main())

Handling File-Like Objects

Both synchronous and asynchronous clients support uploading images from file-like objects(streams) (e.g., io.BytesIO). Here's how you can do it:

from idegrity_identity import IdentityAPI
from io import BytesIO

# Imagine these are your image bytes
id_image_bytes = b'...'
face_image_bytes = b'...'

# Convert bytes to file-like objects
id_image_file = BytesIO(id_image_bytes)
face_image_file = BytesIO(face_image_bytes)

# Initialize the API client with your credentials
identity_api = IdentityAPI(user_id=123, key="your_api_key", key_secret="your_api_secret")

# Upload the images
response = identity_api.verify_images(id_image_file, face_image_file)
print(response)

Support

If you encounter any issues or have questions, please file an issue on GitHub.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

idegrity_identity-0.1.5-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file idegrity_identity-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for idegrity_identity-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e2d4b75e9800a534f87937296d79a0ad034dfb729532c160834f4a80b62ba4a2
MD5 3b8886eb1d4464e7b18e3166da4ef65d
BLAKE2b-256 d2e6cfcb6150d04f7e82693be0e63584e5b6ff293019a009e249b73fa9921031

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