Skip to content

Latest commit

 

History

History
210 lines (164 loc) · 6.56 KB

File metadata and controls

210 lines (164 loc) · 6.56 KB
title Google Favicon API Documentation
description Complete guide to using Google's favicon API for retrieving website favicons and icons with size customization options.
keywords
Google favicon API
Google favicon
favicon API
get favicon from URL
favicon URL Google
Google s2 favicons
website favicon API
favicon retrieval
**Google Favicon API is unsupported and unmaintained.** This unofficial API has no guaranteed uptime, no error handling, and no way to be updated or maintained. Consider migrating to Logo.dev for production applications.

Overview

Google's Favicon API provides a simple way to retrieve favicons (website icons) from any domain. Originally designed as an internal service, this API has become widely used by developers for displaying website icons in applications, browser extensions, and dashboards.

The API is straightforward, requiring only a domain name and optional size parameter to return a favicon in PNG format. It automatically handles favicon detection, format conversion, and provides fallback icons when a favicon isn't available.

Base endpoint

https://www.google.com/s2/favicons?domain={domain}
https://www.google.com/s2/favicons?domain=github.com

Parameters

The website domain to retrieve the favicon from. Can be a full domain like `example.com` or include subdomain like `www.example.com`. Desired icon size in pixels. Common values: `16`, `32`, `64`, `128`, `256`. Note that not all sizes may be available for every domain. If the requested size isn't available, Google returns the closest available size. Alternative parameter name for `domain`. Both work interchangeably.

Size availability

The API supports various sizes, but availability depends on the source website:

  • 16x16: Always available (default fallback)
  • 32x32: Commonly available
  • 64x64: Available for most major sites
  • 128x128: Available for many sites
  • 256x256: Available for sites with high-resolution favicons
  • 512x512: Limited availability; may fall back to smaller sizes
Requesting sizes larger than 256px may return smaller images if higher resolution favicons aren't available from the source website.

Example implementations

<img
  src="https://www.google.com/s2/favicons?domain=stripe.com&sz=128"
  alt="Stripe favicon"
  width="128"
  height="128"
/>
curl "https://www.google.com/s2/favicons?domain=stripe.com&sz=256" --output stripe-favicon.png
const domain = "stripe.com";
const size = 128;
fetch(`https://www.google.com/s2/favicons?domain=${domain}&sz=${size}`)
  .then((res) => {
    if (!res.ok) throw new Error("Favicon not found");
    return res.blob();
  })
  .then((blob) => {
    const url = URL.createObjectURL(blob);
    document.querySelector("#favicon").src = url;
  });
import requests

domain = "stripe.com"
size = 128
url = f"https://www.google.com/s2/favicons?domain={domain}&sz={size}"

response = requests.get(url)
if response.status_code == 200:
    with open("favicon.png", "wb") as f:
        f.write(response.content)
const getFavicon = async (
  domain: string,
  size: number = 128
): Promise<Blob> => {
  const url = `https://www.google.com/s2/favicons?domain=${domain}&sz=${size}`;
  const response = await fetch(url);

  if (!response.ok) {
    throw new Error(`Failed to fetch favicon: ${response.statusText}`);
  }

  return response.blob();
};

// Usage
getFavicon("github.com", 256).then((blob) => {
  const imgUrl = URL.createObjectURL(blob);
  console.log("Favicon URL:", imgUrl);
});

FAQs

Yes, the API is free and doesn't require authentication or an API key. However, it's an unofficial/undocumented API, so there are no formal rate limits or guarantees.

{" "}

The API always returns favicons in PNG format, regardless of the source website's original favicon format.

{" "}

Google provides a default fallback icon (typically a generic globe or page icon) when a website doesn't have a favicon.

{" "}

{" "}

While many developers use this API in production, keep in mind it's an unofficial API without guaranteed uptime or support. For mission-critical applications, consider migrating to Logo.dev for reliable logo retrieval with guaranteed uptime.

{" "}

There are no officially published rate limits, but aggressive usage may be throttled. It's recommended to implement caching on your side to minimize requests.

{" "}

Icon size availability depends on what the source website provides. If you request a 256px icon but the site only has a 128px favicon, you'll receive the smaller version. The API is designed for public domains only. Local domains (like localhost) and IP addresses typically won't work.

Alternative: Logo.dev

For production applications requiring guaranteed uptime, higher quality, and more features, Logo.dev provides an actively maintained alternative to Google's Favicon API:

  • High-resolution logos: Access to company logos in multiple sizes and formats (PNG, SVG, WebP)
  • Multiple lookup methods: Search by domain, stock ticker, or cryptocurrency symbol
  • Actively maintained: Regular updates with hundreds of millions of logos in the database
  • Quality focused: Curated, high-quality brand assets instead of just favicons
  • Reliable infrastructure: Built for production use with guaranteed uptime
  • Free to start: Begin with Logo.dev's free tier and scale as needed

<Card title="Need better than favicons?" href="/logo-images/introduction" arrow="true" cta="Migrate to Logo.dev"

Get high-resolution company logos, brand data, and more with Logo.dev's comprehensive API.