Twitter rate limit module to automatically limit requests to twitter to stay within rate limits
This module helps manage your requests to the Twitter API so you don't get rate limited. If you use the module to make requests, it will automatically queue your requests and if you are in danger of exceeding Twitter's API limits, it will store them and execute them after the time window has passed. No more worrying about rate limiting.
npm install twitter-rate-limiter
Create a file called config.json with your twitter credentials in the format
"twitter":"consumerKey": "...""consumerSecret": "...""token": "...""tokenSecret": "..."
You could hardcode it into the file but that wouldn't be advisable.
In your file, import the config.json file
Import the rate_limit.js file
var RateLimiter = require('../rate_limit.js');
Instantiate a new RateLimit object.
var getfriends = 2 5000;
The two arguments are the requests in the time window in the form(requests, time window). Usually the time window is 900000 ms for 15 minutes. The request number varies by function call
Create a function for the twitter call you want to make. This example shows the GET friends request
varvar url = ''+username+'&count=5000';console.logurl;requestgeturl: url oauth: oauth json: truecallbackbody;
The function calling this would look like
getfriendscallWithLimitcallGetFriends "user"console.logdata;"...insert processing here";