Use a hidden Google API to load favicons

Use a hidden Google API to load favicons

Use a hidden Google API to load favicons

Recently I have been working more and more with HTML and frontend development in general and had the task of loading favicons from various addresses to make links more visually attractive.
Here I came across a hidden Google API to load favicons.

Google Favicon API

Google offers a hidden, central API that returns favicons as jpegs - and in different sizes. I have seen this in Google's own services, whereby the subsequent image is delivered via gstatic.com; Google's CDN.

https://www.google.com/s2/favicons?domain=${tld}&sz=${pixel-size}

For my blog, this can look like this:

schwabencode.com\

https://www.google.com/s2/favicons?domain=schwabencode.com&sz=128

where the size is optional and 16 pixels are returned in the standard and fallback cases.

Alternatives

In addition to Google, Icon Horse also offers a functionally identical API

https://icon.horse/icon/schwabencode.com

And the search engine operator DuckDuckGo also offers such an API:

https://icons.duckduckgo.com/ip3/schwabencode.com.ico