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

v2-twitter

v1.0.23

Published

[![v2](https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fv2)](https://developer.twitter.com/en/docs/twitter-api) [![codecov](https://codecov.io/gh/Joao208/v2-twitter/branch/main/graph/badge.svg?token=YK3MIN9SMX)](https://code

Downloads

5

Readme

Twitter V2

v2 codecov Sonarcloud Status

Twitter api, using V2, for use, create new instance of api, no parameter is necessary, but if you don't pass BearerToken, the others params ConsumerKey, ConsumerSecret, AccessToken, AccessSecret are necessary, but you can pass all parameters

import TwitterApi from 'v2-twitter'

const twitter = new TwitterApi({
  BearerToken: "",
  ConsumerKey: "",
  ConsumerSecret: "",
  AccessToken: "",
  AccessSecret: "",
});

Get An User By Username

For get all user information's:, all parameters and fields can be consulted here

twitter
  .getUserByUsername("TwitterDev", ['profile_image_url'])
  .then((data) => console.log(data));

// {
//     "data": {
//         "id": "2244994945",
//         "name": "Twitter Dev",
//         "username": "TwitterDev"
//     }
// }

Get Many Users For Username

For get all user information's for many users:, all parameters and fields can be consulted here

twitter
  .getUsersByUsername(["TwitterDev"], ['profile_image_url'])
  .then((data) => console.log(data));

// {
//     "data": [
//         {
//             "id": "2244994945",
//             "name": "Twitter Dev",
//             "username": "TwitterDev"
//         }
//     ]
// }

Get User For UserId

For get all user information's by user id:, all parameters and fields can be consulted here

twitter
  .getUserById('2244994945', ['profile_image_url'])
  .then((data) => console.log(data));

// {
//     "data": {
//         "id": "2244994945",
//         "name": "Twitter Dev",
//         "username": "TwitterDev"
//     }
// }

Get Many Users For UserId

For get all user information's by user id for many users:, all parameters and fields can be consulted here

twitter
  .getUsersById(['2244994945'], ['profile_image_url'])
  .then((data) => console.log(data));

// {
//     "data": [
//         {
//             "id": "2244994945",
//             "name": "Twitter Dev",
//             "username": "TwitterDev"
//         }
//     ]
// }

Get Tweet By Id

For get tweet data for tweet id: all parameters and fields can be consulted here

twitter
  .getSingleTweet('2244994945', { tweet: ['text', 'id'] })
  .then((data) => console.log(data));

// {
//     "data": {
//         "id": "1461381489115947010",
//         "text": "There’s so much information in Tweets that @SPDJIndices built a stock index around them.\n\nIntroducing the S&P 500 Twitter Sentiment Index, now measuring conversations & $cashtags on the top positively talked about S&P 500 companies. #YourVoiceYourIndex 👇\n\nhttps://t.co/8aKDXpc94r https://t.co/jiIrBDQb2g"
//     }
// }

Get Many Tweets by Id

For get tweet data for many tweets id: all parameters and fields can be consulted here

twitter
  .getMultipleTweets('2244994945', { tweet: ['text', 'id'] })
  .then((data) => console.log(data));

// {
//     "data": [
//         {
//             "id": "1461381489115947010",
//             "text": "There’s so much information in Tweets that @SPDJIndices built a stock index around them.\n\nIntroducing the S&P 500 Twitter Sentiment Index, now measuring conversations & $cashtags on the top positively talked about S&P 500 companies. #YourVoiceYourIndex 👇\n\nhttps://t.co/8aKDXpc94r https://t.co/jiIrBDQb2g"
//         }
//     ]
// }

Get User Timeline By UserId

For get timeline of user by user id: all parameters and fields can be consulted here

twitter
  .getTimelineByUserId('2244994945', { tweet: ['text', 'id'] })
  .then((data) => console.log(data));

// {
//     "data": [
//         {
//             "id": "1461381489115947010",
//             "text": "There’s so much information in Tweets that @SPDJIndices built a stock index around them.\n\nIntroducing the S&P 500 Twitter Sentiment Index, now measuring conversations & $cashtags on the top positively talked about S&P 500 companies. #YourVoiceYourIndex 👇\n\nhttps://t.co/8aKDXpc94r https://t.co/jiIrBDQb2g"
//         }
//     ],
//     "meta": {
//         "oldest_id": "1460323748788072449",
//         "newest_id": "1461381489115947010",
//         "result_count": 10,
//         "next_token": "7140dibdnow9c7btw3z3al3eejvt8u5twuupa4vswh54p"
//     }
// }

Create new Tweet

🚨 For post/create new Tweet is necessary oauth login and write access 🚨 For create new tweet: all parameters and fields can be consulted here

twitter
  .createTweet('2244994945', { tweet: ['text', 'id'] })
  .then((data) => console.log(data));

// {
//     "data": {
//         "id": "1461897194655600647",
//         "text": "Hello!"
//     }
// }

Delete Tweet by Id

🚨 For delete Tweet is necessary oauth login and write access 🚨 For delete tweet:

twitter
  .deleteTweet('2244994945')
  .then((data) => console.log(data));

// {
//     "data": {
//         "deleted": true
//     }
// }

Get Followers By UserId

For get all followers for user by id: all parameters and fields can be consulted here

twitter
  .getFollowersById('2244994945', { max:10 })
  .then((data) => console.log(data));

// {
//     "data": [
//         {
//             "id": "2244994945",
//             "name": "Twitter Dev",
//             "username": "TwitterDev"
//         }
//     ],
//     "meta": {
//         "result_count": 100,
//         "next_token": "76NGG1H6J79HEZZZ"
//     }
// }

Follow User

🚨 For follow user is necessary oauth login and write access 🚨 Your id on the left, and id to follow in right For follow a user:

twitter
  .followUserId('2244994945', '2244994945')
  .then((data) => console.log(data));

// {
//     "data": {
//         "following": true,
//         "pending_follow": false
//     }
// }

Unfollow User

🚨 For unfollow user is necessary oauth login and write access 🚨 Your id on the left, and id to unfollow in right For unfollow a user:

twitter
  .unfollowUserId('2244994945', '2244994945')
  .then((data) => console.log(data));

// {
//     "data": {
//         "following": false
//     }
// }

Follow User By Username

🚨 For this method necessary oauth login, bearer token and write access 🚨 Your username on the left, and username to follow in right For unfollow a user by username:

twitter
  .followUsername('TwitterDev', 'TwitterDev')
  .then((data) => console.log(data));

// {
//     "data": {
//         "following": true,
//         "pending_follow": false
//     }
// }

Unfollow User By Username

🚨 For this method necessary oauth login, bearer token and write access 🚨 Your username on the left, and username to unfollow in right For unfollow a user by username:

twitter
  .unfollowUsername('TwitterDev', 'TwitterDev')
  .then((data) => console.log(data));

// {
//     "data": {
//         "following": false
//     }
// }

V1.1 API Support

This module does not support previous versions of the Twitter API, however it works well with the following V1.1 modules

NPM

NPM

More methods will come...