piwik-reporting
v0.0.3
Published
Connector to PIWIK with BULK api support
Downloads
3
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);
});
Corresponding URL: http://demo.piwik.org/?module=API&method=PDFReports.addReport&idSite=7&description=Test&period=today&hour=0&reportType=email&reportFormat=pdf&reports[]=VisitsSummary_get&reports[]=VisitTime_getVisitInformationPerLocalTime¶meters[displayFormat]=1¶meters[emailMe]=false¶meters[evolutionGraph]=false&format=json&token_auth=anonymous
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)
})
Corresponding URL: http://demo.piwik.org/?module=API&method=API.getBulkRequest&format=json&token_auth=anonymous&urls[0]=%26method%3DActions.getPageUrl%26idSite%3D2%26period%3Dday%26date%3D2015-1-30%252C2015-3-1%26pageUrl%3DtestPage1&urls[1]=%26method%3DActions.getPageUrl%26idSite%3D2%26period%3Dday%26date%3D2015-1-30%252C2015-3-1%26pageUrl%3DtestPage2