Use CheckDomainAvailability with an Amazon SDK or CLI - Amazon Route 53
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use CheckDomainAvailability with an Amazon SDK or CLI

The following code examples show how to use CheckDomainAvailability.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

.NET
Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <summary> /// Check the availability of a domain name. /// </summary> /// <param name="domain">The domain to check for availability.</param> /// <returns>An availability result string.</returns> public async Task<string> CheckDomainAvailability(string domain) { var result = await _amazonRoute53Domains.CheckDomainAvailabilityAsync( new CheckDomainAvailabilityRequest { DomainName = domain } ); return result.Availability.Value; }
CLI
Amazon CLI

To determine whether you can register a domain name with Route 53

The following check-domain-availability command returns information about whether the domain name example.com is available to be registered using Route 53.

This command runs only in the us-east-1 Region. If your default region is set to us-east-1, you can omit the region parameter.

aws route53domains check-domain-availability \ --region us-east-1 \ --domain-name example.com

Output:

{ "Availability": "UNAVAILABLE" }

Route 53 supports a large number of top-level domains (TLDs), such as .com and .jp, but we don't support all available TLDs. If you check the availability of a domain and Route 53 doesn't support the TLD, check-domain-availability returns the following message.

An error occurred (UnsupportedTLD) when calling the CheckDomainAvailability operation: <top-level domain> tld is not supported.

For a list of the TLDs that you can use when registering a domain with Route 53, see Domains That You Can Register with Amazon Route 53 in the Amazon Route 53 Developer Guide. For more information about registering domains with Amazon Route 53, see Registering a New Domain in the Amazon Route 53 Developer Guide.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

public static void checkDomainAvailability(Route53DomainsClient route53DomainsClient, String domainSuggestion) { try { CheckDomainAvailabilityRequest availabilityRequest = CheckDomainAvailabilityRequest.builder() .domainName(domainSuggestion) .build(); CheckDomainAvailabilityResponse response = route53DomainsClient .checkDomainAvailability(availabilityRequest); System.out.println(domainSuggestion + " is " + response.availability().toString()); } catch (Route53Exception e) { System.err.println(e.getMessage()); System.exit(1); } }
Kotlin
SDK for Kotlin
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

suspend fun checkDomainAvailability(domainSuggestion: String) { val availabilityRequest = CheckDomainAvailabilityRequest { domainName = domainSuggestion } Route53DomainsClient { region = "us-east-1" }.use { route53DomainsClient -> val response = route53DomainsClient.checkDomainAvailability(availabilityRequest) println("$domainSuggestion is ${response.availability}") } }

For a complete list of Amazon SDK developer guides and code examples, see Using Route 53 with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.