Piwik\Plugin\

API

The base class of all API singletons.

Plugins that want to expose functionality through the Reporting API should create a class that extends this one. Every public method in that class that is not annotated with @ignore will be callable through Matomo's Web API.

Note: If your plugin calculates and stores reports, they should be made available through the API.

Examples

Defining an API for a plugin

class API extends \Piwik\Plugin\API
{
    public function myMethod($idSite, $period, $date, $segment = false)
    {
        $dataTable = // ... get some data ...
        return $dataTable;
    }
}

Linking to an API method

<a href="?module=API&method=MyPlugin.myMethod&idSite=1&period=day&date=2013-10-23">Link</a>

Methods

The abstract class defines the following methods:

  • getInstance() — Returns the singleton instance for the derived class.
  • confirmCurrentUserPassword() — Verifies that the given password matches the current user's password, and throws if it is empty or wrong.

getInstance()

Returns the singleton instance for the derived class. If the singleton instance has not been created, this method will create it.

Signature

  • It returns a API value.

confirmCurrentUserPassword()

Verifies that the given password matches the current user's password, and throws if it is empty or wrong.

Does nothing when the Login.userRequiresPasswordConfirmation event disables the confirmation for the user.

Signature

  • It accepts the following parameter(s):
    • $passwordConfirmation (string) — The password entered by the user.
  • It does not return anything or a mixed result.
  • It throws one of the following exceptions: