Skip to content

SuddenDevelopment/api2stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

api2stream

call an api, stream the results, when you reach the end, poll for new results, repeat

//set your callbacks
var objConfig={
   fnEvent:function(){
     //put your stream new event call here
   }
  ,fnCall:function(){
     var results;
     //populate results somehow, most likely an api call
     //need to call the lib to process the results when they complete, this avoids race conditions
     apiPoll.process(results);
  }
};

//other config options
{
	pollSpeed:60, // minimum time in seconds to wait between API calls when polling
	eventSpeed:1, // number of records per second to stream
	order:'desc', // newest or oldest records first? oldest first= desc
	cache:5, //number of records to keep from the beginning and end of the result for diff comparisons
	format:'json', //format of the results
	poll:true, // set to false if you only want to stream 1 set of events
}

//create an instance for each API call you need to poll
var apiPoll=new api2stream(objConfig);

//and GO!
apiPoll.fnFirstResults();

//and STOP!
apiPoll.fnStop();

//and Resume
apiPoll.fnGo();
``

About

call an api, stream the results, when you reach the end, poll for new results, repeat

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published