# DNS Records

List all DNS Records (subdomains, A, MX, CNAME, TXT, etc) for a domain.

Subdomains are auto-disovered, and hints for more obscure ones can be sent to the API to check for.

**Pro tip**: use the "Accept" header to retrieve the DNS records in different types:

* "application/json" - get DNS Records as JSON objects
* "text/plain" - get DNS Records as text lines in 2 modes: wait for full response or read streamed lines as they are discovered (see JavaScript Fetch example below)

<mark style="color:blue;">`GET`</mark> `https://domains-api.com/domains/{domain}/dns-records`

#### Path Parameters

| Name                                     | Type   | Description       |
| ---------------------------------------- | ------ | ----------------- |
| domain<mark style="color:red;">\*</mark> | String | Valid domain name |

#### Query Parameters

| Name      | Type   | Description                  |
| --------- | ------ | ---------------------------- |
| type      | String | A, AAAA, MX, etc             |
| apiKey    | String | Your API Key                 |
| subdomain | String | Extra subdomain to check for |

#### Headers

| Name          | Type   | Description                                                                                                                     |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------- |
| Authorization | String | Your API Key                                                                                                                    |
| Accept        | String | <p>- "text/plain" (default): return DNS records as text lines</p><p>- "application/json": return DNS records as JSON object</p> |

### Examples

{% tabs %}
{% tab title="JS - fetch" %}

```javascript
const domain = 'openai.com'

// text/plain - get DNS records as they are discovered (stream)
fetch(`/domains/${domain}/dns-records?key=_api_key_`)
    .then(async response => {
        if (response.ok) {
            const reader = response.body.getReader()
            const decoder = new TextDecoder()
            while (true) {
                const {done, value} = await reader.read();
                if (done) return;
                
                // dns record line
                console.log(decoder.decode(value))
            }
        }
    })

// text/plain - wait for full response
fetch(`/domains/${domain}/dns-records?key=_api_key_`)
    .then(response => response.text())
    .then(dnsRecords => {
        console.log('all DNS Records', dnsRecords)
    })

// application/json
fetch(`/domains/${domain}/dns-records?key=_api_key_`, {
    headers: {
        accept: 'application/json',
    }
})
    .then(response => response.json())
    .then(dnsRecords => {
        console.log('all DNS Records', dnsRecords)
    })
```

{% endtab %}

{% tab title="JS - axios" %}

```javascript
import axios from 'axios'

const domain = 'github.com'
const { data: dnsRecords } = await axios(`https://domains-api.com/domain/${domain}/dns-records?key=_key_`, {
  headers: {
    accept: 'application/json'
  }
})

console.log('all dns records', dnsRecords)
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dmns.app/api/api-endpoints/dns-records.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
