Hire the author: Lakshay G


In this tutorial I’ll cover how to build your own youtube video title updater with Node.js. To build this I will be using Youtube Data API. Head over to this link to view my project’s result. The project’s Github repository is available here.


A while back, I watched a Youtube video with the same concept but the person didn’t exactly explain how he did that. So this made me curious and motivated to dig deep inside the Youtube data API.


My goal with this project is to build this youtube video title updater with the greatest ease, and deploy it free of cost online.


Cron: Cron is a time-based job scheduler in Unix-like computer operating systems.

Scheduling: Scheduling is the method by which work is assigned to resources that complete the work.

Project Requirements

  1. A gmail account is required
  2. Basic programming fundamentals are a must
  3. Must have a little bit idea about Node.js and JavaScript

Step by Step Tutorial

  1. First of all, head over to this Link and follow the first four steps mentioned there.
    NOTE: While creating credentials, you need to select DESKTOP Application type (because there is no other application type option available)
  2. After that create a .env file which consists of the VIDEO_ID, client_secret and access token which is coming from the first step.
    Refer below to check the .env file sample:-
  3. Now create the server.js file that consists of the authorize and update video title and the get video views functions as shown below:-

Sample .env file below:

OAUTH_TOKEN=/*copy/paste the CONTENTS OF YOUTUBE-NODEJS-QUICKSTART.JSON FILE as it is in json format*/
CLIENT_SECRET=/*copy/paste the CONTENTS OF CLIENT_SECRET.JSON FILE as it is in json format*/
VIDEO_ID=your video Id
view raw .env hosted with ❤ by GitHub

server.js file below:-

var {
} = require('googleapis');
var OAuth2 = google.auth.OAuth2;
const VIDEO_ID = process.env.VIDEO_ID
async function main() {
try {
const auth = authorize()
const videoViews = await getVideoViews(auth)
const videoTitle = await updateVideoTitle(auth, videoViews)
} catch (e) {
function authorize() {
const credentials = JSON.parse(process.env.CLIENT_SECRET)
var clientSecret = credentials.installed.client_secret;
var clientId = credentials.installed.client_id;
var redirectUrl = credentials.installed.redirect_uris[0];
var oauth2Client = new OAuth2(clientId, clientSecret, redirectUrl);
oauth2Client.credentials = JSON.parse(process.env.OAUTH_TOKEN);
return oauth2Client
function getVideoViews(auth) {
const service = google.youtube('v3')
return new Promise((resolve, reject) => {
auth: auth,
part: 'statistics',
}, function(err, response) {
if (err) return reject(err)
function updateVideoTitle(auth, views) {
const service = google.youtube('v3')
return new Promise((resolve, reject) => {
auth: auth,
part: 'snippet',
resource: {
snippet: {
title: `This Video Has ${new Intl.NumberFormat('en-US').format(views)} Views`,
description: `Happy Coding! | ${new Intl.NumberFormat('en-US').format(views)} Views`,
categoryId: 27
}, function(err, response) {
if (err) return reject(err)
view raw server.js hosted with ❤ by GitHub

These functions are pretty much self explanatory. All the parameters are required from the .env file in the first line (using dotenv npm package)
Now run this file using node server.js to check if everything works fine (from turning on youtube data api to updating the title of the video)

How to build a Youtube video title updater with Node.js

4. In order to automate this process of updating the youtube video title using Youtube data API, I will create a cron job.

For this, install two npm packages namely node-cron and shelljs and create the scheduler file as follows:-

let cron = require('node-cron')
let shell = require('shelljs')
var express = require('express')
var app = express()
app.get('/', function(req, res) {
cron.schedule("8 17,25,34,42,51,59 * * * *", function() {
console.log('scheduler running...')
if (shell.exec('node server.js').code !== 0) {
console.log('Something went wrong ')
app.listen(process.env.PORT || 3000, () => console.log(`Server started on port 3000`));
view raw index.js hosted with ❤ by GitHub

Save this file as index.js

Now run node index.js, you will see something like this:

How to build a Youtube video title updater with Node.js

5. Last step is to deploy this project online. There are many places where the project can be deployed, for example: AWS EC2 instance, GCP, Azure, Heroku, Digital Ocean etc.

In order to deploy it free of cost, use heroku and follow the steps:

How to build a Youtube video title updater with Node.js

Learning Tools and Strategies

  1. Don’t write messy code, everything should be well understood. Doing this will automatically help you when it comes to debugging.
  2. Do a console.log() at each major step you feel is important, or that you feel may throw some kind of error. This is so that you are able to get the result of each major code-snippet.
  3. Another thing is to go through the documentation of Youtube data api thoroughly.
  4. The most important thing to keep in mind is that you need to schedule the cron job in such a way that it runs after every 8 to 9 minutes and not less than that. Because there is a limited daily quota of requests that youtube provides.

Search terms

youtube, video, title, updater, node, youtube api


I prefer working in a quiet environment so that I am completely focused

Reflective Analysis

It is a very cool project. At first when I saw this I thought it was a hack or glitch or something of that sort. There are many other things that you can do with the youtube data API too, which means the possibilities for future are vast.


The project gives a detailed idea of how to implement a youtube video title updater using Youtube data API and node.js. There are many other things that you can do with the youtube data API. Do play around with this API.


I used https://www.flickr.com/photos/korosirego/4481461680 for the featured image

The project is available here.

Hire the author: Lakshay G