Node.js SDK — Getting Started
The Expunct Node.js SDK provides a fully typed, async client for the Expunct API with zero runtime dependencies.
Requirements
- Node.js 18 or later (uses native
fetch) - Zero runtime dependencies
Installation
npm install @pii-redactor/sdkOr with other package managers:
yarn add @pii-redactor/sdk
pnpm add @pii-redactor/sdkQuick Example
import { PiiRedactor } from '@pii-redactor/sdk';
const client = new PiiRedactor({ apiKey: 'pk_live_...' });
const result = await client.redact.text({
text: "John Smith's email is john@example.com",
});
console.log(result.redactedText);
// "[PERSON]'s email is [EMAIL_ADDRESS]"Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your API key (starts with pk_live_ or pk_test_) |
baseUrl | string | https://api.pii-redactor.dev | API base URL |
timeout | number | 30000 | Request timeout in milliseconds |
maxRetries | number | 3 | Maximum retry attempts for transient failures |
const client = new PiiRedactor({
apiKey: 'pk_live_...',
baseUrl: 'https://api.pii-redactor.dev',
timeout: 60000,
maxRetries: 5,
});Convenience Methods
The SDK provides shorthand methods for common operations:
// Redact text inline
const result = await client.sanitizeText('Call me at 555-0123');
// Redact a file (returns a job)
const job = await client.sanitizeFile('s3://my-bucket/document.pdf');
// Redact content at a URI (returns a job)
const job = await client.sanitizeUri('https://example.com/page');Next Steps
- Client reference — full client API
- Resources — detailed resource documentation
- Types — TypeScript type reference
- Errors — error handling guide