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

@jquintanadev/mailerlite-sdk

v0.0.4

Published

The `@jquintanadev/mailerlite-sdk` library provides a simple and efficient way to interact with the MailerLite API. Designed for scalability and ease of use, it encapsulates all API interactions, making it ideal for projects that require newsletter and ca

Readme

MailerLite SDK

The @jquintanadev/mailerlite-sdk library provides a simple and efficient way to interact with the MailerLite API. Designed for scalability and ease of use, it encapsulates all API interactions, making it ideal for projects that require newsletter and campaign management.

Building

Run nx build mailerlite-sdk to build the library.

Running unit tests

Run nx test mailerlite-sdk to execute the unit tests via Jest.

Benefits

Using the mailerlite-sdk library provides the following benefits:

  1. Centralized Logic: Encapsulates all interactions with the MailerLite API, reducing code duplication across projects.
  2. Reusability: Can be used in multiple applications within the monorepo or external projects.
  3. Error Handling: Provides consistent error handling for API interactions.
  4. Ease of Use: Simplifies the integration with MailerLite by abstracting API details.
  5. Scalability: Designed to support future API changes and additional features.

Setting Up Credentials

To use the @jquintanadev/mailerlite-sdk, you need to configure your MailerLite API key. Follow these steps:

  1. Obtain Your API Key:

    • Log in to your MailerLite account.
    • Navigate to the Integrations section.
    • Generate or copy your API key.
  2. Store the API Key Securely:

    • Create a .env file in the root of your project (if it doesn't already exist).
    • Add the following line to the .env file:
      MAILERLITE_API_KEY=your-api-key-here
  3. Load the API Key in Your Application:

    • Use a library like dotenv to load the environment variables:
      import dotenv from 'dotenv';
      dotenv.config();
      
      import { setApiKey } from '@jquintanadev/mailerlite-sdk';
      
      setApiKey(process.env.MAILERLITE_API_KEY || '');
  4. Verify the Configuration:

    • Ensure the API key is loaded correctly before making any API calls.

Encapsulated Methods

The SDK will include the following methods:

Subscriber Management

  • addSubscriber(listId: string, subscriber: Subscriber): Promise<Response>: Adds a new subscriber to a specific list.
  • updateSubscriber(subscriberId: string, data: Partial<Subscriber>): Promise<Response>: Updates an existing subscriber.
  • deleteSubscriber(subscriberId: string): Promise<Response>: Removes a subscriber.

List Management

  • getLists(): Promise<List[]>: Retrieves all available lists.
  • getListDetails(listId: string): Promise<List>: Fetches details of a specific list.

Campaign Management

  • createCampaign(data: Campaign): Promise<Response>: Creates a new campaign.
  • sendCampaign(campaignId: string): Promise<Response>: Sends a campaign to the specified list.

Utility Methods

  • setApiKey(apiKey: string): void: Configures the API key for authentication.
  • handleApiError(error: any): void: Handles and logs API errors consistently.

Publishing

To publish the mailerlite-sdk library to npm, follow these steps:

  1. Build the library:

    npx nx build mailerlite-sdk
  2. Increment the version (e.g., patch):

    npm version patch --workspaces
  3. Publish the library:

    npx nx run mailerlite-sdk:nx-release-publish

Ensure you are authenticated with npm and have the correct permissions to publish under the @jquintanadev scope.

Examples

Adding a Subscriber

import { addSubscriber } from '@jquintanadev/mailerlite-sdk';

const subscriber = {
  email: '[email protected]',
  name: 'John Doe',
};

addSubscriber('list-id', subscriber)
  .then(response => console.log('Subscriber added:', response))
  .catch(error => console.error('Error adding subscriber:', error));

Fetching Lists

import { getLists } from '@jquintanadev/mailerlite-sdk';

getLists()
  .then(lists => console.log('Available lists:', lists))
  .catch(error => console.error('Error fetching lists:', error));

Creating a Campaign

import { createCampaign } from '@jquintanadev/mailerlite-sdk';

const campaign = {
  title: 'New Campaign',
  content: '<h1>Hello World</h1>',
};

createCampaign(campaign)
  .then(response => console.log('Campaign created:', response))
  .catch(error => console.error('Error creating campaign:', error));

Future Enhancements

  • Support for additional MailerLite API endpoints.
  • Improved caching for frequently accessed data.
  • Integration with analytics tools for campaign tracking.