1.1.0 • Published 5 years ago

tweet-fetch v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Tweet-Fetch

GitHub license Build Status Coveralls github

Get Tweet data by URL and ID from Twitter in NodeJS with using the twitter token.

const TweetFetch = require("tweet-fetch")

const tweetFetch = new TweetFetch({
  consumer_key: '',
  consumer_secret: '',
  access_token_key: '',
  access_token_secret: ''
})

tweetFetch.get('TWEET_URL')
  .then(res => {
    console.log(res)
  })

Installation

npm install tweet-fetch

or

yan add tweet-fetch

Quick Start

You will need valid Twitter developer credentials in the form of a set of consumer and access tokens/keys. You can get these here.

const TweetFetch = require('tweet-fetch');

For User based authentication:

const tweetFetch = new TweetFetch({
  consumer_key: '',
  consumer_secret: '',
  access_token_key: '',
  access_token_secret: ''
});

Add your credentials accordingly. I would use environment variables to keep your private info safe. So something like:

const tweetFetch = new TweetFetch({
  consumer_key: process.env.TWITTER_CONSUMER_KEY,
  consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
  access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
  access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
});

Usage

Get tweet

Returns Tweet full text with data

tweetFetch.get('TWEET_URL')
  .then(res => {
    console.log(res)
  })

Get embedded tweet

Returns a single Tweet, specified by either a Tweet web URL or the Tweet ID, in an oEmbed-compatible format.

tweetFetch.getOembed('TWEET_URL')
  .then(res => {
  console.log(res)
  })

Get tweet data

Return Tweet JSON. Each Tweet has an author, a message, a unique ID, a timestamp of when it was posted, and sometimes geo metadata shared by the user. Each User has a Twitter name, an ID, a number of followers, and most often an account bio.With each Tweet we also generate "entity" objects, which are arrays of common Tweet contents such as hashtags, mentions, media, and links. If there are links, the JSON payload can also provide metadata such as the fully unwound URL and the webpage’s title and description.

tweetFetch.getData('TWEET_URL')
  .then(res => {
    console.log(res)
  })

License

MIT © Jalal Azimi

1.1.0

5 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.0

6 years ago