概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
什么是 Safe Browsing API?
以下安全浏览 API 仅供非商业用途。如果您需要使用 API 来检测恶意网址以用于商业目的(即“用于销售或创收目的”),请参阅 Web Risk API。
通过安全浏览 API (v4),您的客户端应用可以根据 Google 不断更新的不安全网络资源列表来检查网址。不安全 Web 资源的示例包括社会工程学网站(钓鱼式攻击和欺骗性网站)以及托管恶意软件或垃圾软件的网站。安全浏览列表中包含的任何网址都被视为不安全网址。
如需确定某个网址是否在任何安全浏览列表中,客户端可以使用 Lookup API (v4) 或 Update API (v4)。
Lookup API (v4)
借助 Lookup API,您的客户端应用可以将网址发送到 Google Safe Browsing 服务器以检查其状态。该 API 简单易用,因为它避免了 Update API 的复杂性。
优点:
- 简单的网址检查:您可以发送带有实际网址的 HTTP
POST
请求,然后服务器会以网址的状态响应(安全或不安全)。
缺点:
- 隐私权:网址没有进行哈希处理,因此服务器知道您要查找哪些网址。
- 响应时间:服务器会处理每个查询请求。我们不能保证查找响应时间。
如果您不太在乎所查询的网址的隐私,并且可以容忍网络请求导致的延迟,请考虑使用 Lookup API,因为它相当易于使用。
更新了 API (v4)
通过 Update API,您的客户端应用可以下载安全浏览列表的加密版本,以便在本地进行客户端网址检查。Update API 专为需要高频、低延迟判定的客户端而设计。许多网络浏览器和软件平台都使用此 API 来保护大量用户。
优点:
- 隐私权:您很少与服务器交换数据(仅在本地哈希前缀匹配之后),并使用经过哈希处理的网址,因此服务器永远不会知道客户端查询的实际网址。
- 响应时间:您维护的本地数据库包含安全浏览列表的副本;他们不需要在每次检查网址时都查询服务器。
缺点:
- 实现:您需要设置本地数据库,然后下载并定期更新 Safe Browsing 列表的本地副本(以可变长度 SHA256 哈希值存储)。
- 复杂的网址检查:您需要知道如何对网址进行规范化,如何创建后缀/前缀表达式以及计算 SHA256 哈希值(以便与存储在服务器上的安全浏览列表以及安全浏览列表的本地副本进行比较)。
如果您担心所查询网址的隐私或网络请求引起的延迟,请使用 Update API。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eThe Safe Browsing APIs (v4) enable client applications to check URLs against Google's lists of unsafe web resources, including phishing sites and those hosting malware.\u003c/p\u003e\n"],["\u003cp\u003eTwo APIs are available: Lookup API (v4) for simple URL checks and Update API (v4) for local, privacy-focused checks.\u003c/p\u003e\n"],["\u003cp\u003eLookup API (v4) offers ease of use but has privacy and response time limitations.\u003c/p\u003e\n"],["\u003cp\u003eUpdate API (v4) prioritizes privacy and speed but requires more complex implementation and URL handling.\u003c/p\u003e\n"],["\u003cp\u003eThese APIs are for non-commercial use only; commercial users should refer to the Web Risk API.\u003c/p\u003e\n"]]],["Safe Browsing APIs allow client applications to check URLs against Google's unsafe web resource lists, distinguishing between non-commercial and commercial use (Web Risk API). The Lookup API checks URL status via server requests, offering simplicity but compromising privacy and response time. The Update API downloads encrypted lists for local checks, prioritizing privacy and speed but requiring complex implementation, database setup, and hash management. Users can choose between these based on privacy needs and latency tolerance.\n"],null,["# Overview\n\nWhat are the Safe Browsing APIs?\n--------------------------------\n\nThe following Safe Browsing APIs are for non-commercial use only. If you need to use APIs\nto detect malicious URLs for commercial purposes -- meaning \"for sale or revenue-generating\npurposes\" -- please refer to the [Web Risk API](https://cloud.google.com/web-risk).\n\nThe Safe Browsing APIs (v4) let your client applications check URLs against Google's\nconstantly updated lists of unsafe web resources. Examples of unsafe web resources are social\nengineering sites (phishing and deceptive sites) and sites that host malware or unwanted software.\nAny URL found on a Safe Browsing list is considered unsafe.\n\nTo determine if a URL is on any of the Safe Browsing lists, clients can use either\nthe [Lookup API (v4)](/safe-browsing/v4/lookup-api)\nor the [Update API (v4)](/safe-browsing/v4/update-api).\n\nLookup API (v4)\n---------------\n\nThe Lookup API lets your client applications send URLs to the Google Safe Browsing server to\ncheck their status. The API is simple and easy to use, as it avoids the complexities of the\nUpdate API.\n\nAdvantages:\n\n- Simple URL checks: You send an HTTP `POST` request with the actual URLs, and the server responds with the state of the URLs (safe or unsafe).\n\nDrawbacks:\n\n- Privacy: URLs are not hashed, so the server knows which URLs you look up.\n- Response time: Every lookup request is processed by the server. We don't provide guarantees on lookup response time.\n\nIf you are not too concerned about the privacy of the queried URLs, and you can tolerate the\nlatency induced by a network request, consider using the Lookup API since it's fairly easy to\nuse.\n\nUpdate API (v4)\n---------------\n\nThe Update API lets your client applications download encrypted versions of the Safe Browsing\nlists for local, client-side checks of URLs. The Update API is designed for clients that require\nhigh frequency, low-latency verdicts. Several web browsers and software platforms use this\nAPI to protect large sets of users.\n\nAdvantages:\n\n- Privacy: You exchange data with the server infrequently (only after a local hash prefix match) and using hashed URLs, so the server never knows the actual URLs queried by the clients.\n- Response time: You maintain a local database that contains copies of the Safe Browsing lists; they do not need to query the server every time they want to check a URL.\n\nDrawbacks:\n\n- Implementation: You need to set up a local database and then download, and periodically update, the local copies of the Safe Browsing lists (stored as variable-length SHA256 hashes).\n- Complex URL checks: You need to know how to canonicalize URLs, create suffix/prefix expressions, and compute SHA256 hashes (for comparison with the local copies of the Safe Browsing lists as well as the Safe Browsing lists stored on the server).\n\nIf you are concerned about the privacy of the queried URLs or the latency induced by a\nnetwork request, use the Update API."]]