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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tempmail.lol

v4.1.0

Published

API to generate temporary email addresses.

Downloads

6,676

Readme

TempMail.lol JS API

This is an API for the temporary email service TempMail.lol.

If you are using a BananaCrumbs ID/Token and have not migrated, install version 3.1.0 instead of 4.x.x!

Upgrading from 3.1.0

The key difference between 3.1.0 and 4.0.0 is the fact that the constructor only accepts an API Key, and not a BananaCrumbs ID.

The custom domain method has changed as well as the createInbox method's parameters.

Upgrading from 2.0.3

The version 3.0.0+ is vastly different from the old version of the API. Please read the changes before using the new version of the API.

Version 2.0.3 still works, but does not have support for custom domains or TempMail Plus. Note that v2 support may be dropped at any time, so please upgrade your applications as soon as possible.

Installation

npm i tempmail.lol
# or, if you use yarn
yarn add tempmail.lol

This has built-in types.

Usage

First, create a TempMail object:

const tempmail = new TempMail();

//if you have a TempMail Plus/Ultra account, you can add it here:
const tempmail = new TempMail("API Key");

Types

Email:

type Email = {
    from: string,
    to: string,
    subject: string,
    body: string,
    html: string | null, //only if the email is HTML
    date: number, //date in unix millis
    ip: string, //IP address of sender
}

Inbox:

type Inbox = {
    address: string, //address of inbox
    token: string, //token to use for checkInbox
}

Create inbox

To create an inbox:


//simply, you can use the following function
tempmail.createInbox().then(inbox => {
    console.log(`Inbox: ${inbox.address} with a token of ${inbox.token}`);
});

//Or as async
const inbox: Inbox = await tempmail.createInbox();

//there are some advanced options as well

//whether or not to create a community address
tempmail.createInbox({
    community: false,
    domain: "cooldomain.com",
    prefix: "optional",
});

Note that all inboxes expire after 30 minutes since last check, with a hard expiry limit of one hour that cannot be bypassed.

TempMail Plus subscribers can extend this to TEN hours, but the 30-minute check rule still applies.

Retrieve emails

To get the emails in an inbox:


//you can also pass through the Inbox object instead of the token string
const emails = tempmail.checkInbox("<TOKEN>").then((emails) => {
    if(!emails) {
        console.log(`Inbox expired since "emails" is undefined...`);
        return;
    }
    
    console.log(`We got some emails!`);
    
    for(let i = 0; i < emails.length; i++) {
        console.log(`email ${i}: ${JSON.stringify(emails[i])}`);
    }
});

Custom Domains

Note: you will need to be a TempMail Plus/Ultra subscriber to use custom domains!

Old Custom Domains (v1)

tempmail.checkCustomDomainLegacy("example.com", "token").then(emails => {
    emails.forEach(e => {
        console.log("Email from: " + e.from + " to " + e.to);
    });
});

You can obtain a token by visiting https://tempmail.lol/custom.html

Custom domains will NOT alert you if the token is invalid.

New Custom Domains (v2)

tempmail.checkV2CustomDomain("example.com").then(emails => {
    emails.forEach(e => {
        console.log("Email from: " + e.from + " to " + e.to);
    });
});

To setup this, visit your account on https://accounts.tempmail.lol and migrate if you have not already.

Webhooks

You can set up a webhook to be called when an email is received.

tempmail.setWebhook("https://example.com/webhook").then(() => {
    console.log("Webhook set!");
});

You can also remove the webhook:

tempmail.removeWebhook().then(() => {
    console.log("Webhook removed!");
});

This feature is only available to TempMail Ultra subscribers. Any email created after setting the webhook will trigger the webhook. The email will not be returned in the checkInbox function.

Failed webhooks will not be retried unless a 429 Too Many Requests error is returned.

Webhooks will send data in a JSON format as an array of Email objects.