PHPackages                             madcoda/php-youtube-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. [API Development](/categories/api)
4. /
5. madcoda/php-youtube-api

ActiveLibrary[API Development](/categories/api)

madcoda/php-youtube-api
=======================

PHP wrapper for the Youtube Data API v3

v1.4.0(3w ago)4291.3M↓40.6%115[13 issues](https://github.com/madcoda/php-youtube-api/issues)8MITPHPPHP &gt;=7.0CI passing

Since Jul 7Pushed 3w ago25 watchersCompare

[ Source](https://github.com/madcoda/php-youtube-api)[ Packagist](https://packagist.org/packages/madcoda/php-youtube-api)[ RSS](/packages/madcoda-php-youtube-api/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (3)Versions (17)Used By (8)

php-youtube-api
===============

[](#php-youtube-api)

[![Tests](https://github.com/madcoda/php-youtube-api/actions/workflows/tests.yml/badge.svg)](https://github.com/madcoda/php-youtube-api/actions/workflows/tests.yml)[![Static analysis](https://github.com/madcoda/php-youtube-api/actions/workflows/static.yml/badge.svg)](https://github.com/madcoda/php-youtube-api/actions/workflows/static.yml)[![Latest Stable Version](https://camo.githubusercontent.com/3ff73f14706697b0dc7b0a21e0f29b8de2bce57b6cd9ab74a720de2d8976d2bf/68747470733a2f2f706f7365722e707567782e6f72672f6d6164636f64612f7068702d796f75747562652d6170692f762f737461626c65)](https://packagist.org/packages/madcoda/php-youtube-api)[![Total Downloads](https://camo.githubusercontent.com/37ae4a9abc2b83820b0e902a8f1ef50f3e6eacf1aef414ac217b37531ca0b850/68747470733a2f2f706f7365722e707567782e6f72672f6d6164636f64612f7068702d796f75747562652d6170692f646f776e6c6f616473)](https://packagist.org/packages/madcoda/php-youtube-api)[![License](https://camo.githubusercontent.com/532497c5f565fb86589118d3488dd543d0fae7cbd5220fa31c5ace5fddc2e07c/68747470733a2f2f706f7365722e707567782e6f72672f6d6164636f64612f7068702d796f75747562652d6170692f6c6963656e7365)](https://packagist.org/packages/madcoda/php-youtube-api)

A basic PHP wrapper for the Youtube Data API v3 (non-OAuth). Designed to let devs easily fetch public data (video, channel and playlist info) from Youtube. No third-party runtime dependencies.

The reason for returning the decoded JSON response directly is that you only need to read the Google API doc to use this library, instead of learning another set of APIs on top of it. Keep it simple.

Some parameters are missing from this library simply because they were not needed at the time. If you want a particular feature, please [file an issue](https://github.com/madcoda/php-youtube-api/issues).

OAuth endpoints are out of scope: anything requiring an "authorized request" is not supported.

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

[](#requirements)

- PHP 7.0 or newer, including PHP 8.5
- the `curl` extension
- the `json` extension

Every release is tested on PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5.

PHPStatus7.0 – 7.4Supported. All are past end of life; upgrading is strongly recommended.8.0 – 8.1Supported. Both are past end of life.8.2 – 8.5Supported and actively maintained.The 1.x line keeps the PHP 7.0 floor so existing installs are not broken. It will be raised in 2.0.

Install
-------

[](#install)

```
composer require madcoda/php-youtube-api
```

Getting started
---------------

[](#getting-started)

Please read the wiki on how to use this library with [PHP with composer](https://github.com/madcoda/php-youtube-api/wiki/started-with-php-composer), [Laravel 4](https://github.com/madcoda/php-youtube-api/wiki/started-with-laravel-4) and [Laravel 5](https://github.com/madcoda/php-youtube-api/wiki/started-with-laravel-5).

For the functions implemented in this library, see the [API reference](https://github.com/madcoda/php-youtube-api/wiki/api-reference).

### Plain PHP

[](#plain-php)

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

$youtube = new Madcoda\Youtube\Youtube(array('key' => 'YOUR API KEY'));
$video = $youtube->getVideoInfo('rie-hPVJ7Sw');
```

### Laravel

[](#laravel)

The package is auto-discovered on Laravel 5.5 and newer, so there is nothing to register. Publish the config and set your key:

```
php artisan vendor:publish --provider="Madcoda\Youtube\YoutubeServiceProviderLaravel5"
```

```
$video = Youtube::getVideoInfo(request('vid', 'dQw4w9WgXcQ'));
```

On Laravel 5.0 to 5.4, register the provider and alias manually in `config/app.php`:

```
'providers' => [
    Madcoda\Youtube\YoutubeServiceProviderLaravel5::class,
],
'aliases' => [
    'Youtube' => Madcoda\Youtube\Facades\Youtube::class,
],
```

> The Laravel 4 provider is deprecated and will be removed in 2.0. Laravel 4 has been end of life since 2015, and the provider relies on `package()` and `bindShared()`, both removed in Laravel 5.

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

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

The returned JSON is decoded into PHP objects, not arrays. See the ["Reference" section](https://developers.google.com/youtube/v3/docs/) of the official API doc for the shape of each resource.

Methods that fetch a single resource return `false` when nothing matches; methods that fetch a list return `false` when the list is empty. API errors are thrown as `\Exception`with the Google error code as the exception code.

Using your own HTTP client
--------------------------

[](#using-your-own-http-client)

Requests go through a small transport interface, so you can route them through your own HTTP stack, add retries or logging, or return canned responses in your own tests.

```
use Madcoda\Youtube\Http\HttpClientInterface;

class MyClient implements HttpClientInterface
{
    public function get($url, array $params)
    {
        // return the raw, undecoded response body
    }
}

$youtube = new Madcoda\Youtube\Youtube(array('key' => 'YOUR API KEY'));
$youtube->setHttpClient(new MyClient());
```

Without one, the library uses `Madcoda\Youtube\Http\CurlHttpClient`, which behaves exactly as before.

Development
-----------

[](#development)

The test suite runs offline against recorded fixtures, so it needs no API key:

```
composer install
vendor/bin/phpunit
```

A second suite exercises the real API to catch changes in Google's response shapes. It is excluded by default and needs a key:

```
YOUTUBE_API_KEY=your-key vendor/bin/phpunit --group live
```

No `composer.lock` is committed, which is deliberate: each supported PHP version has to be free to resolve the PHPUnit major that supports it, from 5.7 on PHP 7.0 up to 11.5 on PHP 8.5.

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

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

- [YouTube Data API v3 doc](https://developers.google.com/youtube/v3/)
- [Obtain an API key from the Google API Console](https://console.cloud.google.com/apis/credentials)

Contact
-------

[](#contact)

For bugs, complaints or suggestions, please [file an issue](https://github.com/madcoda/php-youtube-api/issues) or email .

License
-------

[](#license)

`madcoda/php-youtube-api` is licensed under the [MIT License](http://opensource.org/licenses/MIT).

###  Health Score

68

—

FairBetter than 99% of packages

Maintenance95

Actively maintained with recent releases

Popularity61

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% 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 ~400 days

Recently: every ~848 days

Total

12

Last Release

22d ago

PHP version history (3 changes)v1.0PHP &gt;5.3

v1.2.2PHP &gt;=5.3

v1.2.6PHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![madcoda](https://avatars.githubusercontent.com/u/602185?v=4)](https://github.com/madcoda "madcoda (113 commits)")[![jbboehr](https://avatars.githubusercontent.com/u/225601?v=4)](https://github.com/jbboehr "jbboehr (3 commits)")[![mhor](https://avatars.githubusercontent.com/u/4103719?v=4)](https://github.com/mhor "mhor (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![jamesggordon](https://avatars.githubusercontent.com/u/650785?v=4)](https://github.com/jamesggordon "jamesggordon (2 commits)")[![konybakk](https://avatars.githubusercontent.com/u/2905760?v=4)](https://github.com/konybakk "konybakk (2 commits)")[![saruman](https://avatars.githubusercontent.com/u/813190?v=4)](https://github.com/saruman "saruman (2 commits)")[![jk](https://avatars.githubusercontent.com/u/40043?v=4)](https://github.com/jk "jk (1 commits)")[![marvin255](https://avatars.githubusercontent.com/u/2802915?v=4)](https://github.com/marvin255 "marvin255 (1 commits)")[![Hackwar](https://avatars.githubusercontent.com/u/313866?v=4)](https://github.com/Hackwar "Hackwar (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![primus852](https://avatars.githubusercontent.com/u/5185509?v=4)](https://github.com/primus852 "primus852 (1 commits)")[![z38](https://avatars.githubusercontent.com/u/3948085?v=4)](https://github.com/z38 "z38 (1 commits)")[![sidHitesh7](https://avatars.githubusercontent.com/u/3795597?v=4)](https://github.com/sidHitesh7 "sidHitesh7 (1 commits)")[![Stichoza](https://avatars.githubusercontent.com/u/1139050?v=4)](https://github.com/Stichoza "Stichoza (1 commits)")[![tambait](https://avatars.githubusercontent.com/u/22012185?v=4)](https://github.com/tambait "tambait (1 commits)")[![wlkns](https://avatars.githubusercontent.com/u/1921583?v=4)](https://github.com/wlkns "wlkns (1 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (1 commits)")[![LorenzoSapora](https://avatars.githubusercontent.com/u/25519274?v=4)](https://github.com/LorenzoSapora "LorenzoSapora (1 commits)")

---

Tags

phpphp-youtube-apiyoutubeapivideoyoutubemadcoda

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/madcoda-php-youtube-api/health.svg)

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

###  Alternatives

[alaouy/youtube

Laravel PHP Facade/Wrapper for the Youtube Data API v3

8081.4M9](/packages/alaouy-youtube)[socialapis/youtubedownloader

A small project for fetching youtube vidoes with their private api.

251.4k](/packages/socialapis-youtubedownloader)

PHPackages © 2026

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