PHP Class Piwik\Plugins\API\API

Some of the information that is returned by the Metadata API:
  • the dynamically generated list of all API methods via "getReportMetadata"
  • the list of metrics that will be returned by each method, along with their human readable name, via "getDefaultMetrics" and "getDefaultProcessedMetrics"
  • the list of segments metadata supported by all functions that have a 'segment' parameter
  • the (truly magic) method "getProcessedReport" will return a human readable version of any other report, and include the processed metrics such as conversion rate, time on site, etc. which are not directly available in other methods.
  • the method "getSuggestedValuesForSegment" returns top suggested values for a particular segment. It uses the Live.getLastVisitsDetails API to fetch the most recently used values, and will return the most often used values first.
The Metadata API is for example used by the Piwik Mobile App to automatically display all Piwik reports, with translated report & columns names and nicely formatted values. More information on the Metadata API documentation page
Inheritance: extends Piwik\Plugin\API
Afficher le fichier Open project: piwik/piwik Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( SettingsProvider $settingsProvider, ProcessedReport $processedReport )
get ( $idSite, $period, $date, $segment = false, $columns = false ) Get a combined report of the *.get API methods.
getAvailableMeasurableTypes ( ) : array Returns all available measurable types.
getBulkRequest ( array $urls ) : array Performs multiple API requests at once and returns every result.
getDefaultMetricTranslations ( ) : array Default translations for many core metrics.
getGlossaryMetrics ( $idSite ) : array A glossary of all metrics and their definition
getGlossaryReports ( $idSite ) : array A glossary of all reports and their definition
getHeaderLogoUrl ( boolean $pathOnly = false ) : string Returns the url to header logo (~127x50px)
getIpFromHeader ( ) : string Returns the most accurate IP address available for the current user, in IPv4 format. This could be the proxy client's IP address.
getLogoUrl ( boolean $pathOnly = false ) : string Returns the url to application logo (~280x110px)
getMetadata ( $idSite, $apiModule, $apiAction, $apiParameters = [], $language = false, $period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false ) Loads reports metadata, then return the requested one, matching optional API parameters.
getPiwikVersion ( ) : string Get Piwik version
getProcessedReport ( $idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters = false, $idGoal = false, $language = false, $showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false, $format_metrics = null, $idDimension = false )
getReportMetadata ( string $idSites = '', boolean | string $period = false, boolean | Date $date = false, boolean $hideMetricsDoc = false, boolean $showSubtableReports = false, integer $idSite = false ) : array Triggers a hook to ask plugins for available Reports.
getReportPagesMetadata ( integer $idSite ) : array Get a list of all pages that shall be shown in a Piwik UI including a list of all widgets that shall be shown within each page.
getRowEvolution ( integer $idSite, string $period, Date $date, string $apiModule, string $apiAction, boolean | string $label = false, boolean | string $segment = false, boolean | string $column = false, boolean | string $language = false, boolean | integer $idGoal = false, boolean | string $legendAppendMetric = true, boolean | string $labelUseAbsoluteUrl = true, boolean | integer $idDimension = false ) : array Given an API report to query (eg. "Referrers.getKeywords", and a Label (eg. "free%20software"), this function will query the API for the previous days/weeks/etc. and will return a ready to use data structure containing the metrics for the requested Label, along with enriched information (min/max values, etc.)
getSVGLogoUrl ( boolean $pathOnly = false ) : string Returns the URL to application SVG Logo
getSegmentsMetadata ( $idSites = [], $_hideImplementationData = true )
getSettings ( ) : array Returns the section [APISettings] if defined in config.ini.php
getSuggestedValuesForSegment ( $segmentName, $idSite ) : array Given a segment, will return a list of the most used values for this particular segment.
getWidgetMetadata ( integer $idSite ) : array Get a list of all widgetizable widgets.
hasSVGLogo ( ) : boolean Returns whether there is an SVG Logo available.
isPluginActivated ( string $pluginName ) : boolean Return true if plugin is activated, false otherwise

Méthodes protégées

Méthode Description
doesSegmentNeedActionsData ( $segmentName ) : boolean
getSegmentValuesFromVisitorLog ( $segmentName, $table ) : array

Private Methods

Méthode Description
doesSuggestedValuesCallbackNeedData ( $suggestedValuesCallback )
findSegment ( $segmentName, $idSite )
getMostFrequentValues ( $values ) : array
getSuggestedValuesForSegmentName ( $idSite, $segment, $maxSuggestionsToReturn )

Method Details

__construct() public méthode

public __construct ( SettingsProvider $settingsProvider, ProcessedReport $processedReport )
$settingsProvider Piwik\Plugin\SettingsProvider
$processedReport ProcessedReport

doesSegmentNeedActionsData() protected méthode

protected doesSegmentNeedActionsData ( $segmentName ) : boolean
$segmentName
Résultat boolean

get() public méthode

Get a combined report of the *.get API methods.
public get ( $idSite, $period, $date, $segment = false, $columns = false )

getAvailableMeasurableTypes() public méthode

Marked as deprecated so it won't appear in API page. It won't be a public API for now.
Deprecation:
public getAvailableMeasurableTypes ( ) : array
Résultat array

getBulkRequest() public méthode

Performs multiple API requests at once and returns every result.
public getBulkRequest ( array $urls ) : array
$urls array The array of API requests.
Résultat array

getDefaultMetricTranslations() public méthode

This is used for exports with translated labels. The exports contain columns that are not visible in the UI and not present in the API meta data. These columns are translated here.
Deprecation: since Piwik 2.15.1
public getDefaultMetricTranslations ( ) : array
Résultat array

getGlossaryMetrics() public méthode

A glossary of all metrics and their definition
public getGlossaryMetrics ( $idSite ) : array
$idSite
Résultat array

getGlossaryReports() public méthode

A glossary of all reports and their definition
public getGlossaryReports ( $idSite ) : array
$idSite
Résultat array

getHeaderLogoUrl() public méthode

Returns the url to header logo (~127x50px)
Deprecation: since Piwik 2.15.1
public getHeaderLogoUrl ( boolean $pathOnly = false ) : string
$pathOnly boolean If true, returns path relative to doc root. Otherwise, returns a URL.
Résultat string

getIpFromHeader() public méthode

Returns the most accurate IP address available for the current user, in IPv4 format. This could be the proxy client's IP address.
public getIpFromHeader ( ) : string
Résultat string IP address in presentation format.

getLogoUrl() public méthode

Returns the url to application logo (~280x110px)
Deprecation: since Piwik 2.15.1
public getLogoUrl ( boolean $pathOnly = false ) : string
$pathOnly boolean If true, returns path relative to doc root. Otherwise, returns a URL.
Résultat string

getMetadata() public méthode

Loads reports metadata, then return the requested one, matching optional API parameters.
public getMetadata ( $idSite, $apiModule, $apiAction, $apiParameters = [], $language = false, $period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false )

getPiwikVersion() public méthode

Get Piwik version
public getPiwikVersion ( ) : string
Résultat string

getProcessedReport() public méthode

public getProcessedReport ( $idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters = false, $idGoal = false, $language = false, $showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false, $format_metrics = null, $idDimension = false )

getReportMetadata() public méthode

Returns metadata information about each report (category, name, dimension, metrics, etc.)
public getReportMetadata ( string $idSites = '', boolean | string $period = false, boolean | Date $date = false, boolean $hideMetricsDoc = false, boolean $showSubtableReports = false, integer $idSite = false ) : array
$idSites string THIS PARAMETER IS DEPRECATED AND WILL BE REMOVED IN PIWIK 4
$period boolean | string
$date boolean | Piwik\Date
$hideMetricsDoc boolean
$showSubtableReports boolean
$idSite integer
Résultat array

getReportPagesMetadata() public méthode

Get a list of all pages that shall be shown in a Piwik UI including a list of all widgets that shall be shown within each page.
public getReportPagesMetadata ( integer $idSite ) : array
$idSite integer
Résultat array

getRowEvolution() public méthode

Given an API report to query (eg. "Referrers.getKeywords", and a Label (eg. "free%20software"), this function will query the API for the previous days/weeks/etc. and will return a ready to use data structure containing the metrics for the requested Label, along with enriched information (min/max values, etc.)
public getRowEvolution ( integer $idSite, string $period, Date $date, string $apiModule, string $apiAction, boolean | string $label = false, boolean | string $segment = false, boolean | string $column = false, boolean | string $language = false, boolean | integer $idGoal = false, boolean | string $legendAppendMetric = true, boolean | string $labelUseAbsoluteUrl = true, boolean | integer $idDimension = false ) : array
$idSite integer
$period string
$date Piwik\Date
$apiModule string
$apiAction string
$label boolean | string
$segment boolean | string
$column boolean | string
$language boolean | string
$idGoal boolean | integer
$legendAppendMetric boolean | string
$labelUseAbsoluteUrl boolean | string
$idDimension boolean | integer
Résultat array

getSVGLogoUrl() public méthode

Returns the URL to application SVG Logo
public getSVGLogoUrl ( boolean $pathOnly = false ) : string
$pathOnly boolean If true, returns path relative to doc root. Otherwise, returns a URL.
Résultat string

getSegmentValuesFromVisitorLog() protected méthode

protected getSegmentValuesFromVisitorLog ( $segmentName, $table ) : array
$segmentName
$table
Résultat array

getSegmentsMetadata() public méthode

public getSegmentsMetadata ( $idSites = [], $_hideImplementationData = true )

getSettings() public méthode

Returns the section [APISettings] if defined in config.ini.php
public getSettings ( ) : array
Résultat array

getSuggestedValuesForSegment() public méthode

Given a segment, will return a list of the most used values for this particular segment.
public getSuggestedValuesForSegment ( $segmentName, $idSite ) : array
$segmentName
$idSite
Résultat array

getWidgetMetadata() public méthode

Get a list of all widgetizable widgets.
public getWidgetMetadata ( integer $idSite ) : array
$idSite integer
Résultat array

isPluginActivated() public méthode

Return true if plugin is activated, false otherwise
public isPluginActivated ( string $pluginName ) : boolean
$pluginName string
Résultat boolean