Add a youtube api to your Laravel instance
michaelbelgium/laravel-youtube-api is a Laravel package for add a youtube api to your laravel instance.
It currently has 32 GitHub stars and 416 downloads on Packagist (latest version v3.2.0).
Install it with composer require michaelbelgium/laravel-youtube-api.
Discover more Laravel packages by michaelbelgium
or browse all Laravel packages to compare alternatives.
Last updated
This package provides a simple youtube api for your Laravel application. It is based on my non-laravel package Youtube API.
composer require michaelbelgium/laravel-youtube-api
php artisan vendor:publish --tag=youtube-api-config
php artisan storage:link
php artisan migrate
Depending on what driver you use - on the server where your laravel app is located, you'll need to install some packages.
This package adds 3 api routes. The route prefix, /ytconverter/ in this case, is configurable.
Check the wiki page of this repository for more information about the routes.
To enable the search endpoint you need to acquire a Google API key on the Google Developer Console for the API "Youtube Data API v3". Use this key in the environment variable GOOGLE_API_KEY
Downloading Youtube video's is not simple these days. To cover this, you can choose how you want to download the video's by setting the driver in the configuration.
Available drivers:
The default driver. Requires ffmpeg and yt-dlp or youtube-dl to be installed on the server and it'll download files to the server. Metadata comes from yt-dlp.
Requires a (self) hosted Cobalt (API) instance. It doesn't require any software to be installed on the server and it doesn't download files to the server.
If GOOGLE_API_KEY is set, it'll use the Youtube Data API to get metadata, otherwise it will download the video to get the metadata and thus use storage space instead.
Uses cnvmp3.com to convert the files and downloads them to this instance. It doesn't require any software to be installed on the server.
If GOOGLE_API_KEY is set, it'll use the Youtube Data API to get metadata, otherwise it'll use getid3.
If needed, you can protect the API routes with an authentication guard by setting auth in the configuration.
Example:
'auth' => 'sanctum',
If needed, you can limit API calls by editing the config setting ratelimiter. See Laravel docs for more information or examples.
Example:
'ratelimiter' => function (Request $request) {
return Limit::perMinute(5);
},