README
nodejs-piwik-reporting
The module is designed to wrap PIWIK reporting API.
http://developer.piwik.org/api-reference/reporting-api
No dependencies.
Supports BULK operations (API.getBulkRequest), i.e. multiple PIWIK request combined in single http call
Install
npm install piwik-reporting
Setup
var PiwikAPI = require("piwik-reporting");
PiwikAPI.configure({url: "demo.piwik.org", defaultToken: "anonymous"});
Usage
Example 1 - Get site from ID
PiwikAPI.get({method: "SitesManager.getSiteFromId"}, {idSite: "7}, function(message) {
console.log(message);
});
Corresponding URL: http://demo.piwik.org/?module=API&method=SitesManager.getSiteFromId&idSite=7&format=json&token_auth=anonymous
Example 2 - Create a report
var vars = {
idSite: "7",
description: "Test",
period: "today",
hour: "0",
reportType: "email",
reportFormat: "pdf",
reports: ["VisitsSummary_get", "VisitTime_getVisitInformationPerLocalTime"],
parameters: {
displayFormat: "1",
emailMe: false,
evolutionGraph: false
}
};
PiwikAPI.get({method: "PDFReports.addReport"}, vars, function(message) {
console.log(message);
});
example 3 - BULK request
PiwikAPI.get({
method: 'API.getBulkRequest',
}, {
urls: {
0: {
method: 'Actions.getPageUrl',
idSite: "2",
period: 'day',
date: '2015-1-30,2015-3-1',
pageUrl: 'testPage1'
},
1: {
method: 'Actions.getPageUrl',
idSite: "2",
period: 'day',
date: '2015-1-30,2015-3-1',
pageUrl: 'testPage2'
}
}
}, function (data) {
console.log(data)
})