Tổng quan
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Safe Browsing API là gì?
Các Safe Browsing API sau đây chỉ dành cho mục đích phi thương mại. Nếu bạn cần sử dụng API để phát hiện URL độc hại cho mục đích thương mại (tức là "cho mục đích bán hàng hoặc tạo doanh thu"), vui lòng tham khảo Web Risk API.
Safe Browsing API (phiên bản 4) cho phép các ứng dụng kiểm tra URL dựa trên danh sách tài nguyên web không an toàn được Google cập nhật liên tục. Ví dụ về tài nguyên web không an toàn là các trang web tấn công phi kỹ thuật (trang web lừa đảo và trang web lừa đảo) và các trang web lưu trữ phần mềm độc hại hoặc phần mềm không mong muốn.
Mọi URL có trong danh sách Duyệt web an toàn đều được coi là không an toàn.
Để xác định xem một URL có nằm trong danh sách nào của Safe Browsing hay không, các ứng dụng có thể sử dụng Lookup API (v4) hoặc Update API (v4).
Lookup API (v4)
Lookup API cho phép các ứng dụng khách gửi URL đến máy chủ Duyệt web an toàn của Google để kiểm tra trạng thái của các URL đó. API này đơn giản và dễ sử dụng vì tránh được sự phức tạp của Update API.
Ưu điểm:
- Kiểm tra URL đơn giản: Bạn gửi một yêu cầu HTTP
POST
kèm theo các URL thực tế và máy chủ sẽ phản hồi bằng trạng thái của các URL (an toàn hoặc không an toàn).
Nhược điểm:
- Quyền riêng tư: URL không được băm, vì vậy máy chủ biết bạn tra cứu URL nào.
- Thời gian phản hồi: Mọi yêu cầu tra cứu đều được máy chủ xử lý. Chúng tôi không đảm bảo thời gian phản hồi tra cứu.
Nếu không quá lo ngại về quyền riêng tư của các URL được truy vấn và có thể chấp nhận độ trễ do yêu cầu mạng gây ra, hãy cân nhắc sử dụng Lookup API vì API này khá dễ sử dụng.
Update API (phiên bản 4)
Update API cho phép các ứng dụng tải xuống phiên bản mã hoá của danh sách Duyệt web an toàn để kiểm tra URL cục bộ phía máy khách. Update API được thiết kế cho những ứng dụng cần kết quả có tần suất cao và độ trễ thấp. Một số trình duyệt web và nền tảng phần mềm sử dụng API này để bảo vệ một lượng lớn người dùng.
Ưu điểm:
- Quyền riêng tư: Bạn trao đổi dữ liệu với máy chủ không thường xuyên (chỉ sau khi so khớp tiền tố hàm băm cục bộ) và sử dụng các URL đã băm, vì vậy máy chủ không bao giờ biết được các URL thực tế mà ứng dụng đã truy vấn.
- Thời gian phản hồi: Bạn duy trì một cơ sở dữ liệu cục bộ chứa các bản sao của danh sách Duyệt web an toàn; các bản sao này không cần truy vấn máy chủ mỗi khi muốn kiểm tra một URL.
Nhược điểm:
- Triển khai: Bạn cần thiết lập một cơ sở dữ liệu cục bộ, sau đó tải xuống và định kỳ cập nhật các bản sao cục bộ của danh sách Duyệt web an toàn (được lưu trữ dưới dạng hàm băm SHA256 có độ dài thay đổi).
- Kiểm tra URL phức tạp: Bạn cần biết cách chuẩn hoá URL, tạo biểu thức hậu tố/tiền tố và tính toán hàm băm SHA256 (để so sánh với các bản sao cục bộ của Danh sách Duyệt web an toàn cũng như Danh sách Duyệt web an toàn được lưu trữ trên máy chủ).
Nếu bạn lo ngại về quyền riêng tư của các URL được truy vấn hoặc độ trễ do yêu cầu mạng gây ra, hãy sử dụng Update API.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\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."]]