npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

emailr

v1.3.4

Published

Official Emailr API SDK for TypeScript/JavaScript

Readme

@emailr/sdk

Official Emailr API SDK for TypeScript/JavaScript.

Installation

npm install @emailr/sdk
# or
pnpm add @emailr/sdk
# or
yarn add @emailr/sdk

Quick Start

import { Emailr } from '@emailr/sdk';

const emailr = new Emailr({ apiKey: 'your-api-key' });

// Send an email
const result = await emailr.emails.send({
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Hello!',
  html: '<h1>Hello World</h1>',
});

console.log(result.message_id);

Configuration

const emailr = new Emailr({
  apiKey: 'your-api-key',
  baseUrl: 'https://api.emailr.dev', // optional
  timeout: 30000, // optional, in milliseconds
});

Resources

Emails

// Send an email
const result = await emailr.emails.send({
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Hello!',
  html: '<h1>Hello World</h1>',
  text: 'Hello World',
});

// Send with a template
const result = await emailr.emails.send({
  to: '[email protected]',
  template_id: 'template-uuid',
  template_data: { name: 'John', company: 'Acme' },
});

// Get email by ID
const email = await emailr.emails.get('email-uuid');

// List emails
const emails = await emailr.emails.list({ page: 1, limit: 50 });

Contacts

// Create a contact
const contact = await emailr.contacts.create({
  email: '[email protected]',
  first_name: 'John',
  last_name: 'Doe',
  metadata: { source: 'website' },
});

// List contacts
const contacts = await emailr.contacts.list({ limit: 100 });

// Update a contact
const updated = await emailr.contacts.update('contact-uuid', {
  first_name: 'Jane',
});

// Delete a contact
await emailr.contacts.delete('contact-uuid');

// Bulk create contacts
const result = await emailr.contacts.bulkCreate({
  contacts: [
    { email: '[email protected]', first_name: 'User 1' },
    { email: '[email protected]', first_name: 'User 2' },
  ],
});

Templates

// Create a template
const template = await emailr.templates.create({
  name: 'Welcome Email',
  subject: 'Welcome to {{company}}',
  html_content: '<h1>Welcome {{name}}</h1>',
  variables: ['name', 'company'],
});

// List templates
const templates = await emailr.templates.list();

// Update a template
const updated = await emailr.templates.update('template-uuid', {
  subject: 'New Subject',
});

// Delete a template
await emailr.templates.delete('template-uuid');

Domains

// Add a domain
const domain = await emailr.domains.add({ domain: 'example.com' });

// List domains
const domains = await emailr.domains.list();

// Verify domain
const status = await emailr.domains.verify('domain-uuid');

// Check DNS status
const dnsStatus = await emailr.domains.checkDns('domain-uuid');

// Delete a domain
await emailr.domains.delete('domain-uuid');

Webhooks

// Create a webhook
const webhook = await emailr.webhooks.create({
  name: 'Email Events',
  url: 'https://api.example.com/webhooks',
  events: ['email.sent', 'email.delivered', 'email.bounced'],
});

// List webhooks
const webhooks = await emailr.webhooks.list();

// Enable/disable webhook
await emailr.webhooks.enable('webhook-uuid');
await emailr.webhooks.disable('webhook-uuid');

// Delete a webhook
await emailr.webhooks.delete('webhook-uuid');

Broadcasts

// Create a broadcast
const broadcast = await emailr.broadcasts.create({
  name: 'Newsletter - January',
  subject: 'Your monthly update',
  from_email: '[email protected]',
  segment_id: 'segment-uuid',
  html_content: '<h1>Newsletter</h1>',
});

// Send a broadcast
const result = await emailr.broadcasts.send('broadcast-uuid');

// Schedule a broadcast
await emailr.broadcasts.schedule('broadcast-uuid', '2024-01-15T10:00:00Z');

// Cancel a scheduled broadcast
await emailr.broadcasts.cancel('broadcast-uuid');

Segments

// Create a segment
const segment = await emailr.segments.create({
  name: 'Active Users',
  description: 'Users who opened an email in the last 30 days',
  conditions: { opened_email: { within_days: 30 } },
});

// List segments
const segments = await emailr.segments.list();

// Get contacts in a segment
const contacts = await emailr.segments.getContacts('segment-uuid');

// Get segment count
const count = await emailr.segments.getCount('segment-uuid');

Error Handling

import { Emailr, EmailrError, ValidationError, RateLimitError } from '@emailr/sdk';

try {
  await emailr.emails.send({ to: 'invalid-email' });
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Validation failed:', error.message, error.details);
  } else if (error instanceof RateLimitError) {
    console.error('Rate limited. Retry after:', error.retryAfter, 'seconds');
  } else if (error instanceof EmailrError) {
    console.error('API error:', error.message, error.statusCode, error.code);
  }
}

TypeScript Support

This SDK is written in TypeScript and provides full type definitions for all API requests and responses.

import type { SendEmailRequest, Email, Contact } from '@emailr/sdk';

const request: SendEmailRequest = {
  to: '[email protected]',
  subject: 'Hello',
  html: '<h1>Hello</h1>',
};

License

MIT