Node.js SDK
The official Node.js SDK for the Generator Labs API v4.0. Written in TypeScript with full type definitions included.
| Package | generatorlabs (npm) |
| Minimum version | Node.js 18+ |
| Language | TypeScript (full type definitions included) |
| HTTP client | axios |
| GitHub | generator-labs/node-sdk |
Installation
npm install generatorlabs
Or with Yarn:
yarn add generatorlabs
Usage
import { Client } from 'generatorlabs';
const client = new Client('your_account_sid', 'your_auth_token');
// Get a single host
const host = await client.rbl.hosts.get('host_id');
// List all hosts with automatic pagination
const hosts = await client.rbl.hosts.getAll();
// Create a certificate monitor
const monitor = await client.cert.monitors.create({
name: 'example.com',
});
CommonJS imports are also supported:
const { Client } = require('generatorlabs');
Configuration
const client = new Client('your_account_sid', 'your_auth_token', {
timeout: 45000,
maxRetries: 5,
retryBackoff: 2.0,
});
| Option | Default | Description |
|---|---|---|
timeout | 30000 | Total request timeout in milliseconds |
maxRetries | 3 | Maximum number of retry attempts |
retryBackoff | 1.0 | Backoff multiplier between retries |
Webhook Verification
import { Webhook } from 'generatorlabs';
Webhook.verify(body, signatureHeader, secret, tolerance);
See Using Web Hooks for more details on webhook payloads and signature verification.
Error Handling
The Node.js SDK throws Exception errors that you can catch with standard try / catch:
import { Client, Exception } from 'generatorlabs';
try {
const host = await client.rbl.hosts.get('host_id');
} catch (err) {
if (err instanceof Exception) {
console.error(err.message);
}
}
Rate Limit Information
Rate limit details are available on every response:
console.log(response.rateLimitInfo.remaining);
console.log(response.rateLimitInfo.reset);
See What Are the API Rate Limits? for more information.