DNS 记录查询 API 接入文档dns-query
查询域名的各类 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 配置,免去多次查询
1. 基本信息
| 接口地址 | https://v1.apizero.cn/api/dns-query |
|---|---|
| 请求方法 | GET |
| 分类 | dev |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 10 req/s |
| 每日免费额度 | 500 次(已认证用户) |
| 匿名每日额度 | 100 次(无 API Key) |
| VIP 免费 | 否 |
| 调用次数 |
2. 认证
匿名 QPS=3、日 100;登录 QPS=10、日 500。一次普通查询走 3 个并发 DoH 请求;ANY 模式走 24 个(8 类型 × 3 家)。
获取 API Key:登录 https://apizero.cn/account/keys
3. 请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
host | string | 是 | 域名(自动剥离 http(s)://、路径、端口) | — |
type | string | 否 | 记录类型,默认 A。支持名称(A/AAAA/NS/CNAME/MX/TXT/CAA/SOA/ANY)或数字编码(1/2/5/6/15/16/28/257) | — |
4. 请求头
| Header | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
X-API-Key | string | 否 | API Key(不传走匿名额度) | — |
5. 请求示例
以下 5 种语言示例都是可直接运行的,只需把 YOUR_API_KEY 替换为实际 Key。
cURL
curl "https://v1.apizero.cn/api/dns-query?host=%3Chost%3E&type=%3Ctype%3E&key=YOUR_API_KEY"Python
import requests
resp = requests.get(
"https://v1.apizero.cn/api/dns-query",
params={
"host": "<host>",
"type": "<type>",
"key": "YOUR_API_KEY",
},
timeout=15,
)
resp.raise_for_status()
print(resp.json())JavaScript (Node.js)
// Node.js 18+ / 浏览器原生 fetch
const params = new URLSearchParams({
"host": "<host>",
"type": "<type>",
"key": "YOUR_API_KEY",
});
const res = await fetch(`https://v1.apizero.cn/api/dns-query?${params}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);Go
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://v1.apizero.cn/api/dns-query", nil)
q := req.URL.Query()
q.Set("host", "<host>")
q.Set("type", "<type>")
q.Set("key", "YOUR_API_KEY")
req.URL.RawQuery = q.Encode()
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}PHP
<?php
$url = "https://v1.apizero.cn/api/dns-query?" . http_build_query([
"host" => "<host>",
"type" => "<type>",
"key" => "YOUR_API_KEY",
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
print_r($data);6. 响应字段
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
host | string | 规范化后的域名 | — |
input | string | 原始输入回显 | — |
type | string | 请求类型(标准化为大写名称) | — |
type_code | integer | 类型数字编码;ANY 模式下为 0 | — |
total | integer | 记录总数(去重后) | — |
exec_ms | integer | 总耗时(毫秒) | — |
sources | string[] | 成功响应的 DoH 列表(alidns/dnspod/china360) | — |
notes | string|null | 提示信息(如未找到记录时) | — |
records | array | 记录列表 | — |
records[].type | string | 记录类型名(A/AAAA/NS/CNAME/MX/TXT/CAA/SOA) | — |
records[].type_code | integer | 类型数字编码 | — |
records[].name | string | 记录所属域名 | — |
records[].ttl | integer | TTL 秒(多家返回时取最大值) | — |
records[].data | string | 原始 rdata 字符串(与 dig 输出一致) | — |
records[].parsed | object | ★ 结构化解析结果(详见下方各类型说明) | — |
records[].sources | string[] | 哪些 DoH 返回了此条记录 | — |
parsed (A/AAAA) | object | { "ip": "111.63.65.103" } | — |
parsed (CNAME/NS) | object | { "target": "ns1.baidu.com" }(自动去除末尾点) | — |
parsed (MX) | object | { "priority": 10, "exchange": "mx.baidu.com" } | — |
parsed (TXT) | object | { "text": "v=spf1 ..." }(去除外层引号 + 拼接长 TXT 段) | — |
parsed (CAA) | object | { "flags": 0, "tag": "issue", "value": "digicert.com" } | — |
parsed (SOA) | object | { "mname": "ns.foo.com", "rname": "admin.foo.com", "serial": 2024010101, "refresh": 7200, "retry": 3600, "expire": 1209600, "minimum": 600 } | — |
7. 响应示例
{
"code": 0,
"msg": "成功",
"data": {
"host": "baidu.com",
"input": "baidu.com",
"type": "MX",
"type_code": 15,
"total": 2,
"exec_ms": 234,
"sources": [
"alidns",
"china360",
"dnspod"
],
"notes": null,
"records": [
{
"type": "MX",
"type_code": 15,
"name": "baidu.com",
"ttl": 600,
"data": "10 mx.maillb.baidu.com.",
"parsed": {
"priority": 10,
"exchange": "mx.maillb.baidu.com"
},
"sources": [
"alidns",
"china360",
"dnspod"
]
},
{
"type": "MX",
"type_code": 15,
"name": "baidu.com",
"ttl": 600,
"data": "20 mx.baidu.com.",
"parsed": {
"priority": 20,
"exchange": "mx.baidu.com"
},
"sources": [
"alidns",
"china360",
"dnspod"
]
}
]
},
"request_id": "mota..."
}8. 错误码
| code | status | 说明 |
|---|---|---|
0 | OK | 成功(即使无匹配记录也返回 200,records 为空数组,notes 给出提示) |
4000 | Bad Request | 参数错误:host 缺失 / 域名格式错 / type 不合法 |
4011 | Unauthorized | API Key 无效 |
4013 | Forbidden | API Key 已暂停 |
4014 | Forbidden | 当前 IP 不在 API Key 白名单内 |
4029 | Too Many Requests | QPS 限流 |
4030 | Too Many Requests | 今日免费额度已用完 |
5020 | Bad Gateway | 所有 DoH 服务器都失败 |
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 字段标注来源
常见问题
DNS 记录查询 接口怎么免费使用?
未登录用户每个 IP 每天 100 次免费。登录用户创建 API Key 后每天 500 次免费,超额部分按点数计费(0 点/次)。
DNS 记录查询 支持哪些调用方式?
接口使用 GET 请求。文档提供 cURL、Python、JavaScript (Node.js)、Go、PHP 五种语言的可运行示例。也可以下载 /openapi.json 导入 Postman / Insomnia / Apifox 反向生成 SDK。
调用不限额么? QPS 是多少?
本接口 QPS 限制 10 req/s,每个 API Key 每日免费 500 次。需要更高额度可升级 VIP 套餐或联系售后提高 QPS。
这个接口跟自己直连上游有什么区别?
极数本源 作为中间层提供:统一鉴权(一个 Key 调所有接口)、统一计费(点数制)、统一限流、统一错误码、多上游自动切换。免去逐个对接上游、维护 Key、统计调用量的运维成本。