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

ActiveLibrary[API Development](/categories/api)

l/youtube
=========

Laravel PHP Facade/Wrapper for the Youtube Data API v3

v1.2.1(10y ago)022MITPHPPHP &gt;=5.3.0

Since Dec 3Pushed 9y agoCompare

[ Source](https://github.com/laravel2016/ID.YOUTUBE)[ Packagist](https://packagist.org/packages/l/youtube)[ RSS](/packages/l-youtube/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (6)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 )

You need to create an application and create your access token in the [developer console](https://console.developers.google.com).

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

[](#installation)

Add `alaouy/youtube` to your `composer.json`.

```
"alaouy/youtube": "dev-master"

```

Run `composer update` to pull down the latest version of the package.

Now open up `app/config/app.php` and add the service provider to your `providers` array.

```
'providers' => array(
	'Alaouy\Youtube\YoutubeServiceProvider',
)
```

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

[](#configuration)

### For Laravel 5

[](#for-laravel-5)

Run `php artisan vendor:publish` and set your API key in the file:

```
/app/config/youtube.php

```

### For Laravel 4

[](#for-laravel-4)

Run `php artisan config:publish alaouy/youtube` and set your API key in the file:

```
/app/config/packages/alaouy/youtube/config.php

```

Usage
-----

[](#usage)

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

$results = Youtube::searchAdvanced(array( /* 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 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 = array(
    '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 = array(
    'q'             => 'Android',
    'type'          => 'video',
    'part'          => 'id, snippet',
    'maxResults'    => 50
);

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

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

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 61.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 ~158 days

Total

4

Last Release

3797d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4c1b158db1bba6a5b749f653e8feb2187616f56528b071747b311f2421b693d?d=identicon)[laravel2016](/maintainers/laravel2016)

---

Top Contributors

[![alaouy](https://avatars.githubusercontent.com/u/3118889?v=4)](https://github.com/alaouy "alaouy (41 commits)")[![mahmutbayri](https://avatars.githubusercontent.com/u/1398166?v=4)](https://github.com/mahmutbayri "mahmutbayri (8 commits)")[![laravel2016](https://avatars.githubusercontent.com/u/24533220?v=4)](https://github.com/laravel2016 "laravel2016 (5 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (3 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)")[![khoatran](https://avatars.githubusercontent.com/u/1765656?v=4)](https://github.com/khoatran "khoatran (1 commits)")[![lamoni](https://avatars.githubusercontent.com/u/5675626?v=4)](https://github.com/lamoni "lamoni (1 commits)")[![joaoeaugusto](https://avatars.githubusercontent.com/u/2657999?v=4)](https://github.com/joaoeaugusto "joaoeaugusto (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)")

---

Tags

apilaravelvideoyoutubealaouy

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[alaouy/youtube

Laravel PHP Facade/Wrapper for the Youtube Data API v3

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

PHP wrapper for the Youtube Data API v3

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

PHPackages © 2026

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