Tutorial: Get your top 10 popular pages

This tutorial will show you how easy it is to request the yesterday's top 10 popular pages in XML format.

Build the URL

To build the URL of the API call, you need:

  • your Matomo base URL (replace demo.matomo.cloud with the URL and path of your Matomo server

    https://demo.matomo.cloud/?module=API

  • the name of the method you want to call. It has the format moduleName.methodToCall (see the list on API Methods). In this example, let's request the most viewed Pages' titles with Actions.getPageTitles:

    method=Actions.getPageTitles

  • the website id

    idSite=1

  • the date parameter. This can be today, yesterday, or any date with the format YYYY-MM-DD

    date=yesterday

  • the period parameter. This can be day, week, month or year

    period=day

    Alternatively, if you wanted to request all pages from a given date, you could use a date range parameter. For example, to request all pages since January 1st 2021:period=range&date=2011-01-21,yesterday

  • the format parameter. Defines the output format of the data: XML, JSON, CSV, PHP (serialized PHP), HTML (simple html)

    format=xml

  • (optional) to keep the example simple, we ask only for the Visits & Unique visitors metrics to be returned:

    showColumns=nb_visits,nb_uniq_visitors

  • (optional) the filter_limit parameter that defines the number of rows returned

    filter_limit=10

The final url is demo.matomo.cloud/?module=API&method=Actions.getPageTitles&idSite=1&date=yesterday&period=day&format=xml&filter_limit=10&showColumns=nb_visits,nb_uniq_visitors

XML Output

Here is the output of this request:

<?xml version="1.0" encoding="utf-8" ?>
<result>
	<row>
		<label> Cart - Divezone Store</label>
		<nb_visits>1033</nb_visits>
		<nb_uniq_visitors>881</nb_uniq_visitors>
		<segment>pageTitle==Cart%2B-%2BDivezone%2BStore</segment>
	</row>
	<row>
		<label> Diving Jobs, latest Divemaster and Scuba Dive Instructor Job offers!</label>
		<nb_visits>874</nb_visits>
		<nb_uniq_visitors>804</nb_uniq_visitors>
		<segment>pageTitle==Diving%2BJobs%252C%2Blatest%2BDivemaster%2Band%2BScuba%2BDive%2BInstructor%2BJob%2Boffers%2521</segment>
	</row>
	<row>
		<label> Checkout - Divezone Store</label>
		<nb_visits>821</nb_visits>
		<nb_uniq_visitors>718</nb_uniq_visitors>
		<segment>pageTitle==Checkout%2B-%2BDivezone%2BStore</segment>
	</row>
	<row>
		<label> Best Diving sites in Bali &ndash; Indonesia Scuba dive reviews by Divezone</label>
		<nb_visits>589</nb_visits>
		<nb_uniq_visitors>567</nb_uniq_visitors>
		<segment>pageTitle==Best%2BDiving%2Bsites%2Bin%2BBali%2B%25E2%2580%2593%2BIndonesia%2BScuba%2Bdive%2Breviews%2Bby%2BDivezone</segment>
	</row>
	<row>
		<label> My Account - Divezone Store</label>
		<nb_visits>467</nb_visits>
		<nb_uniq_visitors>412</nb_uniq_visitors>
		<segment>pageTitle==My%2BAccount%2B-%2BDivezone%2BStore</segment>
	</row>
	<row>
		<label> Divezone Brand Diving Tank - Divezone Store</label>
		<nb_visits>419</nb_visits>
		<nb_uniq_visitors>378</nb_uniq_visitors>
		<segment>pageTitle==Divezone%2BBrand%2BDiving%2BTank%2B-%2BDivezone%2BStore</segment>
	</row>
	<row>
		<label> Divezone Brand Basic Wetsuit - Divezone Store</label>
		<nb_visits>406</nb_visits>
		<nb_uniq_visitors>346</nb_uniq_visitors>
		<segment>pageTitle==Divezone%2BBrand%2BBasic%2BWetsuit%2B-%2BDivezone%2BStore</segment>
	</row>
	<row>
		<label> Divezone Store</label>
		<nb_visits>359</nb_visits>
		<nb_uniq_visitors>319</nb_uniq_visitors>
		<segment>pageTitle==Divezone%2BStore</segment>
	</row>
	<row>
		<label> Best Diving sites in Indonesia &ndash; Scuba dive reviews by Divezone</label>
		<nb_visits>315</nb_visits>
		<nb_uniq_visitors>307</nb_uniq_visitors>
		<segment>pageTitle==Best%2BDiving%2Bsites%2Bin%2BIndonesia%2B%25E2%2580%2593%2BScuba%2Bdive%2Breviews%2Bby%2BDivezone</segment>
	</row>
	<row>
		<label> Divezone Brand Scuba Fins - Divezone Store</label>
		<nb_visits>280</nb_visits>
		<nb_uniq_visitors>244</nb_uniq_visitors>
		<segment>pageTitle==Divezone%2BBrand%2BScuba%2BFins%2B-%2BDivezone%2BStore</segment>
	</row>
</result>

Other examples

You can get the data in one of these formats: XML, JSON, HTML, CSV, TSV, etc. See the API Reference for the documentation.

There are also functions for Websites, Users, Goals, PDF Reports (create, update, delete operations) and a lot more, such as: adding Annotations, creating custom Segments,