Piwik API Tutorial: Get Your Top 10 Keywords

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

Build the URL

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

The final url is http://demo.piwik.org/?module=API&method=Referrers.getKeywords&idSite=3&date=yesterday&period=day&format=xml&filter_limit=10

XML Output

Here is the output of this request:

<?xml version="1.0" encoding="utf-8" ?>
<result>
	<row>
		<label>Keyword not defined</label>
		<nb_uniq_visitors>6</nb_uniq_visitors>
		<nb_visits>6</nb_visits>
		<nb_actions>9</nb_actions>
		<max_actions>3</max_actions>
		<sum_visit_length>1043</sum_visit_length>
		<bounce_count>4</bounce_count>
		<nb_visits_converted>0</nb_visits_converted>
		<idsubdatatable>2</idsubdatatable>
	</row>
	<row>
		<label>drums</label>
		<nb_uniq_visitors>1</nb_uniq_visitors>
		<nb_visits>1</nb_visits>
		<nb_actions>1</nb_actions>
		<max_actions>1</max_actions>
		<sum_visit_length>0</sum_visit_length>
		<bounce_count>1</bounce_count>
		<nb_visits_converted>0</nb_visits_converted>
		<idsubdatatable>3</idsubdatatable>
	</row>
	<row>
		<label>virtual drum</label>
		<nb_uniq_visitors>1</nb_uniq_visitors>
		<nb_visits>1</nb_visits>
		<nb_actions>1</nb_actions>
		<max_actions>1</max_actions>
		<sum_visit_length>0</sum_visit_length>
		<bounce_count>1</bounce_count>
		<nb_visits_converted>0</nb_visits_converted>
		<idsubdatatable>5</idsubdatatable>
	</row>
	<row>
		<label>virtual drums kit</label>
		<nb_uniq_visitors>1</nb_uniq_visitors>
		<nb_visits>1</nb_visits>
		<nb_actions>1</nb_actions>
		<max_actions>1</max_actions>
		<sum_visit_length>0</sum_visit_length>
		<bounce_count>1</bounce_count>
		<nb_visits_converted>0</nb_visits_converted>
		<idsubdatatable>4</idsubdatatable>
	</row>
</result>

Other useful examples

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,

Check out the Piwik API Reference