This tutorial will show you how easy it is to request the yesterday's top 10 popular pages in XML format.
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
Here is the output of this request:
<?xml version="1.0" encoding="utf-8" ?>
<result>
<row>
<label> Cart - Divezone Store</label>
<nb_visits>1087</nb_visits>
<nb_uniq_visitors>926</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>855</nb_visits>
<nb_uniq_visitors>792</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>828</nb_visits>
<nb_uniq_visitors>724</nb_uniq_visitors>
<segment>pageTitle==Checkout%2B-%2BDivezone%2BStore</segment>
</row>
<row>
<label> My Account - Divezone Store</label>
<nb_visits>482</nb_visits>
<nb_uniq_visitors>419</nb_uniq_visitors>
<segment>pageTitle==My%2BAccount%2B-%2BDivezone%2BStore</segment>
</row>
<row>
<label> Best Diving sites in Bali – Indonesia Scuba dive reviews by Divezone</label>
<nb_visits>477</nb_visits>
<nb_uniq_visitors>458</nb_uniq_visitors>
<segment>pageTitle==Best%2BDiving%2Bsites%2Bin%2BBali%2B%25E2%2580%2593%2BIndonesia%2BScuba%2Bdive%2Breviews%2Bby%2BDivezone</segment>
</row>
<row>
<label> Divezone Brand Basic Wetsuit - Divezone Store</label>
<nb_visits>438</nb_visits>
<nb_uniq_visitors>369</nb_uniq_visitors>
<segment>pageTitle==Divezone%2BBrand%2BBasic%2BWetsuit%2B-%2BDivezone%2BStore</segment>
</row>
<row>
<label> Divezone Brand Diving Tank - Divezone Store</label>
<nb_visits>433</nb_visits>
<nb_uniq_visitors>393</nb_uniq_visitors>
<segment>pageTitle==Divezone%2BBrand%2BDiving%2BTank%2B-%2BDivezone%2BStore</segment>
</row>
<row>
<label> Divezone Store</label>
<nb_visits>383</nb_visits>
<nb_uniq_visitors>340</nb_uniq_visitors>
<segment>pageTitle==Divezone%2BStore</segment>
</row>
<row>
<label> Page Name not defined</label>
<nb_visits>310</nb_visits>
<nb_uniq_visitors>236</nb_uniq_visitors>
<segment>pageTitle==</segment>
</row>
<row>
<label> Divezone Brand Scuba Fins - Divezone Store</label>
<nb_visits>289</nb_visits>
<nb_uniq_visitors>249</nb_uniq_visitors>
<segment>pageTitle==Divezone%2BBrand%2BScuba%2BFins%2B-%2BDivezone%2BStore</segment>
</row>
</result>
XML of the visits of the last 10 days, one entry per day https://demo.matomo.cloud/?module=API&method=VisitsSummary.getVisits&idSite=1&period=day&date=last10&format=xml
XML of the visits by Aquisition Channel https://demo.matomo.cloud/?module=API&method=Referrers.getReferrerType&idSite=1&period=day&date=last10&format=xml
RSS feed containing the top 30 pages for the last 3 weeks https://demo.matomo.cloud/?module=API&method=Referrers.getKeywords&idSite=1&period=week&date=last3&format=rss&filter_limit=30
XML containing the page titles from the last 3 days which match the pattern "store" https://demo.matomo.cloud/?module=API&method=Actions.getPageTitles&idSite=1&period=day&date=last3&format=xml&filter_column=label&filter_pattern=store
XML containing search engine keywords from the last 3 weeks, one entry per week https://demo.matomo.cloud/?module=API&method=Referrers.getKeywords&idSite=1&period=week&date=last3&translateColumnNames=1&format=xml
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,