Giter Club home page Giter Club logo

nomniture's Introduction

nomniture

This is a Node.js port of ROmniture by msukmanowsky.

what is it

nomniture is a minimal Node.js module wrapper for Omniture's REST API.

There are two objects to use, Client and Report. Client is the generic interface to the Omniture API. Report adds a few helper methods to handle requesting a report and polling the Omniture API until the report is ready. It then requests the report and returns the data.

Omniture's API is closed, you have to be a paying customer in order to access the data.

installation

[sudo] npm install nomniture

initialization and authentication

nomniture requires you supply the username, sharedSecret and environment which you can access within the Company > Web Services section of the Admin Console. The environment you'll use to connect to Omniture's API depends on which data center they're using to store your traffic data and will be one of:

Here's an example of initializing with a few configuration options.

  // generic Client
  var Client = require('nomniture').Client;
  var c = new Client(username, sharedSecret, 'sanJose');

  // Report
  var Report = require('nomniture').Report;
  var r = new Report(username, sharedSecret, 'sanJose', {waitTime : 10}); // waitTime is optional, default is set to 5 seconds

usage

There is only one core method for the user:

  • request - handles all requests to the API.

For reference, I'd recommend keeping Omniture's Developer Portal open as you code . It's not the easiest to navigate but most of what you need is there.

The method takes three arguments:

  • Report type - 'Report.QueueRanked', 'ReportSuite.GetAvailableMetrics'
  • Parameters - These vary depending on the type of request. This should be in an object. If no data is needed, pass an empty object
  • Callback function - This function will be called when the request has finished. This callback function has two arguments passessed: an error object (null, if no errors) and the response object.

If the response is a string or a number as it is for "Company.GetTokenCount", the response will be returned a such. All other responses will be a parsed JSON object.

examples

// Get all available metrics using the Client object
var Client = require('nomniture').Client,
    c = new Client(username, sharedSecret, 'sanJose'),
    reportData = { "rsid_list": ["reportSuiteId"] }

c.request('ReportSuite.GetAvailableMetrics', reportData, function(err, response){
  if(err){ throw new Error(err.message); }
  console.log(response);
});

// Use the Report object to get a pageView Overtime report
var Report = require('nomniture').Report,
    option = {
      waitTime: 10, // optionally set the wait time between polling API
      log: true // default is false
    },
    reportData = {
      reportDescription: {
      reportSuiteID: "reportSuiteId",
      dateFrom: "2012-01-01",
      dateTo: "2012-01-31",
      metrics: [{ id: "pageviews" }],
      validate: "true"
    }
  };
var r = new Report(username, sharedSecret, 'sanJose', options) // lets set our poll time to 10 seconds

r.request("Report.QueueOvertime", reportData, function(err, response){
  if(err){ throw new Error(err.message); }
  console.log(response);
});

nomniture's People

Contributors

ender672 avatar imartingraham avatar ivasilov avatar jaredly avatar kauegimenes avatar ukyo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.