PHPackages                             cable8mm/youtube - 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. cable8mm/youtube

ActiveLibrary[API Development](/categories/api)

cable8mm/youtube
================

Renew Laravel PHP Facade/Wrapper for the Youtube Data API v3

v5.0.1(3mo ago)1224↓100%MITPHPPHP ^8.2CI passing

Since Feb 5Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/cable8mm/Youtube)[ Packagist](https://packagist.org/packages/cable8mm/youtube)[ RSS](/packages/cable8mm-youtube/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (6)Versions (12)Used By (0)

Youtube
=======

[](#youtube)

[![code-style](https://github.com/cable8mm/Youtube/actions/workflows/code-style.yml/badge.svg)](https://github.com/cable8mm/Youtube/actions/workflows/code-style.yml)[![run-tests](https://github.com/cable8mm/Youtube/actions/workflows/run-tests.yml/badge.svg)](https://github.com/cable8mm/Youtube/actions/workflows/run-tests.yml)[![Packagist Dependency Version](https://camo.githubusercontent.com/203f716029c3e3c3907daccdfc591b915f4e37a815c06a9551431b0f9247379d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6361626c65386d6d2f596f75747562652f696c6c756d696e617465253246737570706f7274)](https://camo.githubusercontent.com/203f716029c3e3c3907daccdfc591b915f4e37a815c06a9551431b0f9247379d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6361626c65386d6d2f596f75747562652f696c6c756d696e617465253246737570706f7274)[![Packagist Version](https://camo.githubusercontent.com/1c136f5814bcc840cfb96fa0fd2af407bf65bc803d0c16d4d47d1c448b0e3a42/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6361626c65386d6d2f596f7574756265)](https://camo.githubusercontent.com/1c136f5814bcc840cfb96fa0fd2af407bf65bc803d0c16d4d47d1c448b0e3a42/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6361626c65386d6d2f596f7574756265)[![Packagist Downloads](https://camo.githubusercontent.com/400ca96a30b926eb099c4be916a97c0e31ef0c84d80e1bd0e949ad14df570ab2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6361626c65386d6d2f596f7574756265)](https://camo.githubusercontent.com/400ca96a30b926eb099c4be916a97c0e31ef0c84d80e1bd0e949ad14df570ab2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6361626c65386d6d2f596f7574756265)[![Packagist Dependency Version](https://camo.githubusercontent.com/3c67821649dd0e6f37eebd753ca36cba178d763529ac774dd9e0ef55e3af6fd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6361626c65386d6d2f596f75747562652f706870)](https://camo.githubusercontent.com/3c67821649dd0e6f37eebd753ca36cba178d763529ac774dd9e0ef55e3af6fd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6361626c65386d6d2f596f75747562652f706870)[![Packagist Stars](https://camo.githubusercontent.com/ebf5580f13419e4171c742f0b6fb308ac657f05f7517121f15073d15accf82b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6361626c65386d6d2f596f7574756265)](https://camo.githubusercontent.com/ebf5580f13419e4171c742f0b6fb308ac657f05f7517121f15073d15accf82b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6361626c65386d6d2f596f7574756265)[![Packagist License](https://camo.githubusercontent.com/180109349c7bfac162775f2eea3d958a007562209b4cc0020759a24b75a6a00c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6361626c65386d6d2f596f7574756265)](https://camo.githubusercontent.com/180109349c7bfac162775f2eea3d958a007562209b4cc0020759a24b75a6a00c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6361626c65386d6d2f596f7574756265)

Renew Laravel PHP Facade/Wrapper for the Youtube Data API v3 ( Non-OAuth )

We have provided the API Documentation on the web. For more information, please visit  ❤️

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 8 or higher
- API key from [Google Console](https://console.developers.google.com)

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

[](#installation)

Run in console below command to download package to your project:

```
composer require cable8mm/youtube
```

Configuration
-------------

[](#configuration)

Publish config settings:

```
php artisan vendor:publish --provider="Cable8mm\Youtube\YoutubeServiceProvider"

```

Set your Youtube API key in the file:

```
/config/youtube.php
```

Or in the .env file

```
YOUTUBE_API_KEY =
```

Package Development
-------------------

[](#package-development)

If you are going to contribute,

```
composer update
```

And you can use `.env` in the package.

Usage
-----

[](#usage)

```
// use Cable8mm\Youtube\Facades\Youtube;

// Return an STD PHP object
$video = Youtube::getVideoInfo('rie-hPVJ7Sw');

// Get multiple videos info from an array
$videoList = Youtube::getVideoInfo(['rie-hPVJ7Sw','iKHTawgyKWQ']);

// Get localized video info
$video = Youtube::getLocalizedVideoInfo('vjF9GgrY9c0', 'pl');

// Get comment threads by videoId
$commentThreads = Youtube::getCommentThreadsByVideoId('zwiUB_Lh3iA');

// Get popular videos in a country, return an array of PHP objects
$videoList = Youtube::getPopularVideos('us');

// Search playlists, channels and videos. return an array of PHP objects
$results = Youtube::search('Android');

// Only search videos, return an array of PHP objects
$videoList = Youtube::searchVideos('Android');

// Search only videos in a given channel, return an array of PHP objects
$videoList = Youtube::searchChannelVideos('keyword', 'UCk1SpWNzOs4MYmr0uICEntg', 40);

// List videos in a given channel, return an array of PHP objects
$videoList = Youtube::listChannelVideos('UCk1SpWNzOs4MYmr0uICEntg', 40);

$results = Youtube::searchAdvanced([ /* params */ ]);

// Get channel data by channel name, return an STD PHP object
$channel = Youtube::getChannelByName('xdadevelopers');

// Get channel data by channel ID, return an STD PHP object
$channel = Youtube::getChannelById('UCk1SpWNzOs4MYmr0uICEntg');

// Get playlist by ID, return an STD PHP object
$playlist = Youtube::getPlaylistById('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs');

// Get playlists by multiple ID's, return an array of STD PHP objects
$playlists = Youtube::getPlaylistById(['PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs', 'PL590L5WQmH8cUsRyHkk1cPGxW0j5kmhm0']);

// Get playlist by channel ID, return an array of PHP objects
$playlists = Youtube::getPlaylistsByChannelId('UCk1SpWNzOs4MYmr0uICEntg');

// Get items in a playlist by playlist ID, return an array of PHP objects
$playlistItems = Youtube::getPlaylistItemsByPlaylistId('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs');

// Get channel activities by channel ID, return an array of PHP objects
$activities = Youtube::getActivitiesByChannelId('UCk1SpWNzOs4MYmr0uICEntg');

// Retrieve video ID from original YouTube URL
$videoId = Youtube::parseVidFromURL('https://www.youtube.com/watch?v=moSFlvxnbgk');
// result: moSFlvxnbgk
```

Validation Rules
----------------

[](#validation-rules)

```
// use Cable8mm\Youtube\Rules\ValidYoutubeVideo;

// Validate a YouTube Video URL
[
    'youtube_video_url' => ['bail', 'required', new ValidYoutubeVideo]
];
```

You can use the bail rule in conjunction with this in order to prevent unnecessary queries.

Basic Search Pagination
-----------------------

[](#basic-search-pagination)

```
// Set default parameters
$params = [
    'q'             => 'Android',
    'type'          => 'video',
    'part'          => 'id, snippet',
    'maxResults'    => 50
];

// Make intial call. with second argument to reveal page info such as page tokens
$search = Youtube::searchAdvanced($params, true);

// Check if we have a pageToken
if (isset($search['info']['nextPageToken'])) {
    $params['pageToken'] = $search['info']['nextPageToken'];
}

// Make another call and repeat
$search = Youtube::searchAdvanced($params, true);

// Add results key with info parameter set
print_r($search['results']);

/* Alternative approach with new built-in paginateResults function */

// Same params as before
$params = [
    'q'             => 'Android',
    'type'          => 'video',
    'part'          => 'id, snippet',
    'maxResults'    => 50
];

// An array to store page tokens so we can go back and forth
$pageTokens = [];

// Make inital search
$search = Youtube::paginateResults($params, null);

// Store token
$pageTokens[] = $search['info']['nextPageToken'];

// Go to next page in result
$search = Youtube::paginateResults($params, $pageTokens[0]);

// Store token
$pageTokens[] = $search['info']['nextPageToken'];

// Go to next page in result
$search = Youtube::paginateResults($params, $pageTokens[1]);

// Store token
$pageTokens[] = $search['info']['nextPageToken'];

// Go back a page
$search = Youtube::paginateResults($params, $pageTokens[0]);

// Add results key with info parameter set
print_r($search['results']);
```

The pagination above is quite basic. Depending on what you are trying to achieve you may want to create a recursive function that traverses the results.

Manual Class Instantiation
--------------------------

[](#manual-class-instantiation)

```
// Directly call the YouTube constructor
$youtube = new Youtube(config('YOUTUBE_API_KEY'));

// By default, if the $_SERVER['HTTP_HOST'] header is set,
// it will be used as the `Referer` header. To override
// this setting, set 'use-http-host' to false during
// object construction:
$youtube = new Youtube(config('YOUTUBE_API_KEY'), ['use-http-host' => false]);

// This setting can also be set after the object was created
$youtube->useHttpHost(false);
```

Test
----

[](#test)

```
composer test
```

Format of returned data
-----------------------

[](#format-of-returned-data)

The returned JSON is decoded as PHP objects (not Array). Please read the ["Reference" section](https://developers.google.com/youtube/v3/docs/) of the Official API doc.

Youtube Data API v3
-------------------

[](#youtube-data-api-v3)

- [Youtube Data API v3 Doc](https://developers.google.com/youtube/v3/)
- [Obtain API key from Google API Console](https://console.developers.google.com)

Credits
-------

[](#credits)

Built on code from Alaouy's [alaouy/youtube](https://github.com/alaouy/youtube).

###  Health Score

46

↑

FairBetter than 93% of packages

Maintenance79

Regular maintenance activity

Popularity16

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 54.2% 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 ~66 days

Recently: every ~162 days

Total

11

Last Release

111d ago

Major Versions

v3.2.1 → v4.0.02024-02-22

v4.2.0 → v5.0.02025-12-01

PHP version history (2 changes)v3.0.0PHP ^8.0

v5.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c910c874a0263a18f9f976273054cd45faa3ffbcba7891992f4ab52d0656dd93?d=identicon)[Sam Lee](/maintainers/Sam%20Lee)

---

Top Contributors

[![alaouy](https://avatars.githubusercontent.com/u/3118889?v=4)](https://github.com/alaouy "alaouy (97 commits)")[![cable8mm](https://avatars.githubusercontent.com/u/2672043?v=4)](https://github.com/cable8mm "cable8mm (25 commits)")[![bzbislawski](https://avatars.githubusercontent.com/u/12448772?v=4)](https://github.com/bzbislawski "bzbislawski (11 commits)")[![mahmutbayri](https://avatars.githubusercontent.com/u/1398166?v=4)](https://github.com/mahmutbayri "mahmutbayri (8 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (4 commits)")[![vishal-sancheti](https://avatars.githubusercontent.com/u/4789936?v=4)](https://github.com/vishal-sancheti "vishal-sancheti (4 commits)")[![digitalhuman](https://avatars.githubusercontent.com/u/780848?v=4)](https://github.com/digitalhuman "digitalhuman (3 commits)")[![Rpsl](https://avatars.githubusercontent.com/u/265634?v=4)](https://github.com/Rpsl "Rpsl (2 commits)")[![qWici](https://avatars.githubusercontent.com/u/11472929?v=4)](https://github.com/qWici "qWici (2 commits)")[![brunoxavier-dev](https://avatars.githubusercontent.com/u/42558239?v=4)](https://github.com/brunoxavier-dev "brunoxavier-dev (2 commits)")[![akiyamaSM](https://avatars.githubusercontent.com/u/12276076?v=4)](https://github.com/akiyamaSM "akiyamaSM (2 commits)")[![lucaspanik](https://avatars.githubusercontent.com/u/7035554?v=4)](https://github.com/lucaspanik "lucaspanik (1 commits)")[![messerli90](https://avatars.githubusercontent.com/u/3306651?v=4)](https://github.com/messerli90 "messerli90 (1 commits)")[![m-pastuszek](https://avatars.githubusercontent.com/u/32341770?v=4)](https://github.com/m-pastuszek "m-pastuszek (1 commits)")[![paoloposo](https://avatars.githubusercontent.com/u/10469413?v=4)](https://github.com/paoloposo "paoloposo (1 commits)")[![Slaver](https://avatars.githubusercontent.com/u/68165?v=4)](https://github.com/Slaver "Slaver (1 commits)")[![stickpro](https://avatars.githubusercontent.com/u/25886722?v=4)](https://github.com/stickpro "stickpro (1 commits)")[![tylergets](https://avatars.githubusercontent.com/u/9418094?v=4)](https://github.com/tylergets "tylergets (1 commits)")[![wmerfalen](https://avatars.githubusercontent.com/u/2633195?v=4)](https://github.com/wmerfalen "wmerfalen (1 commits)")[![Xartrick](https://avatars.githubusercontent.com/u/1482818?v=4)](https://github.com/Xartrick "Xartrick (1 commits)")

---

Tags

apilaravelpackagephp8youtubeyoutube-apiapilaravelvideoyoutubealaouycable8mm

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cable8mm-youtube/health.svg)

```
[![Health](https://phpackages.com/badges/cable8mm-youtube/health.svg)](https://phpackages.com/packages/cable8mm-youtube)
```

###  Alternatives

[alaouy/youtube

Laravel PHP Facade/Wrapper for the Youtube Data API v3

8251.2M7](/packages/alaouy-youtube)[spatie/laravel-fractal

An easy to use Fractal integration for Laravel applications

1.9k14.8M87](/packages/spatie-laravel-fractal)[specialtactics/l5-api

Dependencies for the Laravel API Boilerplate package

3672.5k1](/packages/specialtactics-l5-api)

PHPackages © 2026

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