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

twitter-api-suite

v0.0.6

Published

Twitter API client for Node.js

Readme

twitter-api-suite

Twitter API client for Node.js.

This library provides convenient access to the Twitter API from applications written in Node.js. It only supports the REST API at this moment. Support for Streaming, Enterprise and Ads APIs will be added soon.

Documentation

Read the official Twitter documentation to learn more about API endpoints.

Installation

npm install twitter-api-suite --save

Usage

Initialize with config object

The package needs to be configured with OAuth tokens. You need a Twitter developer account to create apps and generate tokens. Apply here if you don't have one yet.

const Twitter = require('twitter-api-suite');

const twitter = new Twitter({
    consumer_key: process.env.CONSUMER_KEY,
    consumer_secret: process.env.CONSUMER_SECRET,
    access_token: process.env.ACCESS_TOKEN,
    access_token_secret: process.env.ACCESS_TOKEN_SECRET
});

Or, when configuring the package with an application-only context:

const Twitter = require('twitter-api-suite');

const twitter = new Twitter({
    consumer_key: process.env.CONSUMER_KEY,
    consumer_secret: process.env.CONSUMER_SECRET,
    app_only: true
});

Methods

REST API Requests

twitter.get(endpoint, params, append_response)

Performs a GET request to the Twitter API.

twitter.post(endpoint, params, append_response)

Performs a POST request to the Twitter API.

twitter.put(endpoint, params, append_response)

Performs a PUT request to the Twitter API.

twitter.del(endpoint, params, append_response)

Performs a DELETE request to the Twitter API.

Parameters

  • endpoint

    API endpoint to call. For instance users/show. List of all endpoints can be found here.

  • params (optional)

    Parameters to pass to the request.

  • append_response (optional)

    Boolean, defaults to false. If set to true, data returned in Promises has an additional _response property corresponding to the raw HTTP response received from Twitter, including x-rate-limit-* headers.

Media upload

twitter.upload(params, append_response)

Implements the full logic (INIT, APPEND, FINALIZE, STATUS) of uploading media files through POST media/upload (chunked). The params object must have media_path which is the absolute path to the media file you want to upload. When uploading large files such as videos, the function returns when the media has been processed by Twitter (succeeded or failed).

const params = {
    media_path: 'path/to/file.mp4'
}

Supported types and limits:

  • Image: 5MB (.png, .jpg, .jpeg, .webp)
  • Video: 512MB (.mp4)
  • GIF: 15MB (.gif)

Examples

Every method returns a chainable Promise.

const Twitter = require('twitter-api-suite');

const twitter = new Twitter({
    consumer_key: process.env.CONSUMER_KEY,
    consumer_secret: process.env.CONSUMER_SECRET,
    access_token: process.env.ACCESS_TOKEN,
    access_token_secret: process.env.ACCESS_TOKEN_SECRET
});

twitter.get('users/show', {
    screen_name: 'b_lw'
}).then((user) => {
    return twitter.post('friendships/create', {
        user_id: user.id_str
    });
}).then(() => {
    return twitter.upload({
        media_path: 'video.mp4'
    });
}).then((media_data) => {
    return twitter.post('statuses/update', {
        status: 'Hello world',
        media_ids: media_data.media_id_string
    });
}).then((tweet_data) => {
    console.log('Tweet ID', tweet_data.id_str);
}).catch((err) => {
    console.log(err);
});

Contributing

Contributions for new features, enhancements and bug fixes are welcome. When contributing to this repository, please first discuss the change you wish to make via issue or email before you submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

  • Benoit Lewandowski - @b_lw

See also the list of contributors who participated in this project.