There are more AWS SDK examples available in the AWS Doc SDK Examples
Use CheckDomainAvailability
with an AWS 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
-
- AWS SDK for .NET
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS 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; }
-
For API details, see CheckDomainAvailability in AWS SDK for .NET API Reference.
-
- CLI
-
- AWS 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 nameexample.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 tous-east-1
, you can omit theregion
parameter.aws route53domains check-domain-availability \ --region
us-east-1
\ --domain-nameexample.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.
-
For API details, see CheckDomainAvailability
in AWS CLI Command Reference.
-
- 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 AWS 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); } }
-
For API details, see CheckDomainAvailability in AWS SDK for Java 2.x API Reference.
-
- Kotlin
-
- SDK for Kotlin
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS 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 API details, see CheckDomainAvailability
in AWS SDK for Kotlin API reference.
-