Safe Browsing Lookup API (第 4 版)
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
總覽
Lookup API 可讓用戶端應用程式將要求傳送至安全瀏覽功能
伺服器,檢查網址是否已加入安全瀏覽清單。如果系統在 Google 新聞
如果需要更多清單,則會傳回相符的資訊。
正在檢查網址
如要檢查某個網址是否列在「安全瀏覽」清單中,請將 HTTP POST
要求傳送至
threatMatches.find
方法:
- HTTP
POST
要求最多可包含 500 個網址。網址必須是有效網址
(請參閱 RFC 2396)。
但不必採用標準化或編碼
- HTTP
POST
回應會傳回相符的網址以及快取持續時間。
例如: Threat 比對.find
HTTP POST 要求
在以下範例中,系統會將兩份安全瀏覽清單和三個網址傳送至伺服器,
檢查是否有相符項目
要求標頭包含要求網址和內容類型。記得更換
網址中 API_KEY
的 API 金鑰。
POST https://safebrowsing.googleapis.com/v4/threatMatches:find?key=API_KEY HTTP/1.1
Content-Type: application/json
要求主體
要求主體包含用戶端資訊 (ID 和版本) 和威脅資訊
(名單名稱和網址)。詳情請參閱
threatMatch.find 要求主體
以及本程式碼範例的說明
{
"client": {
"clientId": "yourcompanyname",
"clientVersion": "1.5.2"
},
"threatInfo": {
"threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
"platformTypes": ["WINDOWS"],
"threatEntryTypes": ["URL"],
"threatEntries": [
{"url": "http://www.urltocheck1.org/"},
{"url": "http://www.urltocheck2.org/"},
{"url": "http://www.urltocheck3.com/"}
]
}
}
clientID
和 clientVersion
欄位應是用來識別用戶端實作項目,而非
。(用戶端資訊會用於伺服器端記錄和會計作業;您可以選擇
或用戶端 ID 的任何名稱,但建議選用能夠代表其真實身分的名稱
安全瀏覽清單
threatType
、platformType
和 threatEntryType
欄位
會結合識別 (名稱)「安全瀏覽」清單。本例中有兩個清單:
惡意軟體/WINDOWS/URL 和 SOCIAL_ENGINEERING/WINDOWS/URL。傳送要求前,請確認所需類型
有效的組合 (請參閱安全瀏覽清單)。
威脅網址
在這個例子中,threatEntries
陣列包含三個網址 (urltocheck1.org、urltocheck2.org、
和 urltocheck3.org),用於檢查兩份安全瀏覽清單。
注意:Lookup API 和 threatMatches
方法應一律使用 URL
欄位。
一律為 hash
欄位 (請參閱 ThreatEntry)。
HTTP POST 回應
在以下範例中,回應會傳回相符項目。指定範本中的兩個
該要求會出現在要求中指定的兩份「安全瀏覽」清單之一。
回應標頭包含 HTTP 狀態碼
以及內容類型
HTTP/1.1 200 OK
Content-Type: application/json
回應主體
回應主體會包含比對資訊 (清單名稱和網址
這些清單、中繼資料 (如有) 以及快取持續時間)。詳情請參閱
threatMatch.find 回應主體
以及本程式碼範例的說明
注意:如果找不到相符項目 (也就是說,如果指定的網址「沒有任何」)
出現在要求中指定的「任何」清單中),HTTP POST
回應就會傳回回應
只會在回應主體中傳回空白物件。
{
"matches": [{
"threatType": "MALWARE",
"platformType": "WINDOWS",
"threatEntryType": "URL",
"threat": {"url": "http://www.urltocheck1.org/"},
"threatEntryMetadata": {
"entries": [{
"key": "malware_threat_type",
"value": "landing"
}]
},
"cacheDuration": "300.000s"
}, {
"threatType": "MALWARE",
"platformType": "WINDOWS",
"threatEntryType": "URL",
"threat": {"url": "http://www.urltocheck2.org/"},
"threatEntryMetadata": {
"entries": [{
"key": "malware_threat_type",
"value": "landing"
}]
},
"cacheDuration": "300.000s"
}]
}
相符
matches
物件會列出安全瀏覽清單的名稱和網址 (如果
「 」中有符合。在本例中,系統在其中一個網址 (urltocheck1.org 和 urltocheck2.org) 找到兩個網址:
安全瀏覽清單 (MALWARE/WINDOWS/URL),以便傳回相符的資訊。第三個網址
(urltocheck3.org) 都找不到,因此這個網址不會傳回任何資訊。
threatEntryMetadata
為選填欄位,並提供有關
威脅比對。目前,中繼資料是否可供 MALWARE/WINDOWS/URL 安全瀏覽清單提供
請參閱「中繼資料」。
快取持續時間
cacheDuration
欄位表示系統將網址視為不安全的時間長度。
(請參閱快取)。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eThe Lookup API allows client applications to send requests to Safe Browsing servers to check if URLs are on any Safe Browsing lists, returning matching information if found.\u003c/p\u003e\n"],["\u003cp\u003eTo check URLs, send an HTTP \u003ccode\u003ePOST\u003c/code\u003e request to the \u003ccode\u003ethreatMatches.find\u003c/code\u003e method, including up to 500 URLs in the request body with desired threat types and platform types.\u003c/p\u003e\n"],["\u003cp\u003eThe API response returns an empty object if no matches are found, or a \u003ccode\u003ematches\u003c/code\u003e object containing matching URLs, list names, metadata (if available), and cache durations.\u003c/p\u003e\n"],["\u003cp\u003eClient applications should uniquely identify themselves using \u003ccode\u003eclientId\u003c/code\u003e and \u003ccode\u003eclientVersion\u003c/code\u003e fields in the request body for server-side logging and accounting.\u003c/p\u003e\n"],["\u003cp\u003eThe API uses the \u003ccode\u003eURL\u003c/code\u003e field for threat entries and currently provides metadata for the MALWARE/WINDOWS/URL Safe Browsing list.\u003c/p\u003e\n"]]],["The Lookup API checks URLs against Safe Browsing lists via HTTP `POST` requests to the `threatMatches.find` method, which can include up to 500 URLs. Requests specify client and threat information, including threat types, platform types, and URLs. The response indicates matches, providing the list names, matching URLs, optional metadata, and cache duration. If no matches are found, the response returns an empty object. Client information must uniquely identify client implementations.\n"],null,["# Safe Browsing Lookup API (v4)\n\nOverview\n--------\n\nThe Lookup API lets your client applications send requests to the Safe Browsing\nservers to check if URLs are included on any of the Safe Browsing lists. If a URL is found on one or\nmore lists, the matching information is returned.\n\nChecking URLs\n-------------\n\nTo check if a URL is on a Safe Browsing list, send an HTTP `POST` request to the\n[threatMatches.find](/safe-browsing/reference/rest/v4/threatMatches/find)\nmethod:\n\n- The HTTP `POST` request can include up to 500 URLs. The URLs must be valid (see [RFC 2396](http://www.ietf.org/rfc/rfc2396.txt)) but they do not need to be canonicalized or encoded.\n- The HTTP `POST` response returns the matching URLs along with the cache duration.\n\nExample: threatMatches.find\n---------------------------\n\n### HTTP POST request\n\nIn the following example, two Safe Browsing lists and three URLs are sent to the server to\ndetermine if there is a match.\n\n#### Request header\n\nThe request header includes the request URL and the content type. Remember to substitute\nyour API key for `API_KEY` in the URL. \n\n```scdoc\n POST https://safebrowsing.googleapis.com/v4/threatMatches:find?key=API_KEY HTTP/1.1\n Content-Type: application/json\n \n```\n\n#### Request body\n\nThe request body includes the client information (ID and version) and the threat information\n(the list names and the URLs). For more details, see the\n[threatMatches.find request body](/safe-browsing/reference/rest/v4/threatMatches/find#request-body)\nand the explanations that follow the code example. \n\n```scdoc\n {\n \"client\": {\n \"clientId\": \"yourcompanyname\",\n \"clientVersion\": \"1.5.2\"\n },\n \"threatInfo\": {\n \"threatTypes\": [\"MALWARE\", \"SOCIAL_ENGINEERING\"],\n \"platformTypes\": [\"WINDOWS\"],\n \"threatEntryTypes\": [\"URL\"],\n \"threatEntries\": [\n {\"url\": \"http://www.urltocheck1.org/\"},\n {\"url\": \"http://www.urltocheck2.org/\"},\n {\"url\": \"http://www.urltocheck3.com/\"}\n ]\n }\n }\n```\n\n###### Client information\n\nThe `clientID` and `clientVersion` fields should uniquely identify a client implementation, not an\nindividual user. (Client information is used for server-side logging and accounting. You can choose\nany name for the client ID, but we suggest you choose a name that represents the true identity of the\nclient, such as your company name, presented as all one word, in all-lowercase letters.)\n\n###### Safe Browsing lists\n\nThe `threatType`, `platformType`, and `threatEntryType` fields\nare combined to identify (name) Safe Browsing lists. In the example, two lists are identified:\nMALWARE/WINDOWS/URL and SOCIAL_ENGINEERING/WINDOWS/URL. Before sending a request, make sure the type\ncombinations you specify are valid (see [Safe Browsing Lists](/safe-browsing/v4/lists)).\n\n###### Threat URLs\n\nIn the example, the `threatEntries` array contains three URLs (urltocheck1.org, urltocheck2.org,\nand urltocheck3.org) that will be checked against the two Safe Browsing lists.\n\n**Note:** The Lookup API and the `threatMatches` method should always use the `URL` field,\nnever the `hash` field (see [ThreatEntry](/safe-browsing/reference/rest/v4/ThreatEntry)).\n\n### HTTP POST response\n\nIn the following example, the response returns a match; two of the three URLs specified in the\nrequest are found on one of the two Safe Browsing lists specified in the request.\n\n#### Response header\n\nThe response header includes the [HTTP status code](/safe-browsing/v4/status-codes)\nand the content type. \n\n```http\nHTTP/1.1 200 OK\nContent-Type: application/json\n```\n\n#### Response body\n\nThe response body includes the match information (the list names and the URLs found on\nthose lists, the metadata, if available, and the cache durations). For more details, see the\n[threatMatches.find response body](/safe-browsing/reference/rest/v4/threatMatches/find#response-body)\nand the explanations that follow the code example.\n\n**Note:** If there are no matches (that is, if *none* of the URLs specified\nin the request are found on *any* of the lists specified in a request), the HTTP `POST` response\nsimply returns an empty object in the response body. \n\n```carbon\n{\n \"matches\": [{\n \"threatType\": \"MALWARE\",\n \"platformType\": \"WINDOWS\",\n \"threatEntryType\": \"URL\",\n \"threat\": {\"url\": \"http://www.urltocheck1.org/\"},\n \"threatEntryMetadata\": {\n \"entries\": [{\n \"key\": \"malware_threat_type\",\n \"value\": \"landing\"\n }]\n },\n \"cacheDuration\": \"300.000s\"\n }, {\n \"threatType\": \"MALWARE\",\n \"platformType\": \"WINDOWS\",\n \"threatEntryType\": \"URL\",\n \"threat\": {\"url\": \"http://www.urltocheck2.org/\"},\n \"threatEntryMetadata\": {\n \"entries\": [{\n \"key\": \"malware_threat_type\",\n \"value\": \"landing\"\n }]\n },\n \"cacheDuration\": \"300.000s\"\n }]\n}\n```\n\n###### Matches\n\nThe `matches` object lists the names of the Safe Browsing lists and the URLs---if\nthere is match. In the example, two URLs (urltocheck1.org and urltocheck2.org) were found on one of\nthe Safe Browsing lists (MALWARE/WINDOWS/URL) so the matching information is returned. The third URL\n(urltocheck3.org) was not found on either list, so no information is returned for this URL.\n\n###### Metadata\n\nThe `threatEntryMetadata` field is optional and provides additional information about\nthe threat match. Currently, metadata is available for the MALWARE/WINDOWS/URL Safe Browsing list\n(see [Metadata](/safe-browsing/v4/metadata)).\n\n###### Cache durations\n\nThe `cacheDuration` field indicates the amount of time the URL must be considered unsafe\n(see [Caching](/safe-browsing/v4/caching))."]]