twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

package.json (22241B)


      1 {
      2   "_from": "twit",
      3   "_id": "twit@2.2.11",
      4   "_inBundle": false,
      5   "_integrity": "sha512-BkdwvZGRVoUTcEBp0zuocuqfih4LB+kEFUWkWJOVBg6pAE9Ebv9vmsYTTrfXleZGf45Bj5H3A1/O9YhF2uSYNg==",
      6   "_location": "/twit",
      7   "_phantomChildren": {},
      8   "_requested": {
      9     "escapedName": "twit",
     10     "fetchSpec": "latest",
     11     "name": "twit",
     12     "raw": "twit",
     13     "rawSpec": "",
     14     "registry": true,
     15     "saveSpec": null,
     16     "type": "tag"
     17   },
     18   "_requiredBy": [
     19     "#USER",
     20     "/"
     21   ],
     22   "_resolved": "https://registry.npmjs.org/twit/-/twit-2.2.11.tgz",
     23   "_shasum": "554343d1cf343ddf503280db821f61be5ab407c3",
     24   "_shrinkwrap": null,
     25   "_spec": "twit",
     26   "_where": "/Users/underd0g/Documents/javascript/TwitWebGraph",
     27   "author": {
     28     "name": "Tolga Tezel"
     29   },
     30   "bugs": {
     31     "url": "https://github.com/ttezel/twit/issues"
     32   },
     33   "bundleDependencies": false,
     34   "dependencies": {
     35     "bluebird": "^3.1.5",
     36     "mime": "^1.3.4",
     37     "request": "^2.68.0"
     38   },
     39   "deprecated": false,
     40   "description": "Twitter API client for node (REST & Streaming)",
     41   "devDependencies": {
     42     "async": "0.2.9",
     43     "colors": "0.6.x",
     44     "commander": "2.6.0",
     45     "mocha": "2.1.0",
     46     "rewire": "2.3.4",
     47     "sinon": "1.15.4"
     48   },
     49   "engines": {
     50     "node": ">=0.10.0"
     51   },
     52   "homepage": "https://github.com/ttezel/twit#readme",
     53   "keywords": [
     54     "api",
     55     "oauth",
     56     "rest",
     57     "stream",
     58     "streaming",
     59     "twitter"
     60   ],
     61   "license": "MIT",
     62   "main": "./lib/twitter",
     63   "name": "twit",
     64   "optionalDependencies": {},
     65   "readme": "# twit\n\nTwitter API Client for node\n\nSupports both the **REST** and **Streaming** API.\n\n# Installing\n\n```shell\nnpm install twit\n```\n\n## Usage:\n\n```javascript\nvar Twit = require('twit')\n\nvar T = new Twit({\n  consumer_key:         '...',\n  consumer_secret:      '...',\n  access_token:         '...',\n  access_token_secret:  '...',\n  timeout_ms:           60*1000,  // optional HTTP request timeout to apply to all requests.\n  strictSSL:            true,     // optional - requires SSL certificates to be valid.\n})\n\n//\n//  tweet 'hello world!'\n//\nT.post('statuses/update', { status: 'hello world!' }, function(err, data, response) {\n  console.log(data)\n})\n\n//\n//  search twitter for all tweets containing the word 'banana' since July 11, 2011\n//\nT.get('search/tweets', { q: 'banana since:2011-07-11', count: 100 }, function(err, data, response) {\n  console.log(data)\n})\n\n//\n//  get the list of user id's that follow @tolga_tezel\n//\nT.get('followers/ids', { screen_name: 'tolga_tezel' },  function (err, data, response) {\n  console.log(data)\n})\n\n//\n// Twit has promise support; you can use the callback API,\n// promise API, or both at the same time.\n//\nT.get('account/verify_credentials', { skip_status: true })\n  .catch(function (err) {\n    console.log('caught error', err.stack)\n  })\n  .then(function (result) {\n    // `result` is an Object with keys \"data\" and \"resp\".\n    // `data` and `resp` are the same objects as the ones passed\n    // to the callback.\n    // See https://github.com/ttezel/twit#tgetpath-params-callback\n    // for details.\n\n    console.log('data', result.data);\n  })\n\n//\n//  retweet a tweet with id '343360866131001345'\n//\nT.post('statuses/retweet/:id', { id: '343360866131001345' }, function (err, data, response) {\n  console.log(data)\n})\n\n//\n//  destroy a tweet with id '343360866131001345'\n//\nT.post('statuses/destroy/:id', { id: '343360866131001345' }, function (err, data, response) {\n  console.log(data)\n})\n\n//\n// get `funny` twitter users\n//\nT.get('users/suggestions/:slug', { slug: 'funny' }, function (err, data, response) {\n  console.log(data)\n})\n\n//\n// post a tweet with media\n//\nvar b64content = fs.readFileSync('/path/to/img', { encoding: 'base64' })\n\n// first we must post the media to Twitter\nT.post('media/upload', { media_data: b64content }, function (err, data, response) {\n  // now we can assign alt text to the media, for use by screen readers and\n  // other text-based presentations and interpreters\n  var mediaIdStr = data.media_id_string\n  var altText = \"Small flowers in a planter on a sunny balcony, blossoming.\"\n  var meta_params = { media_id: mediaIdStr, alt_text: { text: altText } }\n\n  T.post('media/metadata/create', meta_params, function (err, data, response) {\n    if (!err) {\n      // now we can reference the media and post a tweet (media will attach to the tweet)\n      var params = { status: 'loving life #nofilter', media_ids: [mediaIdStr] }\n\n      T.post('statuses/update', params, function (err, data, response) {\n        console.log(data)\n      })\n    }\n  })\n})\n\n//\n// post media via the chunked media upload API.\n// You can then use POST statuses/update to post a tweet with the media attached as in the example above using `media_id_string`.\n// Note: You can also do this yourself manually using T.post() calls if you want more fine-grained\n// control over the streaming. Example: https://github.com/ttezel/twit/blob/master/tests/rest_chunked_upload.js#L20\n//\nvar filePath = '/absolute/path/to/file.mp4'\nT.postMediaChunked({ file_path: filePath }, function (err, data, response) {\n  console.log(data)\n})\n\n//\n//  stream a sample of public statuses\n//\nvar stream = T.stream('statuses/sample')\n\nstream.on('tweet', function (tweet) {\n  console.log(tweet)\n})\n\n//\n//  filter the twitter public stream by the word 'mango'.\n//\nvar stream = T.stream('statuses/filter', { track: 'mango' })\n\nstream.on('tweet', function (tweet) {\n  console.log(tweet)\n})\n\n//\n// filter the public stream by the latitude/longitude bounded box of San Francisco\n//\nvar sanFrancisco = [ '-122.75', '36.8', '-121.75', '37.8' ]\n\nvar stream = T.stream('statuses/filter', { locations: sanFrancisco })\n\nstream.on('tweet', function (tweet) {\n  console.log(tweet)\n})\n\n//\n// filter the public stream by english tweets containing `#apple`\n//\nvar stream = T.stream('statuses/filter', { track: '#apple', language: 'en' })\n\nstream.on('tweet', function (tweet) {\n  console.log(tweet)\n})\n\n```\n\n# twit API:\n\n## `var T = new Twit(config)`\n\nCreate a `Twit` instance that can be used to make requests to Twitter's APIs.\n\nIf authenticating with user context, `config` should be an object of the form:\n```\n{\n    consumer_key:         '...'\n  , consumer_secret:      '...'\n  , access_token:         '...'\n  , access_token_secret:  '...'\n}\n```\n\nIf authenticating with application context, `config` should be an object of the form:\n```\n{\n    consumer_key:         '...'\n  , consumer_secret:      '...'\n  , app_only_auth:        true\n}\n```\nNote that Application-only auth will not allow you to perform requests to API endpoints requiring\na user context, such as posting tweets. However, the endpoints available can have a higher rate limit.\n\n## `T.get(path, [params], callback)`\nGET any of the REST API endpoints.\n\n**path**\n\nThe endpoint to hit. When specifying `path` values, omit the **'.json'** at the end (i.e. use **'search/tweets'** instead of **'search/tweets.json'**).\n\n**params**\n\n(Optional) parameters for the request.\n\n**callback**\n\n`function (err, data, response)`\n\n- `data` is the parsed data received from Twitter.\n- `response` is the [http.IncomingMessage](http://nodejs.org/api/http.html# http_http_incomingmessage) received from Twitter.\n\n## `T.post(path, [params], callback)`\n\nPOST any of the REST API endpoints. Same usage as `T.get()`.\n\n## `T.postMediaChunked(params, callback)`\n\nHelper function to post media via the POST media/upload (chunked) API. `params` is an object containing a `file_path` key. `file_path` is the absolute path to the file you want to upload.\n\n```js\nvar filePath = '/absolute/path/to/file.mp4'\nT.postMediaChunked({ file_path: filePath }, function (err, data, response) {\n  console.log(data)\n})\n```\n\nYou can also use the POST media/upload API via T.post() calls if you want more fine-grained control over the streaming; [see here for an example](https://github.com/ttezel/twit/blob/master/tests/rest_chunked_upload.js# L20).\n\n## `T.getAuth()`\nGet the client's authentication tokens.\n\n## `T.setAuth(tokens)`\nUpdate the client's authentication tokens.\n\n## `T.stream(path, [params])`\nUse this with the Streaming API.\n\n**path**\n\nStreaming endpoint to hit. One of:\n\n- **'statuses/filter'**\n- **'statuses/sample'**\n- **'statuses/firehose'**\n- **'user'**\n- **'site'**\n\nFor a description of each Streaming endpoint, see the [Twitter API docs](https://dev.twitter.com/streaming/overview).\n\n**params**\n\n(Optional) parameters for the request. Any Arrays passed in `params` get converted to comma-separated strings, allowing you to do requests like:\n\n```javascript\n//\n// I only want to see tweets about my favorite fruits\n//\n\n// same result as doing { track: 'bananas,oranges,strawberries' }\nvar stream = T.stream('statuses/filter', { track: ['bananas', 'oranges', 'strawberries'] })\n\nstream.on('tweet', function (tweet) {\n  //...\n})\n```\n\n# Using the Streaming API\n\n`T.stream(path, [params])` keeps the connection alive, and returns an `EventEmitter`.\n\nThe following events are emitted:\n\n## event: 'message'\n\nEmitted each time an object is received in the stream. This is a catch-all event that can be used to process any data received in the stream, rather than using the more specific events documented below.\nNew in version 2.1.0.\n\n```javascript\nstream.on('message', function (msg) {\n  //...\n})\n```\n\n## event: 'tweet'\n\nEmitted each time a status (tweet) comes into the stream.\n\n```javascript\nstream.on('tweet', function (tweet) {\n  //...\n})\n```\n\n## event: 'delete'\n\nEmitted each time a status (tweet) deletion message comes into the stream.\n\n```javascript\nstream.on('delete', function (deleteMessage) {\n  //...\n})\n```\n\n## event: 'limit'\n\nEmitted each time a limitation message comes into the stream.\n\n```javascript\nstream.on('limit', function (limitMessage) {\n  //...\n})\n```\n\n## event: 'scrub_geo'\n\nEmitted each time a location deletion message comes into the stream.\n\n```javascript\nstream.on('scrub_geo', function (scrubGeoMessage) {\n  //...\n})\n```\n\n## event: 'disconnect'\n\nEmitted when a disconnect message comes from Twitter. This occurs if you have multiple streams connected to Twitter's API. Upon receiving a disconnect message from Twitter, `Twit` will close the connection and emit this event with the message details received from twitter.\n\n```javascript\nstream.on('disconnect', function (disconnectMessage) {\n  //...\n})\n```\n\n## event: 'connect'\n\nEmitted when a connection attempt is made to Twitter. The http `request` object is emitted.\n\n```javascript\nstream.on('connect', function (request) {\n  //...\n})\n```\n\n## event: 'connected'\n\nEmitted when the response is received from Twitter. The http `response` object is emitted.\n\n```javascript\nstream.on('connected', function (response) {\n  //...\n})\n```\n\n## event: 'reconnect'\n\nEmitted when a reconnection attempt to Twitter is scheduled. If Twitter is having problems or we get rate limited, we schedule a reconnect according to Twitter's [reconnection guidelines](https://dev.twitter.com/streaming/overview/connecting). The last http `request` and `response` objects are emitted, along with the time (in milliseconds) left before the reconnect occurs.\n\n```javascript\nstream.on('reconnect', function (request, response, connectInterval) {\n  //...\n})\n```\n\n## event: 'warning'\n\nThis message is appropriate for clients using high-bandwidth connections, like the firehose. If your connection is falling behind, Twitter will queue messages for you, until your queue fills up, at which point they will disconnect you.\n\n```javascript\nstream.on('warning', function (warning) {\n  //...\n})\n```\n\n## event: 'status_withheld'\n\nEmitted when Twitter sends back a `status_withheld` message in the stream. This means that a tweet was withheld in certain countries.\n\n```javascript\nstream.on('status_withheld', function (withheldMsg) {\n  //...\n})\n```\n\n## event: 'user_withheld'\n\nEmitted when Twitter sends back a `user_withheld` message in the stream. This means that a Twitter user was withheld in certain countries.\n\n```javascript\nstream.on('user_withheld', function (withheldMsg) {\n  //...\n})\n```\n\n## event: 'friends'\n\nEmitted when Twitter sends the [\"friends\" preamble](https://dev.twitter.com/streaming/overview/messages-types# user_stream_messsages) when connecting to a user stream. This message contains a list of the user's friends, represented as an array of user ids. If the [stringify_friend_ids](https://dev.twitter.com/streaming/overview/request-parameters#stringify_friend_id) parameter is set, the friends\nlist preamble will be returned as Strings (instead of Numbers).\n\n```javascript\nvar stream = T.stream('user', { stringify_friend_ids: true })\nstream.on('friends', function (friendsMsg) {\n  //...\n})\n```\n\n## event: 'direct_message'\n\nEmitted when a direct message is sent to the user. Unfortunately, Twitter has not documented this event for user streams.\n\n```javascript\nstream.on('direct_message', function (directMsg) {\n  //...\n})\n```\n\n## event: 'user_event'\n\nEmitted when Twitter sends back a [User stream event](https://dev.twitter.com/streaming/overview/messages-types#Events_event).\nSee the Twitter docs for more information on each event's structure.\n\n```javascript\nstream.on('user_event', function (eventMsg) {\n  //...\n})\n```\n\nIn addition, the following user stream events are provided for you to listen on:\n\n* `blocked`\n* `unblocked`\n* `favorite`\n* `unfavorite`\n* `follow`\n* `unfollow`\n* `mute`\n* `unmute`\n* `user_update`\n* `list_created`\n* `list_destroyed`\n* `list_updated`\n* `list_member_added`\n* `list_member_removed`\n* `list_user_subscribed`\n* `list_user_unsubscribed`\n* `quoted_tweet`\n* `retweeted_retweet`\n* `favorited_retweet`\n* `unknown_user_event` (for an event that doesn't match any of the above)\n\n### Example:\n\n```javascript\nstream.on('favorite', function (event) {\n  //...\n})\n```\n\n## event: 'error'\n\nEmitted when an API request or response error occurs.\nAn `Error` object is emitted, with properties:\n\n```js\n{\n  message:      '...',  // error message\n  statusCode:   '...',  // statusCode from Twitter\n  code:         '...',  // error code from Twitter\n  twitterReply: '...',  // raw response data from Twitter\n  allErrors:    '...'   // array of errors returned from Twitter\n}\n```\n\n## stream.stop()\n\nCall this function on the stream to stop streaming (closes the connection with Twitter).\n\n## stream.start()\n\nCall this function to restart the stream after you called `.stop()` on it.\nNote: there is no need to call `.start()` to begin streaming. `Twit.stream` calls `.start()` for you.\n\n-------\n\n# What do I have access to?\n\nAnything in the Twitter API:\n\n* REST API Endpoints:       https://dev.twitter.com/rest/public\n* Public stream endpoints:  https://dev.twitter.com/streaming/public\n* User stream endpoints:    https://dev.twitter.com/streaming/userstreams\n* Site stream endpoints:    https://dev.twitter.com/streaming/sitestreams\n\n-------\n\nGo here to create an app and get OAuth credentials (if you haven't already): https://apps.twitter.com/app/new\n\n# Advanced\n\nYou may specify an array of trusted certificate fingerprints if you want to only trust a specific set of certificates.\nWhen an HTTP response is received, it is verified that the certificate was signed, and the peer certificate's fingerprint must be one of the values you specified. By default, the node.js trusted \"root\" CAs will be used.\n\neg.\n```js\nvar twit = new Twit({\n  consumer_key:         '...',\n  consumer_secret:      '...',\n  access_token:         '...',\n  access_token_secret:  '...',\n  trusted_cert_fingerprints: [\n    '66:EA:47:62:D9:B1:4F:1A:AE:89:5F:68:BA:6B:8E:BB:F8:1D:BF:8E',\n  ]\n})\n```\n\n# Contributing\n\n- Make your changes\n- Make sure your code matches the style of the code around it\n- Add tests that cover your feature/bugfix\n- Run tests\n- Submit a pull request\n\n# How do I run the tests?\n\nCreate two files: `config1.js` and `config2.js` at the root of the `twit` folder. They should contain two different sets of oauth credentials for twit to use (two accounts are needed for testing interactions). They should both look something like this:\n\n```\nmodule.exports = {\n    consumer_key: '...'\n  , consumer_secret: '...'\n  , access_token: '...'\n  , access_token_secret: '...'\n}\n```\n\nThen run the tests:\n\n```\nnpm test\n```\n\nYou can also run the example:\n\n```\nnode examples/rtd2.js\n```\n\n![iRTD2](http://dl.dropbox.com/u/32773572/RTD2_logo.png)\n\nThe example is a twitter bot named [RTD2](https://twitter.com/#!/iRTD2) written using `twit`. RTD2 tweets about **github** and curates its social graph.\n\n-------\n\n[FAQ](https://github.com/ttezel/twit/wiki/FAQ)\n\n-------\n\n## License\n\n(The MIT License)\n\nCopyright (c) by Tolga Tezel <tolgatezel11@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n## Changelog\n\n### 2.2.11\n* Fix media_category used for media uploads (thanks @BooDoo)\n\n### 2.2.10\n  * Update maximum Tweet characters to 280 (thanks @maziyarpanahi)\n  * For streaming requests, use request body for sending params (thanks @raine)\n  * Fix getBearerToken endpoint (thanks @williamcoates)\n  * Shared Parameter Feature For Media Upload (thanks @haroonabbasi)\n  * Don't include params in path for jsonpayload paths (thanks @egtoney)\n  * Add support for strictSSL request option (thanks @zdoc01)\n\n### 2.2.9\n  * Use JSON payload in request body for new DM endpoints.\n\n### 2.2.8\n  * Add support for HTTP DELETE; you can now `T.delete(...)`.\n\n### 2.2.7\n  * Don't attempt to reconnect to Twitter API when receiving HTTP status code 413 - request entity too large.\n\n### 2.2.6\n  * Fix zlib error when streaming\n\n### 2.2.4\n  * Fix 401 Unauthorized error on streaming connection reconnect after not being\n  connected for some time (eg. due to > 1min loss of network).\n\n### 2.2.2\n  * Emit `parser-error` instead of `error` event if Twitter sends back\n  an uncompressed HTTP response body.\n\n### 2.2.1\n  * Add promise support to Twit REST API calls.\n\n### 2.2.0\n  * Allow omission of `new` keyword; `var t = Twit(config)` works, and `var t = new Twit(config)` works too.\n  * Allow setting an array of trusted certificate fingerprints via `config.trusted_cert_fingerprints`.\n  * Automatically adjust timestamp for OAuth'ed HTTP requests\n  by recording the timestamp from Twitter HTTP responses, computing our local time offset, and applying the offset in the next HTTP request to Twitter.\n\n### 2.1.7\n  * Add `mime` as a dependency.\n\n### 2.1.6\n  * Emit `friends` event for `friends_str` message received when a user stream is requested with `stringify_friend_ids=true`.\n  * Handle receiving \"Exceeded connection limit for user\" message from Twitter while streaming. Emit `error` event for this case.\n  * Emit `retweeted_retweet` and `favorited_retweet` user events.\n  * Add MIT license to package.json (about time!)\n\n### 2.1.5\n  * Support config-based request timeout.\n\n### 2.1.4\n  * Support POST media/upload (chunked) and add `T.postMediaChunked()` to make it easy.\n\n### 2.1.3\n  * Fix bug in constructing HTTP requests for `account/update_profile_image` and `account/update_profile_background_image` paths.\n\n### 2.1.2\n  * Enable gzip on network traffic\n  * Add `quoted_tweet` event\n\n### 2.1.1\n  * Strict-mode fixes (Twit can now be run with strict mode)\n  * Fix handling of disconect message from Twitter\n  * If Twitter returns a non-JSON-parseable fragment during streaming, emit 'parser-error' instead of 'error' (to discard fragments like \"Internal Server Error\")\n\n### 2.1.0\n  * Add `message` event.\n\n### 2.0.0\n  * Implement Application-only auth\n  * Remove oauth module as a dependency\n\n### 1.1.20\n  * Implement support for POST /media/upload\n  * Reconnect logic fix for streaming; add stall abort/reconnect timeout on first connection attempt.\n\n### 1.1.14\n  * Emit `connected` event upon receiving the response from twitter\n\n### 1.0.0\n  * now to stop and start the stream, use `stream.stop()` and `stream.start()` instead of emitting the `start` and `stop` events\n  * If twitter sends a `disconnect` message, closes the stream and emits `disconnect` with the disconnect message received from twitter\n\n### 0.2.0\n  * Updated `twit` for usage with v1.1 of the Twitter API.\n\n### 0.1.5\n\n  * **BREAKING CHANGE** to `twit.stream()`. Does not take a callback anymore. It returns\n    immediately with the `EventEmitter` that you can listen on. The `Usage` section in\n    the Readme.md has been updated. Read it.\n\n\n### 0.1.4\n\n  * `twit.stream()` has signature `function (path, params, callback)`\n",
     66   "readmeFilename": "README.md",
     67   "repository": {
     68     "type": "git",
     69     "url": "git+ssh://git@github.com/ttezel/twit.git"
     70   },
     71   "scripts": {
     72     "test": "mocha tests/* -t 70000 -R spec --bail --globals domain,_events,_maxListeners"
     73   },
     74   "version": "2.2.11"
     75 }