TypeScript/JavaScript π
The official TypeScript/JavaScript client for the CardScan API provides a type-safe interface for all API operations.
Installation
npm install @cardscan.ai/cardscan-client
# or
yarn add @cardscan.ai/cardscan-client
# or
pnpm add @cardscan.ai/cardscan-clientBasic Usage
import { CardScanApi } from '@cardscan.ai/cardscan-client';
// Initialize with your API key
const apiKey = 'sk_test_cardscan_ai_...';
const client = new CardScanApi({ apiKey });
// Generate a session token for a user
const { Token, IdentityId, session_id } = await client.getAccessToken({
user_id: 'unique-user-123'
});
// Initialize client with session token for frontend operations
const userClient = new CardScanApi({
sessionToken: Token,
live: false // Use sandbox environment
});Quick Start with fullScan
The easiest way to scan cards is using the fullScan helper method that handles the entire workflow:
The fullScan method automatically:
Creates a card with appropriate settings
Generates upload URLs
Uploads images in the correct order
Monitors processing via WebSocket
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
WebSocket Support
For real-time updates, connect to the WebSocket API:
Eligibility Verification
Helper Methods
Full Scan Helper
The client includes a fullScan helper method that simplifies the entire card scanning workflow:
TypeScript Types
The client includes full TypeScript definitions for all API operations:
Configuration Options
Browser Usage
The client works in both Node.js and browser environments:
Source Code
View the source code and contribute: GitHub
Last updated
Was this helpful?