Simple node.js wrapper for the Forrst.com API.
Work in progress...
npm install forrst
This wapper is at the moment basically an extension of Node.js’s http.get method, below are 2 basic examples of how to use it:
var forrst = require('forrst');
forrst.stats(function(res){
res.on('data', function(d) {
process.stdout.write(d);
});
res.on('end', function(d) {
console.log('\n\n[request completed]');
});
}).on('error', function(e) {
console.error(e);
});
The stats method is the only one that don't accept parameters, so the only argument to pass to forrst.stats is the callback function.
For all other methods you pass an object containing the method parameters as the first argument and the callback function as the second argument, see the example below:
var forrst = require('forrst');
forrst.posts.list({post_type:'snap'}, function(res){
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
res.on('end', function(d) {
console.log('\n\n[request completed]');
});
}).on('error', function(e) {
console.error(e);
});
The method names use dots instead of slashes, so posts/list become posts.list
- MIT
- require from the developer a custom user-agent
- add authenticated calls
- flip the calls to https