Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What is causing exceeding of Rate Limit in My Program?

What is causing exceeding of Rate Limit in My Program?

Problem

I am using the Stackoverflow API to collect the tags in Stackoverflow. I am using NodeJS and am facing a typical problem. My Rate Limit gets exceeded after 230-250 requests.AS far as I have read it allows

var request=require('superagent');
var request=require('mongoose');
mongoose.connect('mongodb://shivkumarganesh:[email protected]:10090/lklklklkkkkl_gshiv_sk');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback () {
  console.log('Connected');
});

//Schema for Tags
var tagSchema = mongoose.Schema({
    name:String,
    count:Number,
    is_required:Boolean
,    is_moderator_only:Boolean,
    has_synonyms:Boolean});

var Tags = mongoose.model('Tags', tagSchema);

var saveSchema = function(Model){
    Model.save();
}
 ///usr/local/lib/node_modules/superagent  
var i=1;
var req=function(){
    request.get('http://api.stackexchange.com/2.1/tags?page='+i+'&pagesize=100&fromdate=1199145600&todate=1377648000&order=asc&sort=popular&site=stackoverflow')
   .set('X-API-Key', 'foobar')
   .set('Accept', 'application/json')
   .end(function(res){
     if (res.ok && i "+i);
       setTimeout(function() {
           req();
       }, 3000);

     } else {
       console.log('Oh no! error ' + res.text);
       console.log('Processing Over'+i)
     }
   });

}
req();

Please help me to figure this out.If possible please rectify the program. Note: I amusing MongoHQ to store data.

Problem courtesy of: Shiv Kumar Ganesh

Solution

You should read this informative link: https://api.stackexchange.com/docs/throttle

Specifically:

A dynamic throttle is also in place on a per-method level. If an application receives a response with the Backoff Field set, it must wait that many seconds before hitting the same method again.

So check out the backoff field returned, and wait for that much before doing another request.

Solution courtesy of: Florian Margaine

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

What is causing exceeding of Rate Limit in My Program?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×