If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API?
YouTube is serving thumbnails from 2 servers. You just need to replace
https://img.youtube.com https://i.ytimg.com
Examples are with https://i.ytimg.com server just because it’s shorter, no other particular reason. You can use both.
Player Background Thumbnail (480x360):
WebP
https://i.ytimg.com/vi_webp//0.webp
JPG
https://i.ytimg.com/vi//0.jpg
Video frames thumbnails (120x90)
WebP:
Start: https://i.ytimg.com/vi_webp//1.webp
Middle: https://i.ytimg.com/vi_webp//2.webp
End: https://i.ytimg.com/vi_webp//3.webp
JPG:
Start: https://i.ytimg.com/vi//1.jpg
Middle: https://i.ytimg.com/vi//2.jpg
End: https://i.ytimg.com/vi//3.jpg
Lowest quality thumbnail (120x90)
WebP
https://i.ytimg.com/vi_webp//default.webp
JPG
https://i.ytimg.com/vi//default.jpg
Medium quality thumbnail (320x180)
WebP
https://i.ytimg.com/vi_webp//mqdefault.webp
JPG
https://i.ytimg.com/vi//mqdefault.jpg
High quality thumbnail (480x360)
WebP
https://i.ytimg.com/vi_webp//hqdefault.webp
JPG
https://i.ytimg.com/vi//hqdefault.jpg
Standard quality thumbnail (640x480)
WebP
https://i.ytimg.com/vi_webp//sddefault.webp
JPG
https://i.ytimg.com/vi//sddefault.jpg
Unscaled thumbnail resolution
WebP
https://i.ytimg.com/vi_webp//maxresdefault.webp
JPG
https://i.ytimg.com/vi//maxresdefault.jpg