Skip to content

Cloudflare's DNS over HTTPS endpoint also supports JSON format for querying DNS data. For lack of an agreed upon JSON schema for DNS over HTTPS in the Internet Engineering Task Force (IETF), Cloudflare has chosen to follow the same schema as Google's DNS over HTTPS resolver.

JSON formatted queries are sent using a GET request. When making requests using GET, the DNS query is encoded into the URL. The client should include an HTTP Accept request header field with a MIME type of application/dns-json to indicate that the client is able to accept a JSON response from the DNS over HTTPS resolver.

Supported parameters

FieldRequired?DescriptionDefault
nameYesQuery name.-
typeNoQuery type (either a numeric value or text).A
doNoDO bit - whether the client wants DNSSEC data (either empty or one of 0, false, 1, or true).false
cdNoCD bit - disable validation (either empty or one of 0, false, 1, or true).false

Examples

Example request and response:

Terminal window
curl --header "accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=example.com&type=AAAA"
{
"Status": 0,
"TC": false,
"RD": true,
"RA": true,
"AD": true,
"CD": false,
"Question": [
{
"name": "example.com.",
"type": 28
}
],
"Answer": [
{
"name": "example.com.",
"type": 28,
"TTL": 1726,
"data": "2606:2800:220:1:248:1893:25c8:1946"
}
]
}

In the case of an invalid request a 400 Bad Request error is returned:

Terminal window
curl --header "accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=example.com&cd=2"
{
"error": "Invalid CD flag `2`. Expected to be empty or one of `0`, `false`, `1`, or `true`."
}

Response fields

The following tables have more information on each response field.

Successful response

FieldDescription
StatusThe Response Code of the DNS Query. The codes are defined here: