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>967</nb_visits>
<nb_uniq_visitors>816</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>836</nb_visits>
<nb_uniq_visitors>791</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>723</nb_visits>
<nb_uniq_visitors>631</nb_uniq_visitors>
<segment>pageTitle==Checkout%2B-%2BDivezone%2BStore</segment>
</row>
<row>
<label> Best Diving sites in Bali – Indonesia Scuba dive reviews by Divezone</label>
<nb_visits>544</nb_visits>
<nb_uniq_visitors>521</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>399</nb_visits>
<nb_uniq_visitors>352</nb_uniq_visitors>
<segment>pageTitle==My%2BAccount%2B-%2BDivezone%2BStore</segment>
</row>
<row>
<label> Divezone Brand Diving Tank - Divezone Store</label>
<nb_visits>397</nb_visits>
<nb_uniq_visitors>356</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>386</nb_visits>
<nb_uniq_visitors>330</nb_uniq_visitors>
<segment>pageTitle==Divezone%2BBrand%2BBasic%2BWetsuit%2B-%2BDivezone%2BStore</segment>
</row>
<row>
<label> Divezone Store</label>
<nb_visits>341</nb_visits>
<nb_uniq_visitors>305</nb_uniq_visitors>
<segment>pageTitle==Divezone%2BStore</segment>
</row>
<row>
<label> Best Diving sites in Indonesia – Scuba dive reviews by Divezone</label>
<nb_visits>299</nb_visits>
<nb_uniq_visitors>291</nb_uniq_visitors>
<segment>pageTitle==Best%2BDiving%2Bsites%2Bin%2BIndonesia%2B%25E2%2580%2593%2BScuba%2Bdive%2Breviews%2Bby%2BDivezone</segment>
</row>
<row>
<label> Page Name not defined</label>
<nb_visits>284</nb_visits>
<nb_uniq_visitors>253</nb_uniq_visitors>
<segment>pageTitle==</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,