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.

The product-internal skill document is served as plain Markdown for AI agents and scripts. It covers installation, configuration, JSON and DoH usage, and error handling.Open /docs/skill.md

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.

HTTPError codes
400Invalid domain, type or message format.
401Missing or invalid API key.
403Key revoked, tier unavailable or scope not allowed.
404Unknown region.
406Accept does not allow application/dns-message.
413Request body exceeds 64 KB.
415Unsupported media type.
429Account quota exceeded. Retry after the Retry-After interval.
504All 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 configurationStatusNote
Firefox custom DoHSupportedEnter the full keyed URL.
Chrome / Edge secure DNSSupportedURI template may include the path.
iOS / macOS profileSupportedUse the full URL in the DNS settings payload.
curl / programmaticSupportedGET with base64url or POST with wire bytes.
Android Private DNSNot supportedAccepts 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