Table of Contents generated with DocToc
forgetsy-js
NodeJS Trending library
Status
NPM Stats
NOTICE
This library was converted to use Promise/A+. Please see usage instructions below.
Description
Node.JS fork Forgetsy, a trending library designed to track temporal trends in non-stationary categorical distributions. Please fork or file an bug if you discover an issue. The project use Redis as the backend.
Please fork and make it better.
Installation
npm install forgetsy-js
Usage
Initializing
// setup redisvar redis = ;var client = redis; // setup forgetsy-js & pass redis clientvar delta = ;delta;
Create a distribution
// name of distributionvar name = 'facebook-shares'; // name of binvar bin = 'my-content-id'; var promise = delta; promise; promise;
Increment a bin
var promise = delta; promise;
Fetch distribution (all)
var promise = delta; promise
Fetch distribution (one)
var promise = delta; promise
Fetch distribution (n)
var promise = delta; promise
Example output
'item': 'one': 'score': 0999999999997154'item': 'two': 'score': 09999999999939523
Complete Example
var name = 'facebook-shares';var bin = 'my-content-id2'; // create distributiondelta;
Basic Demo
This is a very basic working API demo.
Create a distribution
Categories are the distributions to create
- classical
- modern
- street
Type is the type of distributions we're creating. In this case, the categories are related to "art." You can classify the distributions as you see fit. For example, "type" could easily refer to "music." (Probably sans "street" [:-])
http://104.131.230.35/create?categories=classical,modern,street&type=art
Increment a bin
Here we will trend a bin, "banksy & Barbara Kruger" the famous street artist.
http://104.131.230.35/incr?categories=street&type=art&bin=banksy
http://104.131.230.35/incr?categories=street&type=art&bin=Barbara Kruger
Fetch distribution
Here we will fetch what's trending in category "street" of type "art"
http://104.131.230.35/fetch?categories=street&type=art&filters=geoip
Fetch all distributions
Here we will fetch what's trending in all of the categories of type "art"
http://104.131.230.35/fetch?categories=classical,modern,street&type=art&filters=geoip
Fetch all distributions with geo-location trends
Here we will fetch what's trending in all of the categories of type "art" and geo-location trends. Behind the scenes, the API is detecting your location and trending based on geo-location as well (assuming your location was detected!)
http://104.131.230.35/fetch?categories=classical,modern,street&type=art
Test
npm test