Fetch any YouTube video’s metadata in 2 lines

Navin Kodag1 mins

09 May 2021

So, i was looking for a way to quickly get a YouTube video’s metadata without having to setup the developer account and get an API key since i just needed to integrate it as one small feature.

After doing a quick Google search, I came across the oembed API to fetch metadata for any video with using its link. So it goes like dis

tldr: {% gist %} But after a bit of refactoring 🧹… {% gist %} The basic HTTP request looks like this…


Gives us a response like this…

**"title": "Rick Astley - Never Gonna Give You Up (Video)",
"author_name": "RickAstleyVEVO",
"author_url": "[](",
"type": "video",
"height": **113**,
"width": **200**,
"version": "1.0",
"provider_name": "YouTube",
"provider_url": "[](",
"thumbnail_height": **360**,
"thumbnail_width": **480**,
"thumbnail_url": "[](",
"html": "<iframe width=\"200\" height=\"113\" src=\"\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>"

That’s pretty neat :] navinko

Made with Next.js & ❤️
© 2021 Navin Kodag. All rights reserved.