DNS over HTTPS JSON API needs some tweaks

The new DNS over HTTPS JSON API is nice (and #ty for keeping it similar to Google’s; grassroots standards FTW) but you may want to look at quoting at least TXT record responses.

curl 'https://Cloudflare-dns.com/dns-query?ct=application/dns-json&name=google-public-dns-a.google.com&type=TXT'


{"Status": 0,"TC": false,"RD": true, "RA": true, "AD": false,"CD": false,"Question":[{"name": "google-public-dns-a.google.com.", "type": 16}],"Answer":[{"name": "google-public-dns-a.google.com.", "type": 16, "TTL": 3516, "data": ""http://xkcd.com/1361/""}]}

and the data component in Answer is malformed.

And, I hit submit too soon.

Also: Google’s DNS over HTTPS JSON API lets users submit numerical types as well as alpha one. e.g. 255 as well as ANY. Is there a plan to normalize this as well?

And, since I just noticed “ANY” is an invalid query, I tried it with 1 (A) and that does not work so it wasn’t just an error with ANY. Noting that ANY is not supported wld be gd as well.

For reference, the context for these questions is a new R package: dnsflare.

@hrbrmstr thanks for reporting! Numerical values for types should already work. The ANY query is not supported (see the Status field in the JSON response), I’ll update the documentation to reflect that. I’m already tracking the broken escaping in TXT answers, I’ll let you know when the fix rolls out.

1 Like

I’ll try the numeric again (I may be sending a JSON string vs integer). Thx for the quick response!

Yep. That was it. If it’s a JSON integer it works great. Thx!

The string data is now properly escaped, let me know if you encounter any other problems:

$ curl '' | jq .
  "Status": 0,
  "TC": false,
  "RD": true,
  "RA": true,
  "AD": false,
  "CD": false,
  "Question": [
      "name": "google-public-dns-a.google.com.",
      "type": 16
  "Answer": [
      "name": "google-public-dns-a.google.com.",
      "type": 16,
      "TTL": 86400,
      "data": "\"http://xkcd.com/1361/\""
1 Like

works perfectly! #ty

1 Like