PrimedNodeJS

primednodejs

=========

A server-side API wrapper written in Javascript (NodeJS) to perform API calls to PrimedIO

Installation

npm install primednodejs

Usage

var PRIMEDIO = require('primednodejs');

// Instantiate PRIMEDIO, public key
// and secret key are provided by PrimedIO
var pio = new PRIMEDIO({
	public_key: public_key, 
	secret_key: secret_key
});

// Perform the personalize call,
// which returns a 'promise'
var promise = pio.personalize({
	campaign: 'frontpage.article.bottom',
	signals: [{
		key:'article_id', 
		value: '2578346'
	}, 
	{
		key:'tod-dow', 
		value: 'Fri_15-18'
	}],
	limit_results: 10,
	abvariants: ['A'],
	fractions: [1.0]
});

// Deal with the results as they are returned
// by Primed. 
promise.then(function(response) {
	// 'response' is a wrapper object,
	// calling 'response.all()' returns
	// the list of results which can then be
	// used to render the page
	var results = response.all();
	
	// simulate a click -- 'conversion'
	var clicked = response.first();

	// mark the clicked result as converted
	// by using the `.uuid` property
	pio.convert(clicked.uuid);
}).catch(function (err) {
	console.log('Personalize failed: ' + err);
});

// Converting clicks.
// Each result comes with a guaranteed
// random UUID. This UUID can be sent back to
// PrimedIO to mark a result as having been
// converted. This in turn allows the system
// to evaluate the performance (as CTR) of the
// underlying Model(blend).
pio.convert("df3870dc-b277-11e7-abc4-cec278b6b50a"); 

Tests

npm test