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

rettiwt-auth

v2.1.0

Published

A CLI tool for authenticating against Twitter API

Downloads

5,841

Readme

Rettiwt-Auth

A CLI tool for authenticating against Twitter API

Prerequisites

  • NodeJS 20.x

Installation

The package is intended to be installed globally.

  • For installation via npm, use the command: npm install -g rettiwt-auth
  • For installation via yarn, use the command: yarn global add rettiwt-auth

Types of authentication

The following are the two types of authentcation methods available, with each method providing access to different set of resources:

  1. Guest Authentication, with which, the following resources can be accessed:
    • Tweet Details
    • User Details
    • User Tweets
    • User Tweets and Replies
  2. User Authentication, with which, the following resources can be accessed:
    • Create Tweet
    • Create Retweet
    • Favorite Tweet
    • List Details
    • List Tweets
    • Media Upload
    • Space Details
    • Tweet Details
    • Tweet Likes
    • Tweet Retweets
    • Tweet Search
    • User Details
    • User Followers
    • User Following
    • User Likes
    • User Tweets
    • User Tweets and Replies
    • Video Stream

Getting started

The following examples demonstrate authenticating against Twitter API and generating the credentials.

1. Generating an API key (for use with Rettiwt-API)

  1. Install the package globally by following the steps in the 'Installation' section.

  2. Open a commandline/shell and use the command:
    rettiwt-auth user <email> <username> <password>

    Where,

    • <email> is the email to the Twitter account.
    • <username> is the username associated with the Twitter account.
    • <password> is the password to the Twitter account.
  3. Store the generated API key in a safe spot for later use.

2. Generating credentials as HTTP headers (for use with third-party scripts)

  1. Install the package globally by following the steps in the 'Installation' section.

  2. Open a commandline/shell and use the command:
    rettiwt-auth user -h <email> <username> <password>

    Where,

    • <email> is the email to the Twitter account.
    • <username> is the username associated with the Twitter account.
    • <password> is the password to the Twitter account.

    The -h option specifies the CLI to generate the credentials as HTTP headers.

  3. Store the generated API key in a safe spot for later use.

  4. For authenticating the requests to Twitter, append the headers to outgoing HTTP requests.

Using a proxy

In order to use a proxy while creating either 'guest' or 'user' credentials, use the option -p <URL_to_proxy> or --proxy <URL_to_proxy> to specify the proxy server to use. The following snippet demonstrates using a proxy for generating 'user' credentials:

rettiwt-auth user -p <URL> <email> <username> <password>

Where,

  • <URL> is he URL to the proxy server to use.
  • <email> is the email to the Twitter account.
  • <username> is the username associated with the Twitter account.
  • <password> is the password to the Twitter account.

Additional CLI options

  • To get a list of all commands available, use the command:
    rettiwt-auth help

  • To check the description of single command, use the command:
    rettiwt-auth help <command_name>

    Where,

    • <command_name> is the name of a specific command from the list of available commands

Credential Validity

When you generate the credentials as API key/HTTP headers,

  • The generated API key/HTTP headers are valid for a duration of 1 year, starting from the day of generation.

  • As such, it is suggested to generated the API key/HTTP headers once, then store them in a safe place (such as in an environment variable or a JSON file).

    Notes:

    • Repeated logins might trigger Twitter's anti-bot measures and you might be required to verify yourself as human by logging in from the browser, before being able to use the package again.
    • Therefore make sure to always generate the API key/HTTP headers only once and use it till it expires, before generating a new API key/authentication credential.
  • Whenever it is required to authenticate against Twitter API, use the stored API key/HTTP headers.