deepxl-node-sdk
v1.2.1
Published
SDK for deepxl fraud detection services
Downloads
101
Readme
DeepXL Node.js SDK
TypeScript/JavaScript SDK for DeepXL fraud detection, document parsing, verification, and file retrieval services.
Installation
npm install deepxl-node-sdkUsage
Initialize the Client
import { DeepXLClient } from 'deepxl-node-sdk';
const client = new DeepXLClient({
apiKey: 'your-api-key-here'
});Fraud Detection
Get Available Models
const models = await client.getDetectionModels();
console.log(models);Analyze a File for Fraud Detection
import fs from 'fs';
const fileBuffer = fs.readFileSync('document.jpg');
const result = await client.analyzeFile({
model: 'document', // or 'object'
file: fileBuffer,
fileName: 'document.jpg',
tags: {
customerId: '9999',
customerName: 'Acme Corp',
documentId: 'DOC-2024-001'
}
});
console.log(result.result);Get Detection History
const history = await client.getDetectionHistory({
limit: 25,
offset: 0,
sortBy: 'createdOn',
direction: 'desc',
fraudSeverity: 'high',
minLikelihood: 70
});
console.log(history.data);Get Detection by ID
const detection = await client.getDetectionById(123);
console.log(detection.result);Document Parsing
Get Available Parsing Models
const models = await client.getParsingModels();
console.log(models);Parse a Document
import fs from 'fs';
const fileBuffer = fs.readFileSync('drivers_license.jpg');
const result = await client.parseDocument({
model: 'light', // or 'performance'
file: fileBuffer,
fileName: 'drivers_license.jpg',
tags: {
customerId: '9999',
customerName: 'Acme Corp'
}
});
console.log(result.result.parsedData);Get Parse History
const history = await client.getParsingHistory({
limit: 25,
offset: 0,
sortBy: 'parseId',
direction: 'desc',
documentType: 'usa_driver_license'
});
console.log(history.data);Get Parse by ID
const parse = await client.getParseById(117);
console.log(parse.result);Verification
Verify User with ID and Selfie
import fs from 'fs';
const idFile = fs.readFileSync('id.jpg');
const selfieFile = fs.readFileSync('selfie.jpg');
const result = await client.verify({
idFile: idFile,
idFileName: 'id.jpg',
selfieFile: selfieFile,
selfieFileName: 'selfie.jpg',
tags: {
customerId: '9999',
customerName: 'Acme Corp'
}
});
console.log(result.result.verified);
console.log(result.result.technicalChecks);Get Verification History
const history = await client.getVerificationHistory({
limit: 25,
offset: 0,
verified: true,
sortBy: 'timestamp',
direction: 'desc'
});
console.log(history.data);Get Verification by ID
const verification = await client.getVerificationById(456);
console.log(verification.result);File Retrieval
Download a File
const fileBuffer = await client.downloadFile('fd_123_document.jpg');
fs.writeFileSync('downloaded_file.jpg', fileBuffer);Get File as Response
const response = await client.getFile('fd_123_document.jpg');
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);Type Definitions
All TypeScript types are exported from the package:
import {
FraudDetection,
DetectionResponse,
DetectionQueryParams,
APIParse,
APIParseResponse,
Verification,
VerificationResponse,
ModelMetadata,
Tag,
FileData
} from 'deepxl-node-sdk';Error Handling
The SDK throws errors with descriptive messages:
try {
const result = await client.analyzeFile({
model: 'document',
file: fileBuffer
});
} catch (error) {
console.error('Error:', error.message);
// 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 bydirection: 'asc' or 'desc' (default: 'desc')tagFilter: Filter by tags in format 'tagName=tagValue'- Various model-specific filters (see TypeScript types for details)
Tags
Tags are optional metadata that can be attached to analyses for organization and filtering:
const 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:
const history = await client.getDetectionHistory({
tagFilter: 'customerId=9999'
});