Python 🐍

The official Python client for the CardScan API provides a pythonic interface for all API operations.

Installation

pip install cardscan-client

Basic Usage

from cardscan_client import CardScanApi
from cardscan_client.exceptions import ApiException

# Initialize with your API key
api_key = "sk_test_cardscan_ai_..."
client = CardScanApi(api_key=api_key)

# Generate a session token for a user
token_response = client.get_access_token(user_id="unique-user-123")
session_token = token_response["Token"]
identity_id = token_response["IdentityId"]
session_id = token_response["session_id"]

# Initialize client with session token for frontend operations
user_client = CardScanApi(session_token=session_token, live=False)

Quick Start with full_scan

The easiest way to scan cards is using the full_scan helper method that handles the entire workflow:

The full_scan method automatically:

  • Generates a session token for the user

  • Creates a card with appropriate settings

  • Uploads images in the correct order

  • Polls for processing completion

  • Returns the completed card with all extracted data

Manual Card Scanning Workflow

For more control over the scanning process, you can use the step-by-step approach:

1. Create a Card

2. Generate Upload URL

3. Upload Image

4. Poll for Results

Error Handling

Async Support

The client supports async operations using asyncio:

WebSocket Support

For real-time updates using WebSocket:

Eligibility Verification

Batch Operations

Process multiple cards efficiently:

Configuration Options

Type Hints

The client includes comprehensive type hints:

Logging

Enable detailed logging for debugging:

Source Code

View the source code and contribute: GitHub

Last updated

Was this helpful?