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

ActiveLibrary[API Development](/categories/api)

kield-01/youtube
================

Laravel PHP Facade/Wrapper for the Youtube Data API v3

2.2.3(7y ago)022MITPHPPHP ^7.0

Since Mar 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/KielD-01/Youtube)[ Packagist](https://packagist.org/packages/kield-01/youtube)[ RSS](/packages/kield-01-youtube/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Youtube
=======

[](#youtube)

[![Travis Youtube Build](https://camo.githubusercontent.com/76d9121ecfdc790c8df4582c06d80b5ddaca0310392008083eaa3109550453c0/68747470733a2f2f6170692e7472617669732d63692e6f72672f616c616f75792f596f75747562652e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/76d9121ecfdc790c8df4582c06d80b5ddaca0310392008083eaa3109550453c0/68747470733a2f2f6170692e7472617669732d63692e6f72672f616c616f75792f596f75747562652e7376673f6272616e63683d6d6173746572)

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

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

[](#requirements)

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

Looking for Youtube Package for either of these: PHP 5, Laravel 5.0, Laravel 4? Visit the [`php5-branch`](https://github.com/alaouy/Youtube/tree/php5)

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

[](#installation)

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

```
composer require alaouy/youtube

```

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

[](#configuration)

In `/config/app.php` add YoutubeServiceProvider:

```
KielD01\Youtube\YoutubeServiceProvider::class,

```

Do not forget to add also Youtube facade there:

```
'Youtube' => KielD01\Youtube\Facades\Youtube::class,

```

Publish config settings:

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

```

Set your Youtube API key in the file:

```
/config/youtube.php

```

Or in the .env file

```
YOUTUBE_API_KEY = KEY

```

Or you can set the key programmatically at run time :

```
Youtube::setApiKey('KEY');

```

Usage
-----

[](#usage)

```
// use KielD01\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 multiple videos related to a video
$relatedVideos = Youtube::getRelatedVideos('iKHTawgyKWQ');

// 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
```

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.

Run Unit Test
-------------

[](#run-unit-test)

If you have PHPUnit installed in your environment, run:

```
$ phpunit
```

If you don't have PHPUnit installed, you can run the following:

```
$ composer update
$ ./vendor/bin/phpunit
```

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 Madcoda's [php-youtube-api](https://github.com/madcoda/php-youtube-api).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.5% 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

Unknown

Total

1

Last Release

2604d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0add303e0c489bc0b76824d864285a85e4a21fc9832c2e2255f2187512156b2?d=identicon)[KielD-01](/maintainers/KielD-01)

---

Top Contributors

[![alaouy](https://avatars.githubusercontent.com/u/3118889?v=4)](https://github.com/alaouy "alaouy (72 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)")[![vishal-sancheti](https://avatars.githubusercontent.com/u/4789936?v=4)](https://github.com/vishal-sancheti "vishal-sancheti (4 commits)")[![KielD-01](https://avatars.githubusercontent.com/u/10153164?v=4)](https://github.com/KielD-01 "KielD-01 (4 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (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)")[![akiyamaSM](https://avatars.githubusercontent.com/u/12276076?v=4)](https://github.com/akiyamaSM "akiyamaSM (2 commits)")[![qWici](https://avatars.githubusercontent.com/u/11472929?v=4)](https://github.com/qWici "qWici (2 commits)")[![tylergets](https://avatars.githubusercontent.com/u/9418094?v=4)](https://github.com/tylergets "tylergets (1 commits)")[![kleiberd](https://avatars.githubusercontent.com/u/5521697?v=4)](https://github.com/kleiberd "kleiberd (1 commits)")[![lamoni](https://avatars.githubusercontent.com/u/5675626?v=4)](https://github.com/lamoni "lamoni (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")[![messerli90](https://avatars.githubusercontent.com/u/3306651?v=4)](https://github.com/messerli90 "messerli90 (1 commits)")[![paoloposo](https://avatars.githubusercontent.com/u/10469413?v=4)](https://github.com/paoloposo "paoloposo (1 commits)")[![jesusvazquez](https://avatars.githubusercontent.com/u/2439858?v=4)](https://github.com/jesusvazquez "jesusvazquez (1 commits)")[![dwaxweiler](https://avatars.githubusercontent.com/u/12501775?v=4)](https://github.com/dwaxweiler "dwaxweiler (1 commits)")[![joaoeaugusto](https://avatars.githubusercontent.com/u/2657999?v=4)](https://github.com/joaoeaugusto "joaoeaugusto (1 commits)")[![jordanmiguel](https://avatars.githubusercontent.com/u/8248858?v=4)](https://github.com/jordanmiguel "jordanmiguel (1 commits)")

---

Tags

apilaravelvideoyoutubealaouy

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[alaouy/youtube

Laravel PHP Facade/Wrapper for the Youtube Data API v3

8091.3M9](/packages/alaouy-youtube)[madcoda/php-youtube-api

PHP wrapper for the Youtube Data API v3

4451.2M8](/packages/madcoda-php-youtube-api)

PHPackages © 2026

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