PHPackages                             peranetwork/viewstats-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. peranetwork/viewstats-api

ActiveLibrary

peranetwork/viewstats-api
=========================

A PHP wrapper for the ViewStats API

1.0.0(1y ago)10332MITPHPPHP &gt;=7.4

Since Sep 30Pushed 1y ago3 watchersCompare

[ Source](https://github.com/peranetwork/viewstats-api)[ Packagist](https://packagist.org/packages/peranetwork/viewstats-api)[ RSS](/packages/peranetwork-viewstats-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

ViewStats API Wrapper
=====================

[](#viewstats-api-wrapper)

This PHP wrapper provides an easy-to-use interface for interacting with the ViewStats API. It handles authentication, request sending, and response processing, including decryption of encrypted responses.

ViewStats is a platform for tracking and analyzing YouTube channel statistics. The API provides access to various data points, including channel information, video statistics, and more.

Address: [ViewStats](https://viewstats.com)

Features
--------

[](#features)

- Simple interface for making GET and POST requests to the ViewStats API
- Automatic handling of authentication tokens
- Built-in error handling and logging
- Decryption of encrypted API responses
- Easy integration into existing PHP projects

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

[](#requirements)

- PHP 7.4 or higher
- cURL extension
- OpenSSL extension

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

[](#installation)

You can install this package via Composer:

```
composer require peranetwork/viewstats-api
```

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
require 'vendor/autoload.php';

use ViewStatsWrapper\ViewStatsAPI;

$apiToken = '32ev9m0qggn227ng1rgpbv5j8qllas8uleujji3499g9had6oj7f0ltnvrgi00cq';
$api = new ViewStatsAPI($apiToken);

try {
    $popularChannels = $api->get('/channels/popular', ['total' => 1]);
    print_r($popularChannels);
} catch (\ViewStatsWrapper\Exceptions\APIException $e) {
    echo "API Error: " . $e->getMessage();
} catch (\ViewStatsWrapper\Exceptions\DecryptionException $e) {
    echo "Decryption Error: " . $e->getMessage();
}
```

### Making GET requests

[](#making-get-requests)

```
$params = ['param1' => 'value1', 'param2' => 'value2'];
$response = $api->get('/endpoint', $params);
```

### Making POST requests

[](#making-post-requests)

```
$data = ['key1' => 'value1', 'key2' => 'value2'];
$response = $api->post('/endpoint', $data);
```

API Endpoints
-------------

[](#api-endpoints)

Here are some example endpoints you can use with this wrapper:

### GET Requests

[](#get-requests)

1. Channel Information:

    ```
    $api->get('/channels/@delba');
    ```
2. Channel About Me:

    ```
    $api->get('/channels/@delba/aboutMe');
    ```
3. Channel Stats:

    ```
    $api->get('/channels/@delba/stats', [
        'range' => '28',
        'groupBy' => 'daily',
        'sortOrder' => 'ASC',
        'withRevenue' => 'true',
        'withEvents' => 'true',
        'withBreakdown' => 'false',
        'withToday' => 'false'
    ]);
    ```
4. All-time Channel Stats:

    ```
    $api->get('/channels/@delba/stats', [
        'range' => 'alltime',
        'groupBy' => 'daily',
        'sortOrder' => 'ASC',
        'withRevenue' => 'true',
        'withEvents' => 'false',
        'withBreakdown' => 'false'
    ]);
    ```
5. Monthly Channel Stats:

    ```
    $api->get('/channels/@delba/stats', [
        'range' => '365',
        'groupBy' => 'monthly',
        'sortOrder' => 'ASC',
        'withRevenue' => 'true',
        'withEvents' => 'true',
        'withBreakdown' => 'false',
        'withToday' => 'false'
    ]);
    ```
6. Long and Short Videos:

    ```
    $api->get('/channels/@delba/longsAndShorts');
    ```
7. Featured Video:

    ```
    $api->get('/channels/@delba/featuredVideo');
    ```
8. Channel Averages:

    ```
    $api->get('/channels/@delba/averages');
    ```
9. Channel Videos:

    ```
    $api->get('/channels/@delba/videos', [
        'orderBy' => 'uploadDate',
        'limit' => '40',
        'offset' => '0',
        'withThumbnail' => 'true',
        'type' => 'lf'
    ]);
    ```
10. Channel Projections:

    ```
    $api->get('/channels/@delba/projections/milestones');
    ```
11. Similar Channels:

    ```
    $api->get('/channels/@delba/similar');
    ```
12. Popular Channels:

    ```
    $api->get('/channels/popular', ['total' => '6']);
    ```

### POST Requests

[](#post-requests)

1. Channel Rankings:

    ```
    $api->post('/rankings/channels', [
        'interval' => 'weekly',
        'sortBy' => 'subs',
        'made_for_kids' => true,
        'show_music' => true,
        'category_id' => null,
        'country' => null,
        'show_movies' => true
    ]);
    ```
2. Video Rankings:

    ```
    $api->post('/rankings/videos', [
        'interval' => 7,
        'includeKids' => true,
        'includeMusic' => true,
        'country' => 'all',
        'categoryId' => 9999,
        'videoFormat' => 'all'
    ]);
    ```

Error Handling
--------------

[](#error-handling)

The wrapper throws two types of exceptions:

- `APIException`: For general API errors, including HTTP errors.
- `DecryptionException`: Specifically for errors during the decryption of API responses.

It's recommended to catch these exceptions separately to handle different types of errors appropriately.

Logging
-------

[](#logging)

The wrapper includes a basic logging mechanism. Logs are written to `debug.log` in the project root. You can customize the logging behavior by modifying the `Logger` class.

Security
--------

[](#security)

- API tokens are sent securely in the request headers.
- Encrypted responses are automatically decrypted using AES-256-GCM.
- Sensitive data like API tokens should be stored securely and not hard-coded in your application.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

[MIT License](LICENSE.md)

Support
-------

[](#support)

If you encounter any problems or have any questions, please open an issue on the GitHub repository.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Unknown

Total

1

Last Release

595d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/45fe1a2d6d547b1e58edc219fafaa0617ee86cec4b3d3ff25eeb3b641f8c910f?d=identicon)[peranetwork](/maintainers/peranetwork)

### Embed Badge

![Health badge](/badges/peranetwork-viewstats-api/health.svg)

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

PHPackages © 2026

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