PHPackages                             devhelp/piwik-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. devhelp/piwik-api

ActiveLibrary[API Development](/categories/api)

devhelp/piwik-api
=================

Provides self-contained piwik methods that are able to make call to api with predefined or/and runtime arguments

1.0(10y ago)037.1k3MITPHPPHP &gt;=5.3

Since Apr 17Pushed 9y ago4 watchersCompare

[ Source](https://github.com/devhelp/piwik-api)[ Packagist](https://packagist.org/packages/devhelp/piwik-api)[ Docs](http://devhelp.pl)[ RSS](/packages/devhelp-piwik-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (3)

[![Build Status](https://camo.githubusercontent.com/1cc00e111ef5d983b2de554af6285f4b931914ed476edcd9e2da2fcfed780c94/68747470733a2f2f7472617669732d63692e6f72672f64657668656c702f706977696b2d6170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/devhelp/piwik-api)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/63197e7a59440acb7d96682e4167f3020b07100cb25560e67529592c6b2b9505/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64657668656c702f706977696b2d6170692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/devhelp/piwik-api?branch=master)

Purpose
-------

[](#purpose)

Helps creating self-contained Piwik methods that are able to make call to [Piwik API](http://developer.piwik.org/api-reference/reporting-api) with predefined or/and runtime arguments. Helps in using [Piwik segmentation](http://developer.piwik.org/api-reference/reporting-api-segmentation) and in lazy-loading api parameters values on method call.

Installation
------------

[](#installation)

```
$ composer require devhelp/piwik-api

```

Please check [composer website](http://getcomposer.org) for more information.

Usage
-----

[](#usage)

Basically only thing that you need to implement in order to be able to use the `Method` is your `PiwikClient` class. There is an already implemented `PiwikGuzzleClient` for which you have to configure the `Guzzle` http client.

You can include `PiwikGuzzleClient` by adding [devhelp/piwik-api-guzzle](http://github.com/devhelp/piwik-api-guzzle) in composer.json

### Standalone Method usage

[](#standalone-method-usage)

```
$myPiwikClient = new MyPiwikClient();

$method = new Method($myPiwikClient, 'http://my.piwik.pro', 'MyModule.myAction')

$method->call(array('token_auth' => $myPiwikToken));
```

### Creating multiple methods with Api

[](#creating-multiple-methods-with-api)

```
$myPiwikClient = new MyPiwikClient();

$api = new Api($myPiwikClient, 'http://my.piwik.pro');
$api->setDefaultParams(array(
    'token_auth' => $myPiwikToken,
));

$api->getMethod('MyModule.myAction')->call();
$api->getMethod('MyOtherModule.myOtherAction')->call();
$api->getMethod('MyXXXModule.myXXXAction')->call();
```

### Passing parameters to the call

[](#passing-parameters-to-the-call)

This can be done be passing an array on method call or setting it as default params for the method or the whole api. Parameters can be either a scalar, a callback or an object implementing `Param` interface.

When parameter value implements a `Param` interface or is a callback then it's final value is resolved on call() runtime (resulting in lazy-loaded param value). There is a Segment param that will be explained later. Lazy-loading can be particularly useful for returning a token\_auth by user that is currently logged in

```
$params = array(
    'myCustomVar1' => 'someValue',
    'myCustomVar2' => function() {/*..*/},
    'token_auth' => new LazyTokenAuthValue()
);

$api->getMethod('MyModule.myAction')->call($params);

/*
 * params to which $params array will be resolved on method call are:
 * array(
 *     'myCustomVar1' => 'someValue',
 *     'myCustomVar2' => ..., //this what was resolved from anonymous function
 *     'token_auth' => ..., //this what was resolved from LazyTokenAuthValue
 * );
 */
```

### Using segments

[](#using-segments)

`Segment` param has its own implementation that allows to build Piwik segment query. It's value is resolved on call

```
use Devhelp\Piwik\Api\Param\Segment as SegmentParam;
use Devhelp\Piwik\Api\Param\Segment\Segment;

$segment = new Segment();

$segment->where(new Equals('country', 'PL'))
        ->andWhere(new NotEquals('actions', 1))
        ->andWhere(new Contains('referrerName', 'piwik'))
        ->orWhere(new DoesNotContain('referrerKeyword', 'myBrand'));

$params = array('segment' => new SegmentParam($segment));

/*
 * this will be resolved to
 * array('segment' => 'country==PL;actions!=1;referrerName=@piwik,referrerKeyword!@myBrand');
 */
```

### Integrations

[](#integrations)

- [devhelp/piwik-bundle](http://github.com/devhelp/piwik-bundle)
- [devhelp/piwik-silex-provider](http://github.com/devhelp/piwik-silex-provider)

Credits
-------

[](#credits)

Brought to you by: [devhelp.pl](http://devhelp.pl)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~58 days

Total

5

Last Release

3817d ago

Major Versions

0.4 → 1.02015-12-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1479355?v=4)[devhelp](/maintainers/devhelp)[@devhelp](https://github.com/devhelp)

---

Top Contributors

[![pawelbaranski](https://avatars.githubusercontent.com/u/219097?v=4)](https://github.com/pawelbaranski "pawelbaranski (31 commits)")

---

Tags

matomopiwikpiwik-api

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/devhelp-piwik-api/health.svg)

```
[![Health](https://phpackages.com/badges/devhelp-piwik-api/health.svg)](https://phpackages.com/packages/devhelp-piwik-api)
```

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69433.0M114](/packages/algolia-algoliasearch-client-php)[swisnl/json-api-client

A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.

211473.2k12](/packages/swisnl-json-api-client)[php-heroku-client/php-heroku-client

A PHP client for the Heroku Platform API

24404.8k4](/packages/php-heroku-client-php-heroku-client)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

27539.9k1](/packages/yoti-yoti-php-sdk)[trycourier/courier

Courier PHP SDK

16643.9k](/packages/trycourier-courier)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
