It's much better to use the YouTube API.
Unfortunately,
It is not possible to get the video title using the video ID with API v3 without the API key if you use the API directly. The YouTube Data API v2 is deprecated (see: YouTube Data API v2 Deprecation: Frequently Asked Questions) and currently the YouTube API doesn't support oEmbed with JSONP as it should (see Issue 4329: oEmbed callback for JSONP).
But fortunately there is the Noembed service that lets you get the titles (and other data) of YouTube videos with JSONP and without the API key.
Use can go to,
https://noembed.com/embed?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ
And change the ID to the id you want to get basic data in json like,
```{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ","version":"1.0","thumbnail_height":360,"provider_name":"YouTube","width":200,"thumbnail_width":480,"title":"Rick Astley - Never Gonna Give You Up (Official Music Video)","thumbnail_url":"https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg","author_name":"Rick Astley","author_url":"https://www.youtube.com/c/RickastleyCoUkOfficial","html":"<iframe width=\"200\" height=\"113\" src=\"https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>","height":113,"provider_url":"https://www.youtube.com/","type":"video"}```
Backend code using python
import json
from requests import get
data = dict(json.loads(get("https://noembed.com/embed?url=https://www.youtube.com/watch?v="+id).text))
title = data['title']
You can also use jQuery to get the data from the frontend,
var id = 'dQw4w9WgXcQ';
var url = 'https://www.youtube.com/watch?v=' + id;
$.getJSON('https://noembed.com/embed',
{format: 'json', url: url}, function (data) {
alert(data.title);
});