The Piwik analytics API allows you to access all the data remotely that is available in Piwik's interface. With it you can embed Piwik's data in another application using any programming language, or you can manipulate the data for reports and graphs not available in Piwik itself. Complete documentation of the Piwik analytics API is available at http://piwik.org/docs/analytics-api/reference/ or at the API link in any live Piwik installation.
This API provides metadata on all the other API methods. In other words, calling a function in the Module API will tell you what methods are available for you to use and will give you human-readable information on these methods. The following are some examples of its methods:
You can read more about the methods available in the Metadata API at http://piwik.org/docs/analytics-api/metadata/.
The Actions API will give you information on all of your visitors' actions such as page titles, clicks on external links, and file downloads.
The getPageTitles
method will return all of your page titles and the standard metrics available to that method.
You can also request the data for a single page title by using getPageTitle
, by setting the pageName
parameter to the page title you choose.
Some more of the methods available are getPageUrl
, which will give you metrics for a specific page URL, getOutlink
, which will give you outlink data, and getDownload
, which will give you the downloaded files' data.
Note
The pageName
, pageUrl
, outlinkUrl
, and downloadUrl
parameters must be URL encoded before you call the API.
You can find out more about all of the functions available in the Actions API by visiting http://piwik.org/docs/analytics-api/reference/#Actions.
The CustomVariables API lets you access reports for your CustomVariables names and values. It has only two functions shown as follows:
CustomVariables.getCustomVariables (idSite, period, date, segment = '', expanded = ''). CustomVariables.getCustomVariablesValuesFromNameId (idSite, period, date, idSubtable, segment = '').
The ExampleAPI is useful to developers building a custom Piwik plugin. It is essentially a toy API created to help you learn. You can read more about it at http://piwik.org/docs/analytics-api/reference/#ExampleAPI.
The Goals API gives you control over your goals. You can use updateGoal
to change a goal's details, deleteGoal
to remove a goal, and addGoal
to create a new goal. And if you want to list the goals for one or more websites, you can use the getGoals
method.
Another feature is that this API provides access to your e-commerce tracking data. You can retrieve a list of products purchased on your site by using getItemsSku
, getItemsName
, or getItemsCategory
. These methods will return a list of products that have been purchased on your site along with supporting metrics.
You can explore more of the Goals API by visiting http://piwik.org/docs/analytics-api/reference/#Goals.
The ImageGraph API will return PNG graphs for any Piwik report that supports them. In your request, you can specify these graph types as line plot, vertical bar chart, or 2D/3D pie chart. You can also specify the width, height, font size, and even the colors of the graph being returned.
You can read more about the ImageGraph API at http://piwik.org/docs/analytics-api/reference/#ImageGraph.
The LanguagesManager API lets you translate the data you receive from Piwik into any one of the 40+ languages that Piwik supports.
For more information on the LanguagesManager API, please visit http://piwik.org/docs/analytics-api/reference/#LanguagesManager.
The Live! API will give you real-time information about your visitors. You can also use segmentation with this API to drill down your data to very specific subsets. The getLastVisitsDetails
method will give you a massive amount of detail on each of your visitors. By adding the parameter &segment=
, you can use segmentation to filter the visits that have been returned by any valid criteria.
The getCounters
method will return a simple count of visits, actions, or converted visits for your chosen time period.
Here are the two methods available in the Live! API.
Live.getCounters (idSite, lastMinutes, segment = '') Live.getLastVisitsDetails (idSite, period, date, segment = '', filter_limit = '', maxIdVisit = '', minTimestamp = '').
The MultiSites API will return the key metrics from all the websites you are tracking in Piwik. It only has one method, listed as follows
MultiSites.getAll (period, date, segment = '')
The PDFReports API gives you remote control over Piwik reports. With it, you can generate, download, email, or schedule reports.
To learn more about the PDFReports API, please see http://piwik.org/docs/analytics-api/reference/#PDFReports and http://piwik.org/docs/email-reports/.
The Provider API lets you access reports for your visitors' Internet providers such as Comcast, Road Runner, and Cox. It has only one method:
Provider.getProvider (idSite, period, date, segment = '')
The Referers API will give you data on the referrers that visitors used to find your website. It will return data on websites, search engines, keywords, and campaigns.
An example widget that uses the referrer API is available at http://tinyurl.com/9b8z8hz.
You can read more about the Referers API at http://piwik.org/docs/analytics-api/reference/#Referers.
The SEO API returns a list of SEO data on your URL. It will give you Google PageRank, Yahoo! backlinks, Yahoo! indexed pages, Alexa Rank, and domain name age. Here is its one method:
SEO.getRank (url)
The SitesManager API lets you control your websites in Piwik remotely. You can create, update, and delete the websites that your Piwik installation tracks as well as retrieve data on the configuration of those sites.
You can read more about all the methods available in the SitesManager API at http://piwik.org/docs/analytics-api/reference/#SitesManager.
The UserCountry API will return reports about your visitors' countries and continents.
You can read more about this API at http://piwik.org/docs/analytics-api/reference/#UserCountry.
The UserSettings API will return reports about your visitors' browsing environment including the browser they use, their operating system, plugins they have installed in their browser, their screen resolution and their screen type.
You can learn more about all the methods available in this API at http://piwik.org/docs/analytics-api/reference/#UserSettings.
The UsersManager API allows you to control Piwik users remotely. You can add, delete, update or get information about the users that have access to your Piwik installation.
To find out more about these methods and others available in the UsersManager API please visit http://piwik.org/docs/analytics-api/reference/#UsersManager.
The VisitFrequency API lets you access a list of metrics related toreturning visitors. It has one method:
VisitFrequency.get (idSite, period, date, segment = '', columns = '')
The VisitTime API lets you access reports by hour (server time), and by hour (local time) of your visitors. It has only these two methods:
VisitTime.getVisitInformationPerLocalTime (idSite, period, date, segment = '')
VisitTime.getVisitInformationPerServerTime (idSite, period, date, segment = '', hideFutureHoursWhenToday = '')
The VisitorInterest API gives you visitor engagement reports.
You can find out more about this API at http://piwik.org/docs/analytics-api/reference/#VisitorInterest.
The VisitsSummary API lets you access the core web analytics metrics.
To read about all the methods you can use with this API, please see http://piwik.org/docs/analytics-api/reference/#VisitsSummary.