| category | Integrate |
|---|---|
| previous | reporting-introduction |
| next | querying-the-reporting-api |
This tutorial will show you how easy it is to request the yesterday's top 10 keywords in XML format.
To build the URL of the API call, you need:
-
your Piwik base URL (replace demo.piwik.org with the URL and path of your Piwik server
-
the name of the method you want to call. It has the format moduleName.methodToCall (see the list on API Methods). You need to request the last keywords from the plugin Referrers:
method=Referrers.getKeywords
-
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 of the keywords from a given date, you could use a date range parameter. For example, to request all of the keywords since January 1st 2011:
period=range&date=2011-01-01,yesterday -
the format parameter. Defines the output format of the data: XML, JSON, CSV, PHP (serialized PHP), HTML (simple html)
format=xml
-
(optional) the filter_limit parameter that defines the number of rows returned
filter_limit=10
The final url is http://demo.piwik.org/?module=API&method=Referrers.getKeywords&idSite=3&date=yesterday&period=day&format=xml&filter_limit=10
Here is the output of this request:
{@include escape http://demo.piwik.org/?module=API&method=Referrers.getKeywords&idSite=3&date=yesterday&period=day&format=xml&filter_limit=10}-
XML of the visits of the last 10 days, one entry per day http://demo.piwik.org/?module=API&method=VisitsSummary.getVisits&idSite=3&period=day&date=last10&format=xml
-
XML containing keywords from the last 3 weeks, one entry per week http://demo.piwik.org/?module=API&method=Referrers.getKeywords&idSite=3&period=week&date=last3&format=xml
-
XML containing the keywords from the last 3 days which match the pattern "piwik" http://demo.piwik.org/?module=API&method=Referrers.getKeywords&idSite=3&period=day&date=last3&format=xml&filter_column=label&filter_pattern=piwik
-
RSS feed containing the top 30 keywords for the last 3 weeks, ordered by the number of actions people did when coming from these keywords http://demo.piwik.org/?module=API&method=Referrers.getKeywords&idSite=3&period=week&date=last3&format=rss&filter_limit=30&filter_sort_column=3 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,