Favicon API 与 URL 使用指南

可直接复制使用的 favicon URL 模板(基于免费服务)。

概述

Mzu favicondl 提供可直接复制的 favicon URL 模板与图标提取页面。默认启用 Cloudflare Worker 来发现更真实的图标来源,并通过图片代理支持下载。

快速响应

平均响应时间小于100ms

免费使用

完全免费,无需注册

稳定可靠

99.9% 可用性保障

认证

本项目使用免费的 Favicon 服务 URL 模板,不需要任何认证或 API Key。

注意: 虽然我们不需要API Key,但请合理使用服务,避免过度请求。

接口端点

GET FaviconDL Extract API

查找并下载指定域名或网址的可用 favicon

基础URL:

https://favicondl.com/api/extract

完整示例:

https://favicondl.com/api/extract?url=example.com&size=128

参数说明

参数名 类型 必需 默认值 描述
url string 是 - 目标域名或网址,如:example.com
size number 否 128 期望的图标尺寸,范围会限制在 16 到 512 像素
format string 否 redirect 使用 json 获取元数据;省略时直接跳转到可下载图片

参数详情:

网址

支持域名和完整网址:

  • • example.com
  • • www.example.com
  • • https://example.com/docs
  • • sub.example.com
尺寸

期望的图标尺寸,范围为 16 到 512 像素:

  • • 16 - 16x16
  • • 32 - 32x32
  • • 128 - 128x128
  • • 512 - 512x512 when supported

响应格式

成功响应 (JSON格式)

JSON响应
{
  "ok": true,
  "domain": "example.com",
  "size": 128,
  "iconUrl": "https://example.com/favicon.svg",
  "proxyUrl": "https://favicondl.com/api/proxy?url=...",
  "source": "html"
}

错误响应

错误响应
{
  "success": false,
  "error": "Domain not found",
  "message": "Unable to find favicon for the specified domain",
  "code": 404,
  "timestamp": "2026-01-15T10:30:00Z"
}

注意: 当使用 format=redirect 时,API会直接重定向到图标URL,不返回JSON响应。

使用示例

JavaScript (Fetch)

JavaScript
async function getFavicon(url, size = 128) {
  const endpoint = new URL('https://favicondl.com/api/extract');
  endpoint.searchParams.set('url', url);
  endpoint.searchParams.set('size', String(size));
  const response = await fetch(endpoint);
  if (!response.ok) throw new Error(`Favicon request failed: ${response.status}`);
  return await response.blob();
}

const icon = await getFavicon('example.com', 128);
const imageUrl = URL.createObjectURL(icon);
document.querySelector('#favicon-preview').src = imageUrl;

Python (Requests)

Python
import requests

def get_favicon(url: str, size: int = 128) -> bytes:
    response = requests.get(
        "https://favicondl.com/api/extract",
        params={"url": url, "size": size},
        timeout=15,
    )
    response.raise_for_status()
    return response.content

icon_bytes = get_favicon("example.com", 128)
with open("example-favicon", "wb") as output:
    output.write(icon_bytes)

PHP (cURL)

PHP

HTML 直接引用

HTML
<!-- 在HTML中直接引用favicon -->
<img src="https://favicondl.com/api/extract?url=example.com&size=32" alt="example.com favicon" width="32" height="32">

<!-- 使用大尺寸图标 -->
<img src="https://favicondl.com/api/extract?url=example.com&size=128" alt="example.com favicon" width="128" height="128">

<!-- 作为网站favicon -->
<link rel="icon" type="image/png" href="https://favicondl.com/api/extract?url=example.com&size=32">

错误处理

API在遇到错误时会返回相应的HTTP状态码和错误信息。

HTTP状态码 错误代码 描述 解决方法
400 invalid_domain 域名格式不正确 检查域名格式,确保是有效的域名
404 domain_not_found 找不到指定的域名 确认域名是否正确,网站是否可访问
404 favicon_not_found 网站没有favicon图标 该网站可能没有设置favicon图标
429 rate_limit_exceeded 请求频率过高 降低请求频率,稍后重试
500 internal_error 服务器内部错误 服务暂时不可用,请稍后重试

使用限制

免费使用

无需注册,完全免费使用所有功能

请求限制

  • • 每分钟最多 100 个请求
  • • 每小时最多 1000 个请求
  • • 每日最多 10000 个请求

商业使用

商业用户建议联系我们获取更高的使用配额和优先支持

已复制!