TypeScript / Node.js SDK
Official TypeScript SDK for ReachScore with full type definitions.
Installation
npm install @reachscore/sdk
# or
yarn add @reachscore/sdk
# or
pnpm add @reachscore/sdkQuick Start
example.tstypescript
12345678910111213141516import { ReachScore } from '@reachscore/sdk'; const client = new ReachScore({ apiKey: process.env.REACHSCORE_API_KEY, }); // Create a test const test = await client.tests.create({ fromAddress: 'hello@yourdomain.com', subject: 'Welcome to our platform', htmlBody: '<h1>Hello!</h1>', providers: ['gmail', 'outlook'], }); console.log('Test ID:', test.id); console.log('Score:', test.score);
Configuration Options
const client = new ReachScore({
apiKey: process.env.REACHSCORE_API_KEY,
// Optional: custom base URL for self-hosted
baseUrl: 'https://api.reachscore.co/v1',
// Optional: request timeout in milliseconds
timeout: 30000,
// Optional: number of retries for failed requests
maxRetries: 3,
});Available Resources
| Resource | Description |
|---|---|
| client.tests | Create and manage deliverability tests |
| client.domains | Domain verification and health checks |
| client.monitors | Scheduled monitoring jobs |
| client.webhooks | Webhook endpoint management |
| client.alerts | Alert rules and notifications |
Error Handling
import { ReachScore, ReachScoreError } from '@reachscore/sdk';
try {
const test = await client.tests.create({ ... });
} catch (error) {
if (error instanceof ReachScoreError) {
console.error('API Error:', error.message);
console.error('Error Code:', error.code);
console.error('Request ID:', error.requestId);
}
}