fetch-timeline
Fetch Twitter user timeline using a readable stream
Last updated 4 months ago by kikobeats .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fetch-timeline 
SYNC missed versions from official npm registry.

fetch-timeline

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status Donate

Fetch Twitter user timeline using a readable stream.

Twitter API expose and endpoint called statuses/usertimeline to get the last Twitter users tweets, but is necessary concat the HTTP request to get more to 200 tweets per call (max to 3200).

This module encapsulate the logic to concatenate the HTTP requests.

Install

npm install fetch-timeline --save

Usage

const fetchTimeline = require('fetch-timeline')

const params = {
  screenName: 'kikobeats',
  count: 200
}

const opts = {
  credentials: {
    consumerKey: process.env.TWITTER_CONSUMER_KEY,
    consumerSecret: process.env.TWITTER_CONSUMER_SECRET,
    accessToken: process.env.TWITTER_ACCESS_TOKEN,
    accessTokenSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET
  },
  limit: 3200,
  limitDays: 7
}

const stream = fetchTimeline(params, opts) // => Readable Stream

stream.on('data', (tweet, index) => {
  console.log(`#${++index} ${tweet.text}`)
})

The events available are:

.on('data')

Fire with each tweet fetched from the API endpoint.

.on('info')

Fired at the end of the timeline fetch process with meta information, such as:

{
  "user": "Object",
  "apiCalls": "Number",
  "count": "Number",
  "newerTweetDate": "Date",
  "olderTweetDate": "Date",
}

The rest of the readable event (error, end,...) have the expected behavior.

API

fetchTimeline(params, opts)

params

Represents the params necessary for setup the Twitter endpoint statuses/usertimeline for the API requests.

You need to specify the params using camelCase instead of snakeCase.

The library internally manage the cursor between successive API calls.

opts

credentials

Type: object

Represents the twit#credentials to connect with Twitter API.

limitDays

Type: number

Don't retrieve more older tweets than the number of days using Date.now() as baseline.

limit

Type: number

Use this value when you want to finish the process early, limiting the number of tweets to be fetched.

Examples

See fetch-timeline-cli#bin.

Related

License

MIT © Kiko Beats

Current Tags

  • 1.2.0                                ...           latest (4 months ago)

14 Versions

  • 1.2.0                                ...           4 months ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.3.4                                ...           4 years ago
  • 0.3.3                                ...           4 years ago
  • 0.3.2                                ...           4 years ago
  • 0.3.1                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (6)

Copyright 2014 - 2017 © taobao.org |