jasonadriaan/videocloudanalytics

A simple way to use Brightcove's VideoCloud Analytics API

dev-main 2023-07-03 09:42 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package makes it simple for you to retrieve analytics from Brightcove VideoCloud's Analytics API without having to deal with authentication or repetitive api calls.

Support: Buy me a coffee

I build and maintain this project in my free time. If it makes your life simpler you can buy me a coffee.

Installation

You can install the package via composer:

composer require jasonadriaan/videocloudanalytics

You will need to publish the config file with:

php artisan vendor:publish --tag="videocloudanalytics-config"

In your .env file please add the following lines with your API details from Brightcove VideoCloud

VIDEOCLOUD_ACCOUNT_ID=xxxxx
VIDEOCLOUD_API_KEY=xxxxx
VIDEOCLOUD_API_SECRET=xxxxx

Usage

I would recommend you go ahead and read the VideoCloud Analytics API documentation to understand the underlying API.

Basic usage within your app would be as follows:

use Jasonadriaan\VideoCloudAnalytics\VideoCloudAnalytics;

class main extends Controller
{
    
    public function index(){

        $videocloud = new VideoCloudAnalytics();
        $items = $videocloud->dimensions('date')
                            ->from('2021-08-04')
                            ->to('2022-01-31')
                            ->fields('date,daily_unique_viewers,video_view')
                            ->sort('date')
                            ->limit(30)
                            ->get();
        return $items;
    }

}

Notes:

  • The get() method will return a Laravel Collection to make it easier for you to work with the data returned.
  • The only required field would be the dimensions field. If you do not provide it the API call will fail.
  • For the full Dimension Guide please go read the official documentation.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.