Quake 主机索引数据检索
接口说明
按 Quake 查询语句(QRule DSL)在 quake_host(主机维度网络测绘资产)索引中检索资产,返回以主机 IP 为核心、聚合其下多个服务/端口的结构化数据,支持分页、时间范围过滤、返回字段裁剪与多种输出格式。 与 quake_service(单条服务记录)不同,quake_host 以主机为单位组织数据,一个 IP 下挂载多个 services(端口/服务)。
请求地址
https://api.f.360.cn/api/v3/search/quake_host
请求方法
POST
请求参数
| 名称 | 类型 | 位置 | 是否必填 | 示例值 | 说明 |
|---|---|---|---|---|---|
| query | string | body | 是 | - | Quake 查询语句(QRule DSL);传空按 * 处理 |
| rule | string | body | 否 | - | 类型为IP列表的服务数据收藏名称 |
| ip_list | List[string] | body | 否 | - | IP列表 |
| start | int | body | 否 | 0 | 分页起始 |
| size | int | body | 否 | 10 | 分页大小 |
| ignore_cache | bool | body | 否 | false | 是否忽略缓存 |
| start_time | string | body | 否 | - | 查询起始时间,接受2020-10-14 00:00:00格式的数据,时区为UTC |
| end_time | string | body | 否 | - | 查询截止时间,接受2020-10-14 00:00:00格式的数据,时区为UTC |
| include | List(string) | body | 否 | - | 包含字段 |
| exclude | List(string) | body | 否 | - | 排除字段 |
| latest | string | body | 否 | - | 是否只统计最新数据(去重库 unique);false 使用全量库 |
响应参数
| 一级字段 | 二级字段 | 类型 | 可选值 | 描述 |
|---|---|---|---|---|
| code | Integer | String | 0 | 响应状态码,0 表示成功 | |
| message | string | 响应说明 | ||
| data | array | 查询结果列表,每条记录对应一个主机 | ||
| data | ip | string | IP 地址 | |
| data | hostname | string | 主机名,无则为空字符串 | |
| data | org | string | 所属组织 | |
| data | asn | integer | ASN 编号 | |
| data | is_ipv6 | boolean | true/false | 是否为 IPv6 |
| data | time | string | ISO8601 | 最新数据更新时间 |
data.services(主机上的服务列表)
| 一级字段 | 二级字段 | 类型 | 说明 |
|---|---|---|---|
| data.services | array | 该主机上检测到的所有服务 | |
| data.services | port | integer | 服务端口 |
| data.services | name | string | 服务名称 |
| data.services | transport | string | 传输协议(tcp/udp) |
| data.services | version | string | 服务协议版本 |
| data.services | cert | string | 服务证书,无则为空字符串 |
| data.services | service_id | string | 服务记录唯一标识 |
| data.services | time | string | 该服务数据更新时间(ISO8601) |
| data.services | components | array | 识别出的产品组件列表(结构同服务索引检索接口) |
data.location
| 一级字段 | 二级字段 | 类型 | 说明 |
|---|---|---|---|
| data.location | object | 地理位置信息 | |
| data.location | country_cn | string | 国家(中文) |
| data.location | country_en | string | 国家(英文) |
| data.location | country_code | string | 国家代码 |
| data.location | province_cn | string | 省份(中文) |
| data.location | province_en | string | 省份(英文) |
| data.location | city_cn | string | 城市(中文) |
| data.location | city_en | string | 城市(英文) |
| data.location | district_cn | string | 区县(中文) |
| data.location | district_en | string | 区县(英文) |
| data.location | street_cn | string | 街道(中文) |
| data.location | street_en | string | 街道(英文) |
| data.location | gps | array | 经纬度坐标 [longitude, latitude] |
| data.location | radius | number | 定位精度(公里) |
| data.location | isp | string | 网络运营商 |
| data.location | owner | string | 资产所有者 |
| data.location | asname | string | ASN 名称 |
| data.location | scene_cn | string | 场景类型(中文) |
| data.location | scene_en | string | 场景类型(英文) |
meta
| 一级字段 | 二级字段 | 类型 | 说明 |
|---|---|---|---|
| meta | object | 元数据 | |
| meta.pagination | object | 分页信息 | |
| meta.pagination | count | integer | 当前页返回数量 |
| meta.pagination | page_index | integer | 当前页码 |
| meta.pagination | page_size | integer | 每页数量 |
| meta.pagination | total | integer | 总记录数 |
请求示例
支持cUrl、Python、Java、PHP、Go语言的请求,示例如下
#!/usr/bin/env bash
set -euo pipefail
APPID="" # apikey
SECRET="" # salt
URL="https://api.f.360.cn/api/v3/search/quake_host"
BODY='{"query":"country_cn: \"中国\" AND services.port: 22","start":0,"size":10,"latest":true,"include":["ip","hostname","asn","org","time","location.country_cn","location.province_cn","location.city_cn","location.country_en","location.province_en","location.city_en","location.gps"]}'
NONCE=$(printf '%08d' $((RANDOM % 100000000)))
TIMESTAMP=$(date +%s)
BODY_MD5=$(printf '%s' "$BODY" | openssl dgst -md5 -hex | awk '{print $NF}')
SIGNATURE=$(printf '%s' "${BODY_MD5}${APPID}${NONCE}${TIMESTAMP}${SECRET}" | openssl dgst -md5 -hex | awk '{print $NF}')
SIGNATURE=${SIGNATURE:16}
curl --location --request POST "$URL" \
--header "Content-Type: application/json" \
--header "X-360-Key: ${APPID}" \
--header "X-360-Nonce: ${NONCE}" \
--header "X-360-Timestamp: ${TIMESTAMP}" \
--header "X-360-Signature: ${SIGNATURE}" \
--data "${BODY}"# -*- coding:utf-8 -*-
import hashlib
import json
import random
import time
import requests
APPID = "" # apikey
SECRET = "" # salt
def make_headers(appid, secret, body=""):
headers = {}
headers["X-360-Key"] = appid
headers["X-360-Nonce"] = str(random.randint(0, 99999999)).zfill(8)
headers["X-360-Timestamp"] = str(int(time.time()))
s = (
hashlib.md5(body.encode("utf8")).hexdigest()
+ headers["X-360-Key"]
+ headers["X-360-Nonce"]
+ headers["X-360-Timestamp"]
+ secret
)
md5 = hashlib.md5(s.encode("utf8")).hexdigest()
headers["X-360-Signature"] = md5[16:]
headers["Content-Type"] = "application/json"
return headers
def do_post(url, body):
res = requests.post(
url,
data=json.dumps(body),
headers=make_headers(APPID, SECRET, json.dumps(body)),
)
print(res.text)
if __name__ == "__main__":
url = "https://api.f.360.cn/api/v3/search/quake_host"
params = {
"query": 'country_cn: "中国" AND services.port: 22',
"start": 0,
"size": 10,
"latest": True,
"include": [
"ip", "hostname", "asn", "org", "time",
"location.country_cn", "location.province_cn", "location.city_cn",
"location.country_en", "location.province_en", "location.city_en",
"location.gps"
],
}
do_post(url, params)import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.concurrent.ThreadLocalRandom;
public class Demo {
static String md5(String input) throws Exception {
byte[] digest = MessageDigest.getInstance("MD5")
.digest(input.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%02x", b & 0xff));
}
return sb.toString();
}
public static void main(String[] args) throws Exception {
String appid = ""; // apikey
String secret = ""; // salt
String url = "https://api.f.360.cn/api/v3/search/quake_host";
String body = "{\"query\":\"country_cn: \\\"中国\\\" AND services.port: 22\",\"start\":0,\"size\":10,\"latest\":true,\"include\":[\"ip\",\"hostname\",\"asn\",\"org\",\"time\",\"location.country_cn\",\"location.province_cn\",\"location.city_cn\",\"location.country_en\",\"location.province_en\",\"location.city_en\",\"location.gps\"]}";
String nonce = String.format("%08d", ThreadLocalRandom.current().nextInt(100000000));
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
String signature = md5(md5(body) + appid + nonce + timestamp + secret).substring(16);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("X-360-Key", appid)
.header("X-360-Nonce", nonce)
.header("X-360-Timestamp", timestamp)
.header("X-360-Signature", signature)
.POST(HttpRequest.BodyPublishers.ofString(body, StandardCharsets.UTF_8))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
System.out.println(response.body());
}
}<?php
// apikey
$appid = "";
// salt
$secret = "";
$url = 'https://api.f.360.cn/api/v3/search/quake_host';
$body = json_encode([
'query' => 'country_cn: "中国" AND services.port: 22',
'start' => 0,
'size' => 10,
'latest' => true,
'include' => [
'ip',
'hostname',
'asn',
'org',
'time',
'location.country_cn',
'location.province_cn',
'location.city_cn',
'location.country_en',
'location.province_en',
'location.city_en',
'location.gps',
],
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$nonce = str_pad((string) random_int(0, 99999999), 8, "0", STR_PAD_LEFT);
$timestamp = (string) time();
$signature = substr(md5(md5($body) . $appid . $nonce . $timestamp . $secret), 16);
$ch = curl_init($url);
$options = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-360-Key: {$appid}",
"X-360-Nonce: {$nonce}",
"X-360-Timestamp: {$timestamp}",
"X-360-Signature: {$signature}",
],
];
$options[CURLOPT_POST] = true;
$options[CURLOPT_POSTFIELDS] = $body;
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if ($response === false) {
echo curl_error($ch), PHP_EOL;
} else {
echo $response, PHP_EOL;
}
curl_close($ch);package main
import (
"bytes"
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"math/rand"
"net/http"
"time"
)
func md5Hex(s string) string {
sum := md5.Sum([]byte(s))
return hex.EncodeToString(sum[:])
}
func main() {
appid := "" // apikey
secret := "" // salt
url := "https://api.f.360.cn/api/v3/search/quake_host"
body := []byte(`{"query":"country_cn: \"中国\" AND services.port: 22","start":0,"size":10,"latest":true,"include":["ip","hostname","asn","org","time","location.country_cn","location.province_cn","location.city_cn","location.country_en","location.province_en","location.city_en","location.gps"]}`)
nonce := fmt.Sprintf("%08d", rand.Intn(100000000))
timestamp := fmt.Sprintf("%d", time.Now().Unix())
signature := md5Hex(md5Hex(string(body)) + appid + nonce + timestamp + secret)[16:]
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-360-Key", appid)
req.Header.Set("X-360-Nonce", nonce)
req.Header.Set("X-360-Timestamp", timestamp)
req.Header.Set("X-360-Signature", signature)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
respBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(respBody))
}响应示例
业务正常响应
{
"code": 0,
"message": "Successful.",
"data": [
{
"hostname": "",
"org": "Alibaba Cloud",
"ip": "47.239.173.172",
"asn": 45102,
"is_ipv6": false,
"time": "2026-07-03T05:08:19.848Z",
"location": {
"owner": "",
"province_cn": "香港",
"isp": "阿里云",
"province_en": "Hongkong",
"country_en": "China",
"district_cn": "",
"gps": [114.184921, 22.350617],
"street_cn": "",
"city_en": "Hongkong",
"district_en": "",
"country_cn": "中国",
"street_en": "",
"city_cn": "香港",
"country_code": "CN",
"asname": "ALIBABA-CN-NET",
"scene_cn": "数据中心",
"scene_en": "Hosting",
"radius": 40.0088
},
"services": [
{
"components": [
{
"product_level": "服务协议层",
"product_type": ["常见网络服务"],
"product_vendor": "openssh",
"product_name_cn": "OpenSSH",
"product_name_en": "openssh",
"id": "5e831df9421aa99e9885e4bc",
"product_catalog": ["网络设备与服务"],
"version": "7.4"
}
],
"port": 22,
"service_id": "e446749d37e55d8ebfa7c75513a0ab08",
"name": "ssh",
"cert": "",
"transport": "tcp",
"time": "2026-05-28T23:41:47.644Z",
"version": "2.0"
},
{
"components": [],
"port": 32080,
"service_id": "6f42e3d08ee759b3aa076d026ab23973",
"name": "socks-proxy",
"cert": "",
"transport": "tcp",
"time": "2025-06-12T02:50:12.407Z",
"version": ""
}
]
}
],
"meta": {
"pagination": {
"count": 10,
"page_index": 1,
"page_size": 10,
"total": 1000
}
}
}业务异常响应
{
"code": "t6003",
"message": "查询请求出错,请检查查询语句,或者与管理员联系",
"data": {},
"meta": {}
}{
"code": "GC00105",
"src": "apiholder",
"msg": "appid over field"
}{
"code": "q2001",
"message": "用户当前积分不足以完成本次查询操作。",
"data": {},
"meta": {}
}Quake 检索类接口业务错误码(HTTP 状态码均为 200,通过 code 字段区分):
| code | message | 说明 |
|---|---|---|
| 0 | Successful. | 查询成功 |
| q2001 | 用户当前积分不足以完成本次查询操作。 | 账号积分不足,无法完成本次检索,需充值或联系管理员提升积分 |
| q2001 | 筛选字段传参错误: [xxx], 请调用可筛选字段接口查看可筛选字段 | include/exclude 传入了不在白名单内的字段,先调用对应索引的可筛选字段接口获取白名单 |
| q3005 | 调用API过于频繁 | 触发接口调用频率限制,降低调用频率(建议两次检索间隔15秒以上)后重试 |