# Domain lookup

> POST /domain reads a domain's registration over RDAP (age, expiry, registrar, statuses) and sums up its DNS records, SPF, DMARC and disposable flag.

`POST https://api.qelka.com/v1/domain`

Find out when a domain was registered, when it expires and which registrar holds it, and see how it handles email: you get its registration from the registry, its main DNS records, its SPF and DMARC setup, and whether it is a disposable email domain. Each lookup costs 1 credit; lookups the registry could not answer, errors and test keys are never billed.

## Request

Send a domain, a URL or an email address. The registration is read over RDAP (Registration Data Access Protocol), the protocol registries use to publish registration data.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `domain` | string | Yes | none | A domain name, 1 to 320 characters. A URL (`https://www.example.com/page`) or an email address (`jane@example.com`) works too: its host is reduced to the registrable domain, so `shop.example.co.uk` is looked up as `example.co.uk`. Internationalized names are converted to punycode. |
| `fresh` | boolean | No | `false` | `true` skips the 24-hour result cache. |

Input that is not a domain name, such as `localhost` or a string with spaces, is a `422 unprocessable_input`. The call waits for the registry's RDAP server, so every snippet sets a 30-second client timeout.

```bash title="cURL"
curl https://api.qelka.com/v1/domain \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain": "cloudflare.com"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/domain', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ domain: 'cloudflare.com' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/domain",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"domain": "cloudflare.com"},
    timeout=30,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/domain');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['domain' => 'cloudflare.com']),
    CURLOPT_TIMEOUT => 30,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"domain": "cloudflare.com"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/domain", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/domain')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ domain: 'cloudflare.com' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 30) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Every valid domain name gets a `200`. Read `status` for the short answer and `rdap.status` to know whether `registration` is filled.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `domain`. |
| `input` | string | The `domain` you sent, without surrounding spaces. |
| `domain` | string | The registrable domain that was looked up, in ASCII. |
| `tld` | string | Its top-level domain, such as `com` or `uk`. |
| `status` | string | `registered`, `not_registered` or `unknown`. |
| `rdap` | object | What the registry's RDAP server answered. |
| `rdap.status` | string | `found`, `not_found`, `unsupported` or `error`. |
| `rdap.server` | string or null | The RDAP server the IANA bootstrap file names for the TLD. `null` when there is none, or when the bootstrap file could not be read. |
| `registration` | object or null | The registration record. `null` unless `rdap.status` is `found`. |
| `registration.created_at` | string or null | Registration date, ISO 8601 in UTC. |
| `registration.updated_at` | string or null | Date of the last change, ISO 8601 in UTC. |
| `registration.expires_at` | string or null | Expiration date, ISO 8601 in UTC. Some registries do not publish it. |
| `registration.age_days` | integer or null | Whole days between `created_at` and the lookup. |
| `registration.expires_in_days` | integer or null | Whole days until `expires_at`, negative once it has passed. |
| `registration.registrar` | object or null | The registrar that holds the domain. |
| `registration.registrar.name` | string or null | Registrar name. |
| `registration.registrar.iana_id` | string or null | IANA Registrar ID, for registrars accredited by ICANN. |
| `registration.statuses` | array of strings | RDAP status values, lower case. [RFC 8056](https://www.rfc-editor.org/rfc/rfc8056) maps them to EPP status codes: `client transfer prohibited` is `clientTransferProhibited`. |
| `registration.nameservers` | array of strings | The nameservers the registry delegates the domain to. |
| `registration.dnssec` | boolean or null | `true` when the registry says the delegation is signed with DNSSEC. |
| `dns` | object | DNS records of the domain itself. |
| `dns.status` | string | Status of the NS query: `NOERROR`, `NXDOMAIN`, `SERVFAIL`, `REFUSED` or `TIMEOUT`. |
| `dns.a` | array of strings | IPv4 addresses. |
| `dns.aaaa` | array of strings | IPv6 addresses. |
| `dns.mx` | array of objects | Mail exchangers, lowest priority first. |
| `dns.mx.priority` | integer | MX priority. |
| `dns.mx.exchange` | string | Mail server host. A null MX ([RFC 7505](https://www.rfc-editor.org/rfc/rfc7505)) appears as `.`. |
| `dns.ns` | array of strings | NS records as DNS answers them, lower case. |
| `dns.txt` | object | A summary of the TXT records. |
| `dns.txt.records` | integer | Number of TXT records at the domain. |
| `dns.txt.spf` | string or null | The SPF record, when there is exactly one. |
| `dns.txt.verifications` | array of strings | Services whose domain verification token is in TXT, such as `google` (`google-site-verification=`) or `microsoft` (`MS=`). The others recognized: `adobe`, `apple`, `atlassian`, `brave`, `cisco`, `docusign`, `dropbox`, `facebook`, `github`, `globalsign`, `hubspot`, `mail.ru`, `miro`, `onetrust`, `openai`, `slack`, `stripe`, `yandex` and `zoom`. |
| `email` | object | How the domain handles email. |
| `email.mx` | boolean | `true` when the domain has at least one MX record other than a null MX. |
| `email.null_mx` | boolean | `true` when the domain publishes a null MX: it accepts no email. |
| `email.provider` | string or null | Mail provider recognized from the MX hosts, as on [MX lookup](https://qelka.com/tools/mx-lookup). `null` when none is recognized. |
| `email.spf` | boolean | `true` when the domain publishes an SPF record. |
| `email.spf_all` | string or null | What the final `all` of the SPF record says: `fail` (`-all`), `softfail` (`~all`), `neutral` (`?all`) or `pass` (`+all`). `null` when there is no single SPF record or it has no `all`. |
| `email.dmarc` | boolean | `true` when a DMARC record is published at `_dmarc.{domain}`. |
| `email.dmarc_policy` | string or null | The DMARC policy: `none`, `quarantine` or `reject`. |
| `email.disposable` | boolean | `true` when the domain, or a parent of it, is on the [disposable email domain list](https://qelka.com/data-sources). |
| `credits_used` | integer | Credits debited for this call: 1 with a live key, `0` when `rdap.status` is `error` or with a test key. |
| `cached` | boolean | `true` when the answer came from the 24-hour cache. |

```json title="Response"
{
  "id": "lkp_01M875D1RE89KBPYC9QGDPVNSN",
  "object": "domain",
  "input": "cloudflare.com",
  "domain": "cloudflare.com",
  "tld": "com",
  "status": "registered",
  "rdap": { "status": "found", "server": "https://rdap.verisign.com/com/v1/" },
  "registration": {
    "created_at": "2009-02-17T22:07:54.000Z",
    "updated_at": "2024-01-09T16:45:28.000Z",
    "expires_at": "2033-02-17T22:07:54.000Z",
    "age_days": 6488,
    "expires_in_days": 2277,
    "registrar": { "name": "Cloudflare, Inc.", "iana_id": "1910" },
    "statuses": [
      "client delete prohibited",
      "client transfer prohibited",
      "client update prohibited",
      "server delete prohibited",
      "server transfer prohibited",
      "server update prohibited"
    ],
    "nameservers": ["ns3.cloudflare.com", "ns4.cloudflare.com", "ns5.cloudflare.com", "ns6.cloudflare.com", "ns7.cloudflare.com"],
    "dnssec": true
  },
  "dns": {
    "status": "NOERROR",
    "a": ["104.16.132.229", "104.16.133.229"],
    "aaaa": ["2606:4700::6810:84e5", "2606:4700::6810:85e5"],
    "mx": [
      { "priority": 5, "exchange": "mxa-canary.global.inbound.cf-emailsecurity.net" },
      { "priority": 5, "exchange": "mxb-canary.global.inbound.cf-emailsecurity.net" },
      { "priority": 10, "exchange": "mxa.global.inbound.cf-emailsecurity.net" },
      { "priority": 10, "exchange": "mxb.global.inbound.cf-emailsecurity.net" }
    ],
    "ns": ["ns3.cloudflare.com", "ns4.cloudflare.com", "ns5.cloudflare.com", "ns6.cloudflare.com", "ns7.cloudflare.com"],
    "txt": {
      "records": 29,
      "spf": "v=spf1 ip4:199.15.212.0/22 ip4:173.245.48.0/20 include:_spf.google.com include:spf1.mcsv.net include:spf.mandrillapp.com include:mail.zendesk.com include:stspg-customer.com include:_spf.salesforce.com -all",
      "verifications": ["apple", "atlassian", "cisco", "facebook", "google", "microsoft", "miro", "onetrust", "stripe"]
    }
  },
  "email": {
    "mx": true,
    "null_mx": false,
    "provider": null,
    "spf": true,
    "spf_all": "fail",
    "dmarc": true,
    "dmarc_policy": "reject",
    "disposable": false
  },
  "credits_used": 1,
  "cached": false
}
```

## Read the status

| `status` | What it means | What to do |
|---|---|---|
| `registered` | The registry has a record of the domain, or the domain is delegated in DNS (it has NS records). | Read age, expiry and registrar in `registration` when `rdap.status` is `found`. |
| `not_registered` | The registry's RDAP server answered that it has no record of the name, and DNS shows no delegation. | Do not treat it as a working domain. The name may be free to register, or reserved by the registry. |
| `unknown` | Neither RDAP nor DNS tells. | Look at `rdap.status`: on `error`, try again later. |

| `rdap.status` | What it means | Billed |
|---|---|---|
| `found` | The registry's RDAP server returned the domain, and `registration` is filled. | Yes |
| `not_found` | The RDAP server answered that the domain does not exist. | Yes |
| `unsupported` | The TLD has no RDAP server in the IANA bootstrap file, as for `.de`. `registration` is `null`; `dns` and `email` are filled as usual. | Yes |
| `error` | The RDAP server did not answer in time or answered with an error, or the bootstrap file could not be read. `registration` is `null`. | No |

An `error` answer is not cached: send the same request again later. Answers whose NS query got `SERVFAIL`, `REFUSED` or `TIMEOUT` are billed but not cached either, so the next request asks DNS again.

## How the lookup works

1. The host is taken from the input and reduced to its registrable domain, with a list of multi-label public suffixes such as `co.uk` and `com.au`.
2. The RDAP server of the TLD is read from the [IANA bootstrap file](https://data.iana.org/rdap/dns.json) ([RFC 9224](https://www.rfc-editor.org/rfc/rfc9224)), kept one day.
3. The domain is requested from that server (`GET {server}domain/{domain}`, [RFC 9082](https://www.rfc-editor.org/rfc/rfc9082)), and the events, entities, status, nameservers and secure DNS members of the answer ([RFC 9083](https://www.rfc-editor.org/rfc/rfc9083)) are read.
4. In parallel, A, AAAA, MX, NS and TXT records are resolved over DNS over HTTPS, the DMARC record is read at `_dmarc.{domain}`, and the domain is checked against the disposable list.

## What the API keeps

The response holds the registrar, never the registrant: registries redact registrant contacts in public RDAP answers, and the API does not ask for them. The request log keeps the registrable domain in clear, because it identifies an organization, not a person.

## Examples

### Look up the domain of an email address

Send the address as it is: the API keeps the host and reduces it to the registrable domain. Test keys return a sample registration for any valid domain, without calling RDAP or DNS. With a test key in `QELKA_API_KEY`, this request returns:

```bash title="cURL"
curl https://api.qelka.com/v1/domain \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain": "jane@shop.example.co.uk"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/domain', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ domain: 'jane@shop.example.co.uk' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/domain",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"domain": "jane@shop.example.co.uk"},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8714KE3VGXNBG6S8NNTN89W",
  "object": "domain",
  "input": "jane@shop.example.co.uk",
  "domain": "example.co.uk",
  "tld": "uk",
  "status": "registered",
  "rdap": { "status": "found", "server": "https://rdap.example.test/" },
  "registration": {
    "created_at": "2010-01-01T00:00:00.000Z",
    "updated_at": "2026-01-01T00:00:00.000Z",
    "expires_at": "2030-01-01T00:00:00.000Z",
    "age_days": 6000,
    "expires_in_days": 1000,
    "registrar": { "name": "Example Registrar, Inc.", "iana_id": "9999" },
    "statuses": ["client transfer prohibited"],
    "nameservers": ["ns1.example.co.uk", "ns2.example.co.uk"],
    "dnssec": false
  },
  "dns": {
    "status": "NOERROR",
    "a": ["192.0.2.10"],
    "aaaa": ["2001:db8::10"],
    "mx": [{ "priority": 10, "exchange": "mx.example.co.uk" }],
    "ns": ["ns1.example.co.uk", "ns2.example.co.uk"],
    "txt": { "records": 2, "spf": "v=spf1 -all", "verifications": ["google"] }
  },
  "email": {
    "mx": true,
    "null_mx": false,
    "provider": null,
    "spf": true,
    "spf_all": "fail",
    "dmarc": true,
    "dmarc_policy": "reject",
    "disposable": false
  },
  "credits_used": 0,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | `domain` is missing, empty or longer than 320 characters, the body is not a JSON object, or it has a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 1 credit (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 422 | [unprocessable_input](https://qelka.com/docs/errors#unprocessable_input) | The input is not a domain name, a URL or an email address with a valid domain, such as `localhost` or a string with spaces |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |

No error is billed. When the registry does not answer, the API does not return an error: it answers `200` with `rdap.status: "error"` and `credits_used: 0`.

## Related

- [Domain intelligence API](https://qelka.com/products/domain-intelligence)
- Free tools: [domain age checker](https://qelka.com/tools/domain-age-checker), [MX lookup](https://qelka.com/tools/mx-lookup), [SPF checker](https://qelka.com/tools/spf-checker), [DMARC checker](https://qelka.com/tools/dmarc-checker)
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 domains in one call, each item with `type: "domain"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole column of domains, URLs or email addresses with `type=domain`
- [Caching](https://qelka.com/docs/caching), [Errors](https://qelka.com/docs/errors), [Test mode](https://qelka.com/docs/test-mode)
