DEV Community

How & why I built a favicon fetching service

fiiv on September 03, 2021

A few days ago, I launched Icon Horse, which is a simple, free API to quickly get the favicon of any website. The launch itself went really well, a...
Collapse
 
kostjapalovic profile image
Kostja Appliku.com

Man, this is a great!

I have never thought how much pain can be involved in getting this little image from the a given site.

At the same time we all are used to having these images near our links.

I myself am guilty of not taking care of all the formats for icons and probably most of my sites have crappy images for all sizes.

I mean it is taken for granted that your site should have them in all possible sizes, but amount of work needed for that – hardly ever one things of it.

I guess that’s why many sites don’t have them and that’s why icon.horse is solving an important task of figuring out what is often broken on websites.

Thanks for this app and opening my eyes on this side of the internet.

Collapse
 
mtimofiiv profile image
fiiv

Hey @kostjapalovic ! Thanks for the comment!

Yes indeed, it actually also made me think just how resilient browsers must be. There are so many horrible sins we all commit against web standards all the time, it's kind of amazing things mostly work.

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

I guess we can only start to understand it when we consume other services, not create our own.

I remember my first time when I was dealing with sendind AND receiving emails. Man, this is even worse than icons 😂

Collapse
 
peterc profile image
Peter Cooper

Not to take away from your achievement, since I think it is actually better than this, but some may be interested to know Google has a little known API that does something similar, e.g. google.com/s2/favicons?domain=dev.to .. You are limited on size, get no idea about usage policy, and so forth - but I've used it in a personal search engine for years without problems. Icon Horse is probably a better option for future! :)

Collapse
 
mtimofiiv profile image
fiiv

Hey @peterc , great point!

It's true, Google does have this (as does DuckDuckGo as well – external-content.duckduckgo.com/ip...). But like you said, it serves a 16x16 favicon with no options. The API is also meant to be used internally and is there but for the grace of Google – they can change it or remove it without any notice.

I am in the process of adding options to Icon Horse for:

  • preferred sizes
  • format (svg vs. ico vs. png/jpg)
  • specifying a custom fallback like Gravatar does with its avatars
  • serving the icons from your own domain

Any suggestions?

Collapse
 
hevisko profile image
Hevisko

Since I've found this (and hammered it for caching VaultWarden icon_cache) I have to mention that you'd want to:
a) filter private addresses RFC1918 (ie. 10/8, 172.16/12, 192.168/16) and the "special use" from rfc5735
b) I see gateway timeouts on addresses of hosts that doesn't allow "trusted" (or are actually internals resolving to addresses in (a) )

in both cases above, I'd advocate a simple cached ico of... something :)=)

Collapse
 
mtimofiiv profile image
fiiv

Hi @hevisko ! That explains the spike in requests I got in the last few days ;)

Thanks for finding these things. I've fixed B., and I'll look at A. next week!

Collapse
 
francescobianco profile image
Francesco Bianco

That's amazing! A perfect example of microsaas.

Collapse
 
mtimofiiv profile image
fiiv

Thanks, @francescobianco !

Collapse
 
kolaposki profile image
Oshodi Kolapo

Great work man. I love this.

I found this after google's google.com/s2/favicons?domain=gith... could not fetch github's favicon. Really weird.

Thanks for this. Works like magic

Collapse
 
mtimofiiv profile image
fiiv

Weird that Google's service doesn't work in this case!

In any case, et me know if you have any feedback on Icon Horse. :)

Collapse
 
thehidden1 profile image
Mohamed Amine

i got a 404 :) https://icon.horse/icon/icon.horse/icon/icon.horse

Collapse
 
mtimofiiv profile image
fiiv

Hi @thehidden1 ! The 404 is because you want to just put the hostname into the URL, not the whole URL. So like this:

https://icon.horse/icon/icon.horse
Enter fullscreen mode Exit fullscreen mode