Use GetDomainSuggestions with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use GetDomainSuggestions with an AWS SDK or CLI

The following code examples show how to use GetDomainSuggestions.

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> /// Get a list of suggestions for a given domain. /// </summary> /// <param name="domain">The domain to check for suggestions.</param> /// <param name="onlyAvailable">If true, only returns available domains.</param> /// <param name="suggestionCount">The number of suggestions to return. Defaults to the max of 50.</param> /// <returns>A collection of domain suggestions.</returns> public async Task<List<DomainSuggestion>> GetDomainSuggestions(string domain, bool onlyAvailable, int suggestionCount = 50) { var result = await _amazonRoute53Domains.GetDomainSuggestionsAsync( new GetDomainSuggestionsRequest { DomainName = domain, OnlyAvailable = onlyAvailable, SuggestionCount = suggestionCount } ); return result.SuggestionsList; }
CLI
AWS CLI

To get a list of suggested domain names

The following get-domain-suggestions command displays a list of suggested domain names based on the domain name example.com. The response includes only domain names that are available. 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 get-domain-suggestions \ --region us-east-1 \ --domain-name example.com \ --suggestion-count 10 \ --only-available

Output:

{ "SuggestionsList": [ { "DomainName": "egzaampal.com", "Availability": "AVAILABLE" }, { "DomainName": "examplelaw.com", "Availability": "AVAILABLE" }, { "DomainName": "examplehouse.net", "Availability": "AVAILABLE" }, { "DomainName": "homeexample.net", "Availability": "AVAILABLE" }, { "DomainName": "examplelist.com", "Availability": "AVAILABLE" }, { "DomainName": "examplenews.net", "Availability": "AVAILABLE" }, { "DomainName": "officeexample.com", "Availability": "AVAILABLE" }, { "DomainName": "exampleworld.com", "Availability": "AVAILABLE" }, { "DomainName": "exampleart.com", "Availability": "AVAILABLE" } ] }
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 listDomainSuggestions(Route53DomainsClient route53DomainsClient, String domainSuggestion) { try { GetDomainSuggestionsRequest suggestionsRequest = GetDomainSuggestionsRequest.builder() .domainName(domainSuggestion) .suggestionCount(5) .onlyAvailable(true) .build(); GetDomainSuggestionsResponse response = route53DomainsClient.getDomainSuggestions(suggestionsRequest); List<DomainSuggestion> suggestions = response.suggestionsList(); for (DomainSuggestion suggestion : suggestions) { System.out.println("Suggestion Name: " + suggestion.domainName()); System.out.println("Availability: " + suggestion.availability()); System.out.println(" "); } } 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 AWS Code Examples Repository.

suspend fun listDomainSuggestions(domainSuggestion: String?) { val suggestionsRequest = GetDomainSuggestionsRequest { domainName = domainSuggestion suggestionCount = 5 onlyAvailable = true } Route53DomainsClient { region = "us-east-1" }.use { route53DomainsClient -> val response = route53DomainsClient.getDomainSuggestions(suggestionsRequest) response.suggestionsList?.forEach { suggestion -> println("Suggestion Name: ${suggestion.domainName}") println("Availability: ${suggestion.availability}") println(" ") } } }