{"id":18310696,"url":"https://github.com/visualappeal/matomo-php-api","last_synced_at":"2025-05-15T23:03:55.643Z","repository":{"id":2552702,"uuid":"3531101","full_name":"VisualAppeal/Matomo-PHP-API","owner":"VisualAppeal","description":"PHP wrapper for the Matomo API.","archived":false,"fork":false,"pushed_at":"2025-03-07T11:27:50.000Z","size":472,"stargazers_count":94,"open_issues_count":3,"forks_count":32,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-15T23:03:42.715Z","etag":null,"topics":["matomo","matomo-api","matomo-php-api","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VisualAppeal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-02-23T23:45:54.000Z","updated_at":"2025-03-30T02:54:41.000Z","dependencies_parsed_at":"2025-03-29T11:01:35.968Z","dependency_job_id":"651ec4e8-56c3-4cd3-96bf-1d6d5edcf6c7","html_url":"https://github.com/VisualAppeal/Matomo-PHP-API","commit_stats":{"total_commits":152,"total_committers":16,"mean_commits":9.5,"dds":0.3486842105263158,"last_synced_commit":"2e680baabb334c0d6cd74fd35f964c4c73168fae"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VisualAppeal%2FMatomo-PHP-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VisualAppeal%2FMatomo-PHP-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VisualAppeal%2FMatomo-PHP-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VisualAppeal%2FMatomo-PHP-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VisualAppeal","download_url":"https://codeload.github.com/VisualAppeal/Matomo-PHP-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436944,"owners_count":22070946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matomo","matomo-api","matomo-php-api","php"],"created_at":"2024-11-05T16:15:16.818Z","updated_at":"2025-05-15T23:03:55.605Z","avatar_url":"https://github.com/VisualAppeal.png","language":"PHP","readme":"# Matomo PHP API\n\n[![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://img.shields.io/packagist/dt/visualappeal/matomo-php-api)](https://packagist.org/packages/visualappeal/matomo-php-api)\n\nA PHP wrapper class for the [Matomo](https://matomo.org/) API.\n\n## Requirements\n\n* PHP \u003e= 8.0 (for php 7.3/7.4 use version 1.6.1)\n* cUrl (php-curl)\n* JSON (php-json)\n\n## Install\n\nThis library can be installed via composer: `composer require visualappeal/matomo-php-api`\n\n## Usage\n\n### Create an instance of matomo\n\n```php\nrequire(__DIR__ . '/vendor/autoload.php');\n\nuse VisualAppeal\\Matomo;\n\n$matomo = new Matomo('http://stats.example.org', 'my_access_token', 'siteId');\n```\n\nThere are some basic parameters (period, date, range) which you can define at the beginning. They do not change until you reset them with\n\n```php\n$matomo-\u003ereset();\n```\n\nSo you can execute multiple requests without specifying the parameters again.\n\n### siteId\n\nThe ID of your website, single number, list separated through comma `\"1,4,7\"`, or `\"all\"`.\n\n### period\n\nThe period you request the statistics for\n\n```php\nMatomo::PERIOD_DAY\nMatomo::PERIOD_WEEK\nMatomo::PERIOD_MONTH\nMatomo::PERIOD_YEAR\nMatomo::PERIOD_RANGE\n```\n\nIf you set the period to `Matomo::PERIOD_RANGE` you can specify the range via\n\n```php\n$matomo-\u003esetRange('2012-01-14', '2012-04-30'); //All data from the first to the last date\n$matomo-\u003esetRange('2012-01-14', Matomo::DATE_YESTERDAY); //All data from the first date until yesterday\n$matomo-\u003esetRange('2012-01-14'); //All data from the first date until now\n```\n\nIf you set it to something other than `Matomo::PERIOD_RANGE` you can specify the date via:\n\n```php\n$matomo-\u003esetPeriod(x);\n$matomo-\u003esetDate('2012-03-03');\n\nCase x of PERIOD_DAY the report is created for the third of march, 2012\nCase x of PERIOD_WEEK the report is created for the first week of march, 2012\nCase x of PERIOD_MONTH the report is created for march, 2012\nCase x of PERIOD_YEAR the report is created for 2012\n```\n\n### date\n\nSet the date via\n\n```php\n$matomo-\u003esetDate('YYYY-mm-dd');\n```\n\nOr use the constants\n\n```php\n$matomo-\u003esetDate(Matomo::DATE_TODAY);\n$matomo-\u003esetDate(Matomo::DATE_YESTERDAY);\n```\n\nReport for the last seven weeks including the current week\n\n```php\n$matomo-\u003esetPeriod(Matomo::PERIOD_WEEK);\n$matomo-\u003esetDate('last7');\n```\n\nReport for the last 2 years without the current year\n\n```\n$matomo-\u003esetPeriod(Matomo::PERIOD_YEAR);\n$matomo-\u003esetDate('previous2');\n```\n\n### segment, idSubtable, expanded\n\nFor 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.\n\n### format\n\nSpecify a output format via\n\n```php\n$matomo-\u003esetFormat(Matomo::FORMAT_JSON);\n```\n\nJSON is converted with `json_decode` before returning the request.\n\nAll available formats\n\n```php\nMatomo::FORMAT_XML\nMatomo::FORMAT_JSON\nMatomo::FORMAT_CSV\nMatomo::FORMAT_TSV\nMatomo::FORMAT_HTML\nMatomo::FORMAT_RSS\nMatomo::FORMAT_PHP\n```\n\n\n## Example\n\nGet all the unique visitors from yesterday:\n\n```php\nrequire(__DIR__ . '/vendor/autoload.php');\n\nuse VisualAppeal\\Matomo;\n\n$matomo = new Matomo('http://stats.example.org', 'my_access_token', 1, Matomo::FORMAT_JSON);\n\n$matomo-\u003esetPeriod(Matomo::PERIOD_DAY);\n$matomo-\u003esetDate(Matomo::DATE_YESTERDAY);\n\necho 'Unique visitors yesterday: ' . $matomo-\u003egetUniqueVisitors();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisualappeal%2Fmatomo-php-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvisualappeal%2Fmatomo-php-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisualappeal%2Fmatomo-php-api/lists"}