/Laravel-Youtube-API

A way to add an API to your Laravel app that converts youtube video's to mp3/mp4 and returns a download/stream link and information.

Primary LanguagePHPMIT LicenseMIT

Laravel Youtube API

Latest Version on Packagist Total Downloads

This package provides a simple youtube api for your Laravel application. It is based on my non-laravel package Youtube API.

Installation

  • Install the package via composer:
composer require michaelbelgium/laravel-youtube-api
  • Optional: publish the config file and edit if u like:
php artisan vendor:publish --tag=youtube-api-config
  • This package uses the public disk of Laravel. Run this command to create a symbolic link to the public folder so that converted Youtube downloads are accessible:
php artisan storage:link
  • Acquire a Google API key at the Google Developer Console for the API "Youtube Data API v3". Use this key in the environment variable GOOGLE_API_KEY - that this packages uses

Software

On the server where your laravel app is located, you'll need to install some packages.

API Usage

This package adds 3 api routes. The route prefix, /ytconverter/ in this case, is configurable.

  • POST /ytconverter/convert
  • DELETE /ytconverter/{id}
  • GET /ytconverter/search/{q}

Check the wiki page of this repository for more information about the routes.

API Auth

If needed, you can protect the API routes with the api:auth middleware by setting enable_auth to true in the configuration. A token is then required to make requests to the routes by passing it as bearer token or as query parameter api_token. See Laravel 6.x docs