Skip to content
Benjamin Loison edited this page May 12, 2023 · 10 revisions

Install your own instance of the API on a nginx web server:

  1. If not already hosting a nginx website, run in a terminal:

On Linux (Ubuntu, Debian and Mint):

sudo apt install nginx php-fpm
  1. Configure PHP and nginx by running:
sudo sed -i -e{56,57,60,63}'s/#//g' -e 's/php7.4-fpm/php-fpm/g;s/index index.html/index index.php index.html/g;65i\ \tlocation = /YouTube-operational-API/ytPrivate/keys.txt {\n\t\tdeny all;\n\t}\n;65i\ \tlocation ~ /YouTube-operational-API/noKey {\n\t\trewrite ^(.*)$ /YouTube-operational-API/noKey/index.php;\n\t}\n' /etc/nginx/sites-available/default
sudo sed -i "65i\ \trewrite ^/YouTube-operational-API/(search|videos|playlists|playlistItems|channels|community|webhooks|commentThreads|lives|liveChats)$ /YouTube-operational-API/$1.php;\n" /etc/nginx/sites-available/default

If you're also interested in having your own no-key endpoint (then you have to provide it YouTube Data API v3 keys), then add to /etc/nginx/sites-available/default:

    location ~ ytPrivate/keys.txt {
        deny all;
    }

    rewrite ^/noKey/ /noKey/index.php;
sudo service nginx reload
  1. Now that you are hosting a website, get the current working directory of your terminal into the folder that is online by using:
cd /var/www/html/
  1. Clone this repository by using:
git clone https://github.com/Benjamin-Loison/YouTube-operational-API
  1. Verify that your API instance is reachable by trying to access: http://localhost/YouTube-operational-API

Note that the CORS feature may be unsupported (cf this .htaccess section).

This tutorial is known to work on Linux Mint, verifying its compatibility with Debian and Ubuntu should be done.

Clone this wiki locally