PHPackages                             visualappeal/piwik-php-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. visualappeal/piwik-php-api

Abandoned → [visualappeal/matomo-php-api](/?search=visualappeal%2Fmatomo-php-api)Library[API Development](/categories/api)

visualappeal/piwik-php-api
==========================

API wrapper for matomo

2.1.0(1y ago)9731.5k33[3 issues](https://github.com/VisualAppeal/Matomo-PHP-API/issues)MITPHPPHP &gt;=8.2CI failing

Since Jul 24Pushed 1y ago8 watchersCompare

[ Source](https://github.com/VisualAppeal/Matomo-PHP-API)[ Packagist](https://packagist.org/packages/visualappeal/piwik-php-api)[ RSS](/packages/visualappeal-piwik-php-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (26)Used By (0)

Matomo PHP API
==============

[](#matomo-php-api)

[![PHPUnit](https://github.com/VisualAppeal/Matomo-PHP-API/actions/workflows/tests.yml/badge.svg)](https://github.com/VisualAppeal/Matomo-PHP-API/actions/workflows/tests.yml) [![Packagist](https://camo.githubusercontent.com/f7bbdcf4b344c309d376dfddaf61a8a13a49cbb44c619693f2ef8c6b270084d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76697375616c61707065616c2f6d61746f6d6f2d7068702d617069)](https://packagist.org/packages/visualappeal/matomo-php-api)

A PHP wrapper class for the [Matomo](https://matomo.org/) API.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0 (for php 7.3/7.4 use version 1.6.1)
- cUrl (php-curl)
- JSON (php-json)

Install
-------

[](#install)

This library can be installed via composer: `composer require visualappeal/matomo-php-api`

Usage
-----

[](#usage)

### Create an instance of matomo

[](#create-an-instance-of-matomo)

```
require(__DIR__ . '/vendor/autoload.php');

use VisualAppeal\Matomo;

$matomo = new Matomo('http://stats.example.org', 'my_access_token', 'siteId');
```

There are some basic parameters (period, date, range) which you can define at the beginning. They do not change until you reset them with

```
$matomo->reset();
```

So you can execute multiple requests without specifying the parameters again.

### siteId

[](#siteid)

The ID of your website, single number, list separated through comma `"1,4,7"`, or `"all"`.

### period

[](#period)

The period you request the statistics for

```
Matomo::PERIOD_DAY
Matomo::PERIOD_WEEK
Matomo::PERIOD_MONTH
Matomo::PERIOD_YEAR
Matomo::PERIOD_RANGE
```

If you set the period to `Matomo::PERIOD_RANGE` you can specify the range via

```
$matomo->setRange('2012-01-14', '2012-04-30'); //All data from the first to the last date
$matomo->setRange('2012-01-14', Matomo::DATE_YESTERDAY); //All data from the first date until yesterday
$matomo->setRange('2012-01-14'); //All data from the first date until now
```

If you set it to something other than `Matomo::PERIOD_RANGE` you can specify the date via:

```
$matomo->setPeriod(x);
$matomo->setDate('2012-03-03');

Case x of PERIOD_DAY the report is created for the third of march, 2012
Case x of PERIOD_WEEK the report is created for the first week of march, 2012
Case x of PERIOD_MONTH the report is created for march, 2012
Case x of PERIOD_YEAR the report is created for 2012
```

### date

[](#date)

Set the date via

```
$matomo->setDate('YYYY-mm-dd');
```

Or use the constants

```
$matomo->setDate(Matomo::DATE_TODAY);
$matomo->setDate(Matomo::DATE_YESTERDAY);
```

Report for the last seven weeks including the current week

```
$matomo->setPeriod(Matomo::PERIOD_WEEK);
$matomo->setDate('last7');
```

Report for the last 2 years without the current year

```
$matomo->setPeriod(Matomo::PERIOD_YEAR);
$matomo->setDate('previous2');

```

### segment, idSubtable, expanded

[](#segment-idsubtable-expanded)

For some functions you can specify `segment`, `idSubtable` and `expanded`. Please refer to the matomo [segment documentation](https://developer.matomo.org/api-reference/reporting-api-segmentation) and to the [api reference](https://developer.matomo.org/api-reference/reporting-api) for more information about these parameters.

### format

[](#format)

Specify a output format via

```
$matomo->setFormat(Matomo::FORMAT_JSON);
```

JSON is converted with `json_decode` before returning the request.

All available formats

```
Matomo::FORMAT_XML
Matomo::FORMAT_JSON
Matomo::FORMAT_CSV
Matomo::FORMAT_TSV
Matomo::FORMAT_HTML
Matomo::FORMAT_RSS
Matomo::FORMAT_PHP
```

Example
-------

[](#example)

Get all the unique visitors from yesterday:

```
require(__DIR__ . '/vendor/autoload.php');

use VisualAppeal\Matomo;

$matomo = new Matomo('http://stats.example.org', 'my_access_token', 1, Matomo::FORMAT_JSON);

$matomo->setPeriod(Matomo::PERIOD_DAY);
$matomo->setDate(Matomo::DATE_YESTERDAY);

echo 'Unique visitors yesterday: ' . $matomo->getUniqueVisitors();
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance43

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor3

3 contributors hold 50%+ of commits

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 ~161 days

Recently: every ~415 days

Total

25

Last Release

437d ago

Major Versions

1.7.0 → 2.0.02023-06-14

PHP version history (7 changes)1.0.0PHP &gt;=5.3.0

1.1.2PHP &gt;=5.4.0

1.3.0PHP &gt;=7

1.5.0PHP &gt;=7.2

1.6.0PHP &gt;=7.3

1.7.0PHP &gt;=8.0

2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/81e28043849dc03142de395d05318c70cb408e645ebd5a3985ab5896c30951e0?d=identicon)[thelfensdrfer](/maintainers/thelfensdrfer)

---

Top Contributors

[![hackolein](https://avatars.githubusercontent.com/u/7509171?v=4)](https://github.com/hackolein "hackolein (11 commits)")[![voku](https://avatars.githubusercontent.com/u/264695?v=4)](https://github.com/voku "voku (8 commits)")[![teodortalov](https://avatars.githubusercontent.com/u/2781820?v=4)](https://github.com/teodortalov "teodortalov (6 commits)")[![simonschaufi](https://avatars.githubusercontent.com/u/941794?v=4)](https://github.com/simonschaufi "simonschaufi (4 commits)")[![bashilbers](https://avatars.githubusercontent.com/u/455905?v=4)](https://github.com/bashilbers "bashilbers (3 commits)")[![axelcho](https://avatars.githubusercontent.com/u/1785573?v=4)](https://github.com/axelcho "axelcho (2 commits)")[![stayallive](https://avatars.githubusercontent.com/u/1090754?v=4)](https://github.com/stayallive "stayallive (2 commits)")[![zhkarl](https://avatars.githubusercontent.com/u/22057443?v=4)](https://github.com/zhkarl "zhkarl (1 commits)")[![janyksteenbeek](https://avatars.githubusercontent.com/u/3578636?v=4)](https://github.com/janyksteenbeek "janyksteenbeek (1 commits)")[![jnngr](https://avatars.githubusercontent.com/u/15106609?v=4)](https://github.com/jnngr "jnngr (1 commits)")[![michael2h4ng](https://avatars.githubusercontent.com/u/5486783?v=4)](https://github.com/michael2h4ng "michael2h4ng (1 commits)")[![oparoz](https://avatars.githubusercontent.com/u/323220?v=4)](https://github.com/oparoz "oparoz (1 commits)")[![webkluns](https://avatars.githubusercontent.com/u/404160?v=4)](https://github.com/webkluns "webkluns (1 commits)")

---

Tags

matomomatomo-apimatomo-php-apiphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[codedredd/laravel-soap

A SoapClient wrapper integration for Laravel

221516.6k3](/packages/codedredd-laravel-soap)[visualappeal/matomo-php-api

API wrapper for matomo

95230.3k](/packages/visualappeal-matomo-php-api)[craftpulse/craft-typesense

Craft Plugin that synchronises with Typesense

122.7k](/packages/craftpulse-craft-typesense)

PHPackages © 2026

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