v2-twitter
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.23 • Public • Published

    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...

    Keywords

    none

    Install

    npm i v2-twitter

    DownloadsWeekly Downloads

    14

    Version

    1.0.23

    License

    MIT

    Unpacked Size

    50.3 kB

    Total Files

    19

    Last publish

    Collaborators

    • foodzillabr