Skip to content

Build a domain availability form

Check an exact domain name and show available, taken, or unknown without treating a failed lookup as availability.

Working example

ParseAPI
Node

Set up ParseAPI

Set PARSEAPI_KEY in your server environment. Use Node.js 22 or later.

Terminal
export PARSEAPI_KEY='YOUR_SECRET_API_KEY'
Get an API key ↗

Check the name someone wants to use

Add a domain field to a project or website setup flow. Send the exact name to ParseAPI from your server, then show its registration state beside the field.

The result has three states: available, taken, and unknown. Registration availability does not establish purchase eligibility, a price, or a reservation. A person still needs to confirm those details when purchasing.

1. Collect the exact domain name

Give the form a single named input:

JavaScript
const form = `<form method="post" action="/">
  <label for="domain">Domain name</label>
  <input id="domain" name="domain" type="text" maxlength="253" required
    autocomplete="off" autocapitalize="none" spellcheck="false"
    placeholder="example.com" value="${escape(fields.domain ?? '')}"
    aria-describedby="domain-help">
  <p id="domain-help" class="note">Enter an exact domain, without https:// or a path.</p>
  <button type="submit">Check domain</button>
</form>`;

Accept a hostname such as example.com, rather than a URL or email address. The server trims it, normalizes internationalized names to ASCII, and removes a trailing dot. It preserves the actual name: shop.example.com is not silently rewritten to example.com.

Keep the secret PARSEAPI_KEY on the server. The complete example uses Node's built-in fetch with X-API-Version: 2.3.0 and no SDK dependency. The local app uses Node's HTTP server, so the browser only submits the form to the app.

2. Ask Domain about registration

The download's small HTTP client sends GET /domain/{domain} with the normalized name:

JavaScript
const domain = await parse.domain(name, { signal });

The response returns domain and available. Check that domain matches the requested name before rendering the result.

This is a registration lookup. DNS records, an HTTP response, or an absent website do not establish that a domain can be registered. No DNS shortcut or extra lookup is needed here.

3. Keep all three availability states

Branch on the boolean or null explicitly:

JavaScript
const state = domain.available === true ? 'available'
  : domain.available === false ? 'taken' : 'unknown';

true reports an unregistered name, false reports a registered name, and null means availability could not be established. A registry name outside supported coverage can remain unknown. Do not use !domain.available, which would merge unknown with a known negative.

A failed HTTP request or malformed response also leaves availability unknown. The app makes one attempt per submission with a 10-second timeout and offers a retry rather than silently repeating it.

4. Return the result to the setup flow

Render the exact checked name with a useful next step:

JavaScript
const title = { available: 'Available', taken: 'Taken', unknown: 'Availability unknown' }[result.state];
const explanation = {
  available: 'The registration lookup reports this exact name as unregistered. '
    + 'Confirm eligibility, price, and availability with your registrar before buying.',
  taken: 'This exact name is registered. Try another name.',
  unknown: 'The registration lookup could not establish availability. Try again later.'
}[result.state];
return `<section class="result"><h2>${title}</h2>
  <p>${escape(result.name)}</p><p>${explanation}</p></section>`;

In your application, keep the chosen name in the project setup draft and recheck before any existing purchase flow. This example neither purchases nor reserves a domain. Editing the name immediately clears the old result and cancels an in-flight request, so a late response cannot mark the new name available.

The Domain reference explains registration behavior and additional registration details.

Complete example

Use the complete implementation as a reference when adding this feature to your app. It includes the validation and failure handling around the calls above.

View and copy the complete source
Try the complete example on your computer

After completing the setup above, save the source in your application folder and start the app:

Terminal
node domain-search-form.node.mjs

Open 127.0.0.1:8000 to use the form. The server keeps your secret key out of the page.

For every field and parameter, see Domain API reference.