API documentation
LiteDNS exposes two protocols: a JSON API for scripts and agents, and DoH for standard DNS clients. Both use the same API key and the same account quota.
Authentication
Send the key in the X-API-Key header for JSON requests. DoH clients that cannot set custom headers put the key in the URL path, exactly as shown below. Keys can be renamed or revoked at any time in the console.
JSON API
POST /api/open/resolve with a JSON body, or use GET with query parameters for a quick curl check. The region must be cn or us. Supported types are A, AAAA, CNAME, TXT, MX, NS and SOA.
curl -s https://dns.litelake.cn/api/open/resolve \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"domain":"example.com","type":"A","region":"cn"}'JSON API
{
"code": 200,
"message": "ok",
"data": {
"status": "NOERROR",
"rcode": 0,
"answers": [
{ "name": "example.com.", "type": "A", "ttl": 300, "data": "93.184.216.34" }
],
"provenance": {
"region": "cn",
"exec_region": "cn",
"upstream": "223.5.5.5",
"cache": "miss",
"latency_ms": 23
}
}
}DNS over HTTPS
GET /api/open/doh/{region}/{apikey}?dns={base64url} and POST /api/open/doh/{region}/{apikey} with an application/dns-message body. Any valid DNS answer, including NXDOMAIN or SERVFAIL, is returned with HTTP 200 and the wire response.
GET
curl -s -H "Accept: application/dns-message" \
"https://dns.litelake.cn/api/open/doh/cn/YOUR_KEY?dns=AAABAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB"POST
curl -s -X POST \
-H "Content-Type: application/dns-message" \
--data-binary @query.bin \
"https://dns.litelake.cn/api/open/doh/cn/YOUR_KEY"Region parameter
The region is an explicit parameter, not an automatic GeoDNS decision. Unknown regions return 404.
region=cn— cn — China vantage, executed by the China edge with mainland upstreams.region=us— us — overseas vantage, executed by the overseas edge with unfiltered upstreams.
Provenance
Every JSON answer carries the region, executing region, upstream that produced the answer, cache state (miss, fresh or stale) and latency. DoH exposes region, upstream and cache through X-LiteDNS-Region, X-LiteDNS-Upstream and X-LiteDNS-Cache.
region · exec_region · upstream · cache · latency_ms · rcode
Error codes
The JSON API uses native HTTP status codes for failures. DoH follows RFC 8484: valid DNS answers are always 2xx, while 4xx status codes indicate that no DNS answer was produced.
| HTTP | Error codes |
|---|---|
| 400 | Invalid domain, type or message format. |
| 401 | Missing or invalid API key. |
| 403 | Key revoked, tier unavailable or scope not allowed. |
| 404 | Unknown region. |
| 406 | Accept does not allow application/dns-message. |
| 413 | Request body exceeds 64 KB. |
| 415 | Unsupported media type. |
| 429 | Account quota exceeded. Retry after the Retry-After interval. |
| 504 | All upstreams failed and no cache could answer. |
Client configuration
The DoH URL contains a path, which standard clients support. Use the full keyed URL from the console.
| Client configuration | Status | Note |
|---|---|---|
| Firefox custom DoH | Supported | Enter the full keyed URL. |
| Chrome / Edge secure DNS | Supported | URI template may include the path. |
| iOS / macOS profile | Supported | Use the full URL in the DNS settings payload. |
| curl / programmatic | Supported | GET with base64url or POST with wire bytes. |
| Android Private DNS | Not supported | Accepts a hostname only and cannot carry a key path. |
Agent skill
No authentication is required to read the skill document. Keep your API key out of shared logs.
Open /docs/skill.md