forrst

0.1.0 • Public • Published

node-forrst

Simple node.js wrapper for the Forrst.com API.

Work in progress...

Installation

npm install forrst

Usage

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:

Methods with no parameters

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);
});

Forrst methods that dont have parameters, such as stats and posts/all are called with only one argument on node-forrst, the callback that works like a regular node.js http request callback.

Methods with parameters

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);
});

For all other methods the first argument is an object with the method parameters and the second is the callback function. The method names use dots instead of slashes, so posts/list become posts.list

Implemented Methods

License

  • MIT

TODO / Roadmap

  • require from the developer a custom user-agent
  • add authenticated calls
  • flip the calls to https
  • make the library available as a npm package

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i forrst

      Weekly Downloads

      2

      Version

      0.1.0

      License

      none

      Last publish

      Collaborators

      • fczuardi