Skip to main content

Python SDK for DeepXL fraud detection, document parsing, and verification services

Project description

DeepXL Python SDK

Python SDK for DeepXL fraud detection, document parsing, verification, and file retrieval services.

Installation

pip install deepxl

Or install from source:

pip install -r requirements.txt

Usage

Initialize the Client

from deepxl import DeepXLClient, DeepXLClientConfig

config = DeepXLClientConfig(apiKey='your-api-key-here')
client = DeepXLClient(config)

Fraud Detection

Get Available Models

models = client.get_detection_models()
print(models)

Analyze a File for Fraud Detection

from deepxl import AnalyzeFileOptions

# Read file as bytes
with open('document.jpg', 'rb') as f:
    file_data = f.read()

options = AnalyzeFileOptions(
    model='document',  # or 'object'
    file=file_data,
    fileName='document.jpg',
    tags={
        'customerId': '9999',
        'customerName': 'Acme Corp',
        'documentId': 'DOC-2024-001'
    }
)

result = client.analyze_file(options)
print(result['result'])

Get Detection History

from deepxl import DetectionQueryParams

params = DetectionQueryParams(
    limit=25,
    offset=0,
    sortBy='createdOn',
    direction='desc',
    fraudSeverity='high',
    minLikelihood=70
)

history = client.get_detection_history(params)
print(history['data'])

Get Detection by ID

detection = client.get_detection_by_id(123)
print(detection['result'])

Document Parsing

Get Available Parsing Models

models = client.get_parsing_models()
print(models)

Parse a Document

from deepxl import ParseDocumentOptions

# Read file as bytes
with open('drivers_license.jpg', 'rb') as f:
    file_data = f.read()

options = ParseDocumentOptions(
    model='light',  # or 'performance'
    file=file_data,
    fileName='drivers_license.jpg',
    tags={
        'customerId': '9999',
        'customerName': 'Acme Corp'
    }
)

result = client.parse_document(options)
print(result['result']['parsedData'])

Get Parse History

from deepxl import ParseQueryParams

params = ParseQueryParams(
    limit=25,
    offset=0,
    sortBy='parseId',
    direction='desc',
    documentType='usa_driver_license'
)

history = client.get_parsing_history(params)
print(history['data'])

Get Parse by ID

parse_result = client.get_parse_by_id(117)
print(parse_result['result'])

Verification

Verify User with ID and Selfie

from deepxl import VerifyOptions

# Read files as bytes
with open('id.jpg', 'rb') as f:
    id_data = f.read()

with open('selfie.jpg', 'rb') as f:
    selfie_data = f.read()

options = VerifyOptions(
    idFile=id_data,
    idFileName='id.jpg',
    selfieFile=selfie_data,
    selfieFileName='selfie.jpg',
    tags={
        'customerId': '9999',
        'customerName': 'Acme Corp'
    }
)

result = client.verify(options)
print(result['result']['verified'])
print(result['result']['technicalChecks'])

Get Verification History

from deepxl import VerificationQueryParams

params = VerificationQueryParams(
    limit=25,
    offset=0,
    verified=True,
    sortBy='timestamp',
    direction='desc'
)

history = client.get_verification_history(params)
print(history['data'])

Get Verification by ID

verification = client.get_verification_by_id(456)
print(verification['result'])

File Retrieval

Download a File

file_bytes = client.download_file('fd_123_document.jpg')
with open('downloaded_file.jpg', 'wb') as f:
    f.write(file_bytes)

Get File as Response

response = client.get_file('fd_123_document.jpg')
file_bytes = response.content
with open('downloaded_file.jpg', 'wb') as f:
    f.write(file_bytes)

Type Definitions

All type definitions are available for import:

from deepxl import (
    Tag,
    FileData,
    ModelMetadata,
    FraudDetection,
    DetectionResponse,
    DetectionQueryParams,
    AnalyzeFileOptions,
    APIParse,
    APIParseResponse,
    ParseQueryParams,
    ParseDocumentOptions,
    Verification,
    VerificationResponse,
    VerificationQueryParams,
    VerifyOptions,
)

Error Handling

The SDK raises ValueError with descriptive error messages:

try:
    result = client.analyze_file(options)
except ValueError as e:
    print(f'Error: {e}')
    # Error messages match API error responses

Query Parameters

All query parameters are optional and can be used to filter and paginate results:

  • limit: Number of results (1-100, default: 25)
  • offset: Number of results to skip (default: 0)
  • sortBy: Field to sort by
  • direction: 'asc' or 'desc' (default: 'desc')
  • tagFilter: Filter by tags in format 'tagName=tagValue'
  • Various model-specific filters (see type definitions for details)

Tags

Tags are optional metadata that can be attached to analyses for organization and filtering:

tags = {
    'customerId': '9999',
    'customerName': 'Acme Corp',
    'documentId': 'DOC-2024-001',
    'companyName': 'DeepXL',
    'companyId': 'COMP-001'
}

You can filter results by tags using the tagFilter query parameter:

params = DetectionQueryParams(tagFilter='customerId=9999')
history = client.get_detection_history(params)

Using File Objects

You can also pass file-like objects directly:

# Using open file handle
with open('document.jpg', 'rb') as f:
    options = AnalyzeFileOptions(
        model='document',
        file=f,
        fileName='document.jpg'
    )
    result = client.analyze_file(options)

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

deepxl_python_sdk-1.2.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

deepxl_python_sdk-1.2.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file deepxl_python_sdk-1.2.1.tar.gz.

File metadata

  • Download URL: deepxl_python_sdk-1.2.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for deepxl_python_sdk-1.2.1.tar.gz
Algorithm Hash digest
SHA256 0483b3c51853f6ad1b71ede83f92e1ff12d38065c17eb6e8b308450a85e48d59
MD5 d9bd6de4e20e75a782884c99e17ea293
BLAKE2b-256 fb8dcd1307adec8b25f231c3368f71dd018fe9365238ef586032cd8d6bed5d1c

See more details on using hashes here.

File details

Details for the file deepxl_python_sdk-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for deepxl_python_sdk-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0effcc3ec24bdb3c1c6d85359db2ab75a2300d9da77493608b27b3e1a1fc1b6
MD5 4d81f0e314190c55c9a6addbb2b65eee
BLAKE2b-256 bca2ee87a06a27b89256959c82f5e16caa40c853fc827b87ecd598c11ad00796

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