parserator-sdk
v1.0.0
Published
Official Node.js SDK for Parserator - Intelligent data parsing using the Architect-Extractor pattern
Maintainers
Readme
Parserator Node.js SDK
Intelligent data parsing using the revolutionary Architect-Extractor pattern
Transform any unstructured data into clean, structured JSON with AI-powered precision. The Parserator SDK implements a sophisticated two-stage LLM approach that maximizes accuracy while minimizing token costs.
<� The Architect-Extractor Revolution
Parserator uses a groundbreaking two-LLM approach that outperforms traditional single-model parsing:
<� The Architect (LLM 1)
- Job: Create a detailed parsing plan
- Input: Your desired schema + small data sample (~1000 chars)
- Output: Structured
SearchPlanwith precise extraction instructions - Benefit: Complex reasoning on minimal data = ultra-low token cost
� The Extractor (LLM 2)
- Job: Execute the parsing plan
- Input: Full data + the Architect's
SearchPlan - Output: Final structured JSON, validated against the plan
- Benefit: Direct execution with minimal "thinking" = maximum efficiency
Result: 70% reduction in token usage while achieving 95%+ accuracy rates.
=� Quick Start
Installation
npm install @parserator/node-sdkBasic Usage
const { ParseratorClient } = require('@parserator/node-sdk');
const client = new ParseratorClient({
apiKey: 'pk_live_your_api_key_here'
});
const result = await client.parse({
inputData: `
John Smith
Senior Developer
[email protected]
(555) 123-4567
`,
outputSchema: {
name: 'string',
title: 'string',
email: 'email',
phone: 'phone'
}
});
console.log(result.parsedData);
// {
// name: "John Smith",
// title: "Senior Developer",
// email: "[email protected]",
// phone: "(555) 123-4567"
// }Quick Parse Helper
const { quickParse } = require('@parserator/node-sdk');
const result = await quickParse(
'pk_live_your_api_key_here',
'Raw unstructured data here...',
{ name: 'string', email: 'email' },
'Extract contact information'
);=� Key Features
- > Two-Stage AI Processing: Architect-Extractor pattern for maximum efficiency
- =� Token Optimization: 70% reduction in token costs vs traditional parsing
- <� High Accuracy: 95%+ parsing accuracy on structured and semi-structured data
- � Batch Processing: Process multiple documents concurrently
- =� Pre-built Presets: Optimized schemas for emails, invoices, contacts, logs
- = TypeScript Ready: Full type definitions included
- =� Error Handling: Comprehensive error types and retry logic
- =� Usage Analytics: Track token usage and performance metrics
=� API Reference
ParseratorClient
const client = new ParseratorClient({
apiKey: 'pk_live_...', // Required: Your API key
baseUrl: 'https://api.parserator.com', // Optional: Custom API URL
timeout: 30000, // Optional: Request timeout (ms)
retries: 3, // Optional: Max retry attempts
debug: false // Optional: Enable debug logging
});parse(request)
const result = await client.parse({
inputData: 'string', // The unstructured data to parse
outputSchema: {}, // Desired JSON structure
instructions: 'string', // Optional: Additional context
options: {
timeout: 45000, // Request timeout override
validateOutput: true, // Validate against schema
confidenceThreshold: 0.8 // Minimum confidence (0-1)
}
});batchParse(request, progressCallback?)
const result = await client.batchParse({
items: [/* array of parse requests */],
options: {
concurrency: 3, // Parallel processing limit
failFast: false, // Stop on first error
preserveOrder: true // Keep input order
}
}, (progress) => {
console.log(`${progress.completed}/${progress.total} completed`);
});=� Examples
Email Processing
const { EMAIL_PARSER } = require('@parserator/node-sdk');
const result = await client.parse({
inputData: `
From: [email protected]
Subject: Q1 Review Meeting
Hi team, let's schedule our Q1 review for Friday at 2 PM.
Action items:
- John: Prepare sales presentation
- Sarah: Update financial forecasts
`,
outputSchema: EMAIL_PARSER.outputSchema,
instructions: EMAIL_PARSER.instructions
});
console.log(result.parsedData.action_items);
// ["John: Prepare sales presentation", "Sarah: Update financial forecasts"]Invoice Processing
const result = await client.parse({
inputData: `
INVOICE #INV-2024-001
Date: January 15, 2024
Bill To: Acme Corporation
Web Development: 40 hrs @ $150/hr = $6,000
Tax (8.5%): $510
Total: $6,510
`,
outputSchema: {
invoice_number: 'string',
date: 'iso_date',
client: 'string',
line_items: 'object',
subtotal: 'number',
tax: 'number',
total: 'number'
}
});Batch Processing
const documents = [
{ inputData: 'Contact 1...', outputSchema: contactSchema },
{ inputData: 'Invoice 1...', outputSchema: invoiceSchema },
{ inputData: 'Email 1...', outputSchema: emailSchema }
];
const batchResult = await client.batchParse({
items: documents,
options: { concurrency: 3 }
});
console.log(`Processed ${batchResult.summary.successful} items`);=K
B Support
- Documentation: parserator.com/docs
- API Reference: parserator.com/docs/api
- Examples: View Examples
- Issues: GitHub Issues
- Email: [email protected]
Built with d by the Parserator team - Transform your unstructured data into structured gold. (
