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

swamp-thing

v0.1.0

Published

A better Twitter client

Downloads

25

Readme

Swamp Thing

A better Twitter client.

What is this?

It's a Twitter client, like node-twitter or twit, but with some key differences:

  • Endpoints are exposed as methods. No more spelunking through Twitter's documentation — just use Intellisense. It's much easier!
  • Sensible defaults — e.g. stringify_ids and dnt (privacy setting) default to true, and count defaults to the maximum value
  • undefined and null values are omitted from queries, so you don't have to conditionally add parameters like max_id. Just do max_id: null (this is a really dumb gotcha with the Twitter API that has wasted a lot of my time)
  • Helper functions like decrement, for subtracting 1 from ID strings

Limitations

  • It is unfinished. Only GET requests for now, and a few endpoints are missing

Usage

import { Client, decrement } from 'swamp-thing';

const client = new Client({
	"consumer_key": "A_CONSUMER_KEY",
	"consumer_secret": "A_CONSUMER_SECRET",
	"access_token_key": "AN_ACCESS_TOKEN_KEY",
	"access_token_secret": "AN_ACCESS_TOKEN_SECRET"
});

async function get_all_tweets(screen_name) {
	const tweets = [];
	let max_id = null;

	while (true) {
		const chunk = await client.get.statuses.user_timeline({
			screen_name,
			max_id
		});

		if (chunk.length === 0) return tweets;

		tweets.push(...chunk);

		const { id_str } = chunk.pop();
		max_id = decrement(id_str);
	}
}

get_all_tweets('rich_harris').then(tweets => {
	console.log('these are bad tweets:', tweets);
});

You can also create iterators for paging through responses:

import { Client } from 'swamp-thing';

const client = new Client(credentials);

async function get_all_tweets(screen_name) {
	const iterator = client.iterator.get.statuses.user_timeline({ screen_name });
	const tweets = [];

	while (true) {
		const { done, value } = await iterator.next();
		if (done) return tweets;
		tweets.push(...value);
	}
}

get_all_tweets('rich_harris').then(tweets => {
	console.log('these are bad tweets:', tweets);
});

Client pools

If you need to access large amounts of data from the Twitter API, you are likely to hit rate limits. You can circumvent these limits by pooling clients and rotating through them. Swamp Thing automates this process.

import { Pool, decrement } from 'swamp-thing';

const pool = new Pool([
	{
		"consumer_key": "A_CONSUMER_KEY",
		"consumer_secret": "A_CONSUMER_SECRET",
		"access_token_key": "AN_ACCESS_TOKEN_KEY",
		"access_token_secret": "AN_ACCESS_TOKEN_SECRET"
	},
	{
		"consumer_key": "A_CONSUMER_KEY",
		"consumer_secret": "A_CONSUMER_SECRET",
		"access_token_key": "AN_ACCESS_TOKEN_KEY",
		"access_token_secret": "AN_ACCESS_TOKEN_SECRET"
	},
	{
		"consumer_key": "A_CONSUMER_KEY",
		"consumer_secret": "A_CONSUMER_SECRET",
		"access_token_key": "AN_ACCESS_TOKEN_KEY",
		"access_token_secret": "AN_ACCESS_TOKEN_SECRET"
	},
	// ...
]);

After the pool has been created, it has the same API as a regular client.

Why the name?

Because Twitter is a fetid swamp.

License

LIL