<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API
provided by 极数本源 (https://apizero.cn). Prefer Authorization: Bearer.
Success is business code === 0 (do not treat HTTP 200 as success).
Generate working backend code; never put the API Key in a frontend or app.
API Key: https://apizero.cn/account/keys
Human docs: https://apizero.cn/aidocs/dns-query -->

# DNS 记录查询

查询域名的各类 DNS 记录，支持 A / AAAA / NS / CNAME / MX / TXT / CAA / SOA 共 8 种标准类型，以及 ANY（一次返回所有类型）。

✨ 特色：
  • 不依赖第三方工具站，完全自建 — 3 家国内 DoH 并发（AliDNS / DNSPod / 360）
  • 所有记录结构化解析：MX 拆 priority/exchange、CAA 拆 flags/tag/value、SOA 拆 mname/serial/...
  • 多家结果合并去重 + 各记录标注来自哪些 DoH（sources 字段）
  • 兼容数字 qtype（如 1=A / 15=MX / 257=CAA），不破坏旧调用方式
  • ANY 模式：单次请求拿到域名的全部 DNS 配置，免去多次查询

## 平台约定

- 网关：`https://v1.apizero.cn`
- 鉴权：`Authorization: Bearer <API Key>`（兼容 X-API-Key 与 Query api_key / apikey / key）
- 回包：`{ code, msg, data, tips, request_id }`。成功看 `code === 0`

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `dns-query` |
| 接口名称 | DNS 记录查询 |
| 接口地址 | `https://v1.apizero.cn/api/dns-query` |
| 请求方法 | `GET` |
| 分类 | 开发工具 |
| 提供方 | 极数本源 |
| 计费模式 | 完全免费 |
| QPS 限制 | 3 req/s |
| 登录免费额度 | 20 次 |
| 匿名每日额度 | 5 次 |

### 会员每日额度

| 会员档位 | 每日额度 | QPS |
| --- | --- | --- |
| 黄金会员 | 2,000 次/日 | QPS 10 |
| 钻石会员 | 5,000 次/日 | QPS 30 |
| 企业会员 | 100,000 次/日 | QPS 60 |

## 2. 认证

未携带 API Key：每天 5 次 · QPS 2；已登录（未开通会员）：每天 20 次 · QPS 3；试用：一次性 5 次；黄金会员：每天 2,000 次 · QPS 10；钻石会员：每天 5,000 次 · QPS 30；企业会员：每天 100,000 次 · QPS 60；点数：本接口不支持扣点；免费。一次普通查询走 3 个并发 DoH 请求。ANY 模式走 24 个（8 类型 × 3 家）。

获取 API Key：https://apizero.cn/account/keys

## 3. 子能力

### A 记录（推荐） (`a`)

查询 IPv4 地址（type=A，默认）。文档示例为 baidu.com 真实 DoH 合并结果。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `baidu.com` |
| `type` | `string` | 否 | 记录类型，此处固定 A（也可用数字编码） | `A` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.ip` | `string` | ip |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "baidu.com",
    "input": "baidu.com",
    "type": "A",
    "type_code": 1,
    "records": [
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 424,
        "data": "110.242.74.102",
        "parsed": {
          "ip": "110.242.74.102"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 424,
        "data": "111.63.65.103",
        "parsed": {
          "ip": "111.63.65.103"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 424,
        "data": "111.63.65.247",
        "parsed": {
          "ip": "111.63.65.247"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 424,
        "data": "124.237.177.164",
        "parsed": {
          "ip": "124.237.177.164"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      }
    ],
    "total": 4,
    "exec_ms": 170,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### AAAA 记录 (`aaaa`)

查询 IPv6 地址（type=AAAA / 28）。示例为 google.com。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `google.com` |
| `type` | `string` | 否 | 记录类型，此处固定 AAAA（也可用数字编码） | `AAAA` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.ip` | `string` | ip |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "google.com",
    "input": "google.com",
    "type": "AAAA",
    "type_code": 28,
    "records": [
      {
        "type": "AAAA",
        "type_code": 28,
        "name": "google.com",
        "ttl": 227,
        "data": "2607:f8b0:400e:c0a::64",
        "parsed": {
          "ip": "2607:f8b0:400e:c0a::64"
        },
        "sources": [
          "alidns"
        ]
      },
      {
        "type": "AAAA",
        "type_code": 28,
        "name": "google.com",
        "ttl": 227,
        "data": "2607:f8b0:400e:c0a::65",
        "parsed": {
          "ip": "2607:f8b0:400e:c0a::65"
        },
        "sources": [
          "alidns"
        ]
      },
      {
        "type": "AAAA",
        "type_code": 28,
        "name": "google.com",
        "ttl": 227,
        "data": "2607:f8b0:400e:c0a::71",
        "parsed": {
          "ip": "2607:f8b0:400e:c0a::71"
        },
        "sources": [
          "alidns"
        ]
      },
      {
        "type": "AAAA",
        "type_code": 28,
        "name": "google.com",
        "ttl": 227,
        "data": "2607:f8b0:400e:c0a::8b",
        "parsed": {
          "ip": "2607:f8b0:400e:c0a::8b"
        },
        "sources": [
          "alidns"
        ]
      },
      {
        "type": "AAAA",
        "type_code": 28,
        "name": "google.com",
        "ttl": 84,
        "data": "2a00:1450:4010:c0f::64",
        "parsed": {
          "ip": "2a00:1450:4010:c0f::64"
        },
        "sources": [
          "dnspod"
        ]
      },
      {
        "type": "AAAA",
        "type_code": 28,
        "name": "google.com",
        "ttl": 84,
        "data": "2a00:1450:4010:c0f::65",
        "parsed": {
          "ip": "2a00:1450:4010:c0f::65"
        },
        "sources": [
          "dnspod"
        ]
      }
    ],
    "total": 8,
    "exec_ms": 138,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### NS 记录 (`ns`)

权威名称服务器（type=NS / 2）。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `baidu.com` |
| `type` | `string` | 否 | 记录类型，此处固定 NS（也可用数字编码） | `NS` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.target` | `string` | target |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "baidu.com",
    "input": "baidu.com",
    "type": "NS",
    "type_code": 2,
    "records": [
      {
        "type": "NS",
        "type_code": 2,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "dns.baidu.com.",
        "parsed": {
          "target": "dns.baidu.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "NS",
        "type_code": 2,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "ns2.baidu.com.",
        "parsed": {
          "target": "ns2.baidu.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "NS",
        "type_code": 2,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "ns3.baidu.com.",
        "parsed": {
          "target": "ns3.baidu.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "NS",
        "type_code": 2,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "ns4.baidu.com.",
        "parsed": {
          "target": "ns4.baidu.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "NS",
        "type_code": 2,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "ns7.baidu.com.",
        "parsed": {
          "target": "ns7.baidu.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      }
    ],
    "total": 5,
    "exec_ms": 216,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### CNAME 记录 (`cname`)

别名记录（type=CNAME / 5）。示例为 www.github.com。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `www.github.com` |
| `type` | `string` | 否 | 记录类型，此处固定 CNAME（也可用数字编码） | `CNAME` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.target` | `string` | target |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "www.github.com",
    "input": "www.github.com",
    "type": "CNAME",
    "type_code": 5,
    "records": [
      {
        "type": "CNAME",
        "type_code": 5,
        "name": "www.github.com",
        "ttl": 3600,
        "data": "github.com.",
        "parsed": {
          "target": "github.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      }
    ],
    "total": 1,
    "exec_ms": 166,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### MX 记录 (`mx`)

邮件交换（type=MX / 15）。示例含 priority / exchange。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `gmail.com` |
| `type` | `string` | 否 | 记录类型，此处固定 MX（也可用数字编码） | `MX` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.priority` | `number` | priority |
| `records[].parsed.exchange` | `string` | exchange |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "gmail.com",
    "input": "gmail.com",
    "type": "MX",
    "type_code": 15,
    "records": [
      {
        "type": "MX",
        "type_code": 15,
        "name": "gmail.com",
        "ttl": 3600,
        "data": "10 alt1.gmail-smtp-in.l.google.com.",
        "parsed": {
          "priority": 10,
          "exchange": "alt1.gmail-smtp-in.l.google.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "MX",
        "type_code": 15,
        "name": "gmail.com",
        "ttl": 3600,
        "data": "20 alt2.gmail-smtp-in.l.google.com.",
        "parsed": {
          "priority": 20,
          "exchange": "alt2.gmail-smtp-in.l.google.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "MX",
        "type_code": 15,
        "name": "gmail.com",
        "ttl": 3600,
        "data": "30 alt3.gmail-smtp-in.l.google.com.",
        "parsed": {
          "priority": 30,
          "exchange": "alt3.gmail-smtp-in.l.google.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "MX",
        "type_code": 15,
        "name": "gmail.com",
        "ttl": 3600,
        "data": "40 alt4.gmail-smtp-in.l.google.com.",
        "parsed": {
          "priority": 40,
          "exchange": "alt4.gmail-smtp-in.l.google.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "MX",
        "type_code": 15,
        "name": "gmail.com",
        "ttl": 3600,
        "data": "5 gmail-smtp-in.l.google.com.",
        "parsed": {
          "priority": 5,
          "exchange": "gmail-smtp-in.l.google.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      }
    ],
    "total": 5,
    "exec_ms": 311,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### TXT 记录 (`txt`)

文本记录（type=TXT / 16），常用于 SPF/验证。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `google.com` |
| `type` | `string` | 否 | 记录类型，此处固定 TXT（也可用数字编码） | `TXT` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.text` | `string` | text |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "google.com",
    "input": "google.com",
    "type": "TXT",
    "type_code": 16,
    "records": [
      {
        "type": "TXT",
        "type_code": 16,
        "name": "google.com",
        "ttl": 451,
        "data": "\"MS=E4A68B9AB2BB9670BCE15412F62916164C0B20BB\"",
        "parsed": {
          "text": "MS=E4A68B9AB2BB9670BCE15412F62916164C0B20BB"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "TXT",
        "type_code": 16,
        "name": "google.com",
        "ttl": 451,
        "data": "\"Z29vZ2xl\"",
        "parsed": {
          "text": "Z29vZ2xl"
        },
        "sources": [
          "alidns",
          "china360"
        ]
      },
      {
        "type": "TXT",
        "type_code": 16,
        "name": "google.com",
        "ttl": 451,
        "data": "\"apple-domain-verification=30afIBcvSuDV2PLX\"",
        "parsed": {
          "text": "apple-domain-verification=30afIBcvSuDV2PLX"
        },
        "sources": [
          "alidns",
          "china360"
        ]
      },
      {
        "type": "TXT",
        "type_code": 16,
        "name": "google.com",
        "ttl": 451,
        "data": "\"cisco-ci-domain-verification=47c38bc8c4b74b7233e9053220c1bbe76bcc1cd33c7acf7acd36cd6a5332004b\"",
        "parsed": {
          "text": "cisco-ci-domain-verification=47c38bc8c4b74b7233e9053220c1bbe76bcc1cd33c7acf7acd36cd6a5332004b"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "TXT",
        "type_code": 16,
        "name": "google.com",
        "ttl": 451,
        "data": "\"docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e\"",
        "parsed": {
          "text": "docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "TXT",
        "type_code": 16,
        "name": "google.com",
        "ttl": 451,
        "data": "\"docusign=1b0a6754-49b1-4db5-8540-d2c12664b289\"",
        "parsed": {
          "text": "docusign=1b0a6754-49b1-4db5-8540-d2c12664b289"
        },
        "sources": [
          "alidns",
          "china360"
        ]
      }
    ],
    "total": 15,
    "exec_ms": 140,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### CAA 记录 (`caa`)

证书颁发机构授权（type=CAA / 257）。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `google.com` |
| `type` | `string` | 否 | 记录类型，此处固定 CAA（也可用数字编码） | `CAA` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.flags` | `number` | flags |
| `records[].parsed.tag` | `string` | tag |
| `records[].parsed.value` | `string` | value |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "google.com",
    "input": "google.com",
    "type": "CAA",
    "type_code": 257,
    "records": [
      {
        "type": "CAA",
        "type_code": 257,
        "name": "google.com",
        "ttl": 7200,
        "data": "0 issue \"pki.goog\"",
        "parsed": {
          "flags": 0,
          "tag": "issue",
          "value": "pki.goog"
        },
        "sources": [
          "alidns",
          "china360"
        ]
      }
    ],
    "total": 1,
    "exec_ms": 336,
    "sources": [
      "alidns",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### SOA 记录 (`soa`)

起始授权机构（type=SOA / 6）。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `baidu.com` |
| `type` | `string` | 否 | 记录类型，此处固定 SOA（也可用数字编码） | `SOA` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.mname` | `string` | mname |
| `records[].parsed.rname` | `string` | rname |
| `records[].parsed.serial` | `number` | serial |
| `records[].parsed.refresh` | `number` | refresh |
| `records[].parsed.retry` | `number` | retry |
| `records[].parsed.expire` | `number` | expire |
| `records[].parsed.minimum` | `number` | minimum |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "baidu.com",
    "input": "baidu.com",
    "type": "SOA",
    "type_code": 6,
    "records": [
      {
        "type": "SOA",
        "type_code": 6,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "dns.baidu.com. sa.baidu.com. 2012151296 300 300 2592000 600",
        "parsed": {
          "mname": "dns.baidu.com",
          "rname": "sa.baidu.com",
          "serial": 2012151296,
          "refresh": 300,
          "retry": 300,
          "expire": 2592000,
          "minimum": 600
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      }
    ],
    "total": 1,
    "exec_ms": 182,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```

### ANY 全部类型 (`any`)

一次拉取多种常见记录。部分解析器对 ANY 支持有限；文档示例已截断。

- 方法：`GET`
- 路径：`/api/dns-query`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `host` | `string` | 是 | 域名（自动剥离协议/路径/端口）；也兼容 domain | `baidu.com` |
| `type` | `string` | 否 | 记录类型，此处固定 ANY（也可用数字编码） | `ANY` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `host` | `string` | 规范化后的域名 |
| `type` | `string` | 请求类型（大写） |
| `type_code` | `integer` | 类型数字编码 |
| `records` | `array` | 记录列表：type / name / ttl / data / parsed / sources |
| `records[].type` | `string` | 类型 |
| `records[].type_code` | `number` | type_code |
| `records[].name` | `string` | 名称 |
| `records[].ttl` | `number` | ttl |
| `records[].data` | `string` | data |
| `records[].parsed` | `object` | parsed |
| `records[].parsed.ip` | `string` | ip |
| `records[].sources` | `array` | sources |
| `records[].sources[]` | `string` | sources 的一项 |
| `total` | `integer` | 记录总数 |
| `exec_ms` | `integer` | 耗时毫秒 |
| `sources` | `array` | 成功响应的 DoH 源 |
| `sources[]` | `string` | sources 的一项 |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "host": "baidu.com",
    "input": "baidu.com",
    "type": "ANY",
    "type_code": 0,
    "records": [
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 411,
        "data": "110.242.74.102",
        "parsed": {
          "ip": "110.242.74.102"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 411,
        "data": "111.63.65.103",
        "parsed": {
          "ip": "111.63.65.103"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 411,
        "data": "111.63.65.247",
        "parsed": {
          "ip": "111.63.65.247"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "A",
        "type_code": 1,
        "name": "baidu.com",
        "ttl": 411,
        "data": "124.237.177.164",
        "parsed": {
          "ip": "124.237.177.164"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "NS",
        "type_code": 2,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "dns.baidu.com.",
        "parsed": {
          "target": "dns.baidu.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      },
      {
        "type": "NS",
        "type_code": 2,
        "name": "baidu.com",
        "ttl": 7200,
        "data": "ns2.baidu.com.",
        "parsed": {
          "target": "ns2.baidu.com"
        },
        "sources": [
          "alidns",
          "china360",
          "dnspod"
        ]
      }
    ],
    "total": 16,
    "exec_ms": 1361,
    "sources": [
      "alidns",
      "dnspod",
      "china360"
    ],
    "notes": null
  },
  "tips": "极数本源 · https://apizero.cn"
}
```


## 5. 请求示例

Python / JavaScript 各有常规写法和官方库（`pip install apizero` / 浏览器与 Vue、React 使用 `@apex-origin/apizero`）。成功后先判断 `code == 0` 再读 `data`。

### cURL

```bash
curl -sS -H "Authorization: Bearer YOUR_API_KEY" "https://v1.apizero.cn/api/dns-query?host=%3Chost%3E"
```

### Python

```python
# 服务端常规写法：标准库 urllib，不用 pip
import json
import ssl
import urllib.error
import urllib.parse
import urllib.request

key = "YOUR_API_KEY"

url = "https://v1.apizero.cn/api/dns-query"
params = {
    "host": "<host>",
}
query = urllib.parse.urlencode({k: "" if v is None else str(v) for k, v in params.items()})
req = urllib.request.Request(
    url + ("?" + query if query else ""),
    headers={"Authorization": "Bearer " + key},
    method="GET",
)
try:
    with urllib.request.urlopen(
        req, timeout=20, context=ssl.create_default_context()
    ) as resp:
        raw = resp.read().decode("utf-8")
except urllib.error.HTTPError as e:
    raw = e.read().decode("utf-8", "replace")
body = json.loads(raw)
print(json.dumps(body, ensure_ascii=False, indent=2))
if body.get("code") == 0:
    print(body.get("data"))
```

### Python 官方库

```python
# 官方库（服务端）：先执行一次 pip install apizero
import apizero

key = "YOUR_API_KEY"
client = apizero.key(key)
r = client.dns_query(
    host="<host>",
)
if not r.ok:
    raise RuntimeError(r.msg)
print(r.ok, r.code)
print(r.json)
```

### JavaScript

```javascript
// 服务端 Node 18+ fetch
const key = "YOUR_API_KEY";
const url = "https://v1.apizero.cn/api/dns-query?host=%3Chost%3E";
const res = await fetch(url, {
  headers: { Authorization: `Bearer ${key}` },
});
const body = await res.json();
console.log(body);
if (body.code === 0) console.log(body.data);
```

### JavaScript 官方库（Node）

```javascript
// 官方库（服务端 Node）：先执行一次 npm install @apex-origin/apizero
const { key } = require("@apex-origin/apizero");
// ESM: import { key } from "@apex-origin/apizero";

const apiKey = "YOUR_API_KEY";
const client = key(apiKey);
const r = await client.dns_query({
  "host": "<host>",
});
if (!r.ok) throw new Error(r.msg);
console.log(r.ok, r.code);
console.log(r.json);
```

### Go

```go
// 服务端常规写法：net/http
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	key := "YOUR_API_KEY"

	url := "https://v1.apizero.cn/api/dns-query?host=%3Chost%3E"
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+key)
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	raw, _ := io.ReadAll(resp.Body)
	fmt.Println(string(raw))
}
```

### Java

```java
// 服务端常规写法：Java 11+ HttpClient
// Jackson：com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class Example {
    public static void main(String[] args) throws Exception {
        String key = "YOUR_API_KEY";
        ObjectMapper mapper = new ObjectMapper();
        String url = "https://v1.apizero.cn/api/dns-query?host=%3Chost%3E";

        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();
        HttpRequest req = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + key)
                .timeout(Duration.ofSeconds(20))
                .GET()
                .build();
        HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandlers.ofString());
        JsonNode body = mapper.readTree(resp.body());
        System.out.println(resp.body());
        if (body.path("code").asInt() == 0) {
            System.out.println(body.path("data"));
        }
    }
}
```

### PHP

```php
<?php
// 服务端常规写法：curl，强制 TLS 1.2
$key = "YOUR_API_KEY";

$ch = curl_init("https://v1.apizero.cn/api/dns-query?host=%3Chost%3E");
$opts = [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 20,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer '.$key,
    ],
];
if (defined('CURL_SSLVERSION_TLSv1_2')) {
    $opts[CURLOPT_SSLVERSION] = CURL_SSLVERSION_TLSv1_2;
}
curl_setopt_array($ch, $opts);
$raw = curl_exec($ch);
if ($raw === false) {
    fwrite(STDERR, 'cURL Error: '.curl_error($ch).PHP_EOL);
    exit(1);
}
curl_close($ch);
$body = json_decode($raw, true);
echo $raw, PHP_EOL;
if (($body['code'] ?? null) === 0) {
    echo json_encode($body['data'] ?? null, JSON_UNESCAPED_UNICODE), PHP_EOL;
}
```

### Rust

```rust
// 服务端常规写法
// cargo add reqwest --features json,blocking ; cargo add serde_json
use reqwest::blocking::Client;
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION};
use serde_json::Value;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let key = "YOUR_API_KEY";

    let url = "https://v1.apizero.cn/api/dns-query?host=%3Chost%3E";
    let mut headers = HeaderMap::new();
    headers.insert(
        AUTHORIZATION,
        HeaderValue::from_str(&format!("Bearer {key}"))?,
    );
    let body: Value = Client::new()
        .get(url)
        .headers(headers)
        .timeout(std::time::Duration::from_secs(20))
        .send()?
        .json()?;
    println!("{}", serde_json::to_string_pretty(&body)?);
    Ok(())
}
```

## 8. 错误码

先看业务 code。HTTP 也可能不是 200。

| 业务码 | HTTP | 说明 |
| --- | --- | --- |
| 0 | 200 | 成功 |
| 4000 | 400 | 参数错误 |
| 4011 | 401 | API Key 无效 |
| 4013 | 403 | API Key 已暂停 |
| 4014 | 403 | 当前 IP 不在 Key 白名单 |
| 4015 | 401 | 此接口需要 API Key |
| 4022 | 402 | 余额不足 |
| 4029 | 429 | 调用过快（QPS） |
| 4030 | 429 | 今日免费额度已用完 |
| 4040 | 503 | 接口已下线 |
| 4041 | 404 | 接口不存在 |
| 5000 | 500 | 服务器内部错误 |
| 5020 | 502 | 上游暂时不可用 |
| 5021 | 502 | 上游返回格式异常 |
| 5030 | 502 | 暂无可用节点 |


## 9. 变更日志

- **1.0.0** (2026-05-06): 首次发布：3 家国内 DoH 并发（AliDNS / DNSPod / 360），不依赖第三方工具站
支持 8 种标准类型（A/AAAA/NS/CNAME/MX/TXT/CAA/SOA）+ ANY 一次查全
所有记录附带 parsed 结构化解析（MX/CAA/SOA/TXT 等）
兼容数字 qtype 老接口（1/2/5/6/15/16/28/257）
记录去重：(type, data) 组合 key + sources 字段标注来源
