@pramit.dev/sdk
v0.3.0
Published
Official Node.js SDK for the Pramit India Compliance API
Maintainers
Readme
@pramit.dev/sdk
Official Node.js SDK for the Pramit India Compliance API.
Install
npm install @pramit.dev/sdkQuick Start
import { Pramit } from "@pramit.dev/sdk";
const pramit = new Pramit({ apiKey: "pk_live_your_key_here" });
// Analyze a contract (async — waits for result)
const analysis = await pramit.analyzeContractSync(contractText);
console.log(analysis.overall_risk_score); // "LOW" | "MEDIUM" | "HIGH" | "CRITICAL"
console.log(analysis.flagged_clauses);
// Extract invoice data (async — waits for result)
const invoice = await pramit.extractInvoiceSync(base64Data, "image/png");
console.log(invoice.total);
console.log(invoice.line_items);
console.log(invoice._meta?.state_analysis); // CGST/SGST vs IGST
// GSTIN lookup (instant, cached)
const { data } = await pramit.lookupGstin("29AABCT1234F1ZP");
console.log(data.legal_name);
console.log(data.state); // "Karnataka"Async Pattern
AI endpoints are async. The SDK handles polling for you:
// Option 1: Fire and forget — use webhooks
const { jobId } = await pramit.analyzeContract(text, {
webhookUrl: "https://your-app.com/webhooks/pramit",
});
// Option 2: Sync wrapper — blocks until result
const result = await pramit.analyzeContractSync(text);
// Option 3: Manual polling
const { jobId } = await pramit.analyzeContract(text);
const job = await pramit.waitForJob(jobId, {
pollInterval: 2000,
maxAttempts: 30,
});Error Handling
import { Pramit, PramitError } from "@pramit.dev/sdk";
try {
const result = await pramit.analyzeContractSync(text);
} catch (err) {
if (err instanceof PramitError) {
console.error(err.code); // "RATE_LIMITED", "INVALID_INPUT", etc.
console.error(err.status); // 429, 400, etc.
console.error(err.requestId); // for support
}
}API Reference
new Pramit(config)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | required | Your Pramit API key |
| baseUrl | string | https://api.pramit.dev | API base URL |
| timeout | number | 30000 | Request timeout in ms |
Methods
| Method | Returns | Description |
|--------|---------|-------------|
| analyzeContract(text, options?) | { jobId } | Submit contract for analysis |
| analyzeContractSync(text, options?) | ContractAnalysis | Submit and wait for result |
| extractInvoice(base64, mime, options?) | { jobId } | Submit invoice for extraction |
| extractInvoiceSync(base64, mime, options?) | InvoiceExtraction | Submit and wait for result |
| lookupGstin(gstin) | { data, cached } | GSTIN details lookup |
| getJob(jobId) | Job | Check job status |
| waitForJob(jobId, options?) | Job | Poll until complete |
