There are more AWS SDK examples available in the AWS Doc SDK Examples
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; }
-
For API details, see GetDomainSuggestions in AWS SDK for .NET API Reference.
-
- 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 nameexample.com
. The response includes only domain names that are available. This command runs only in theus-east-1
Region. If your default region is set tous-east-1
, you can omit theregion
parameter.aws route53domains get-domain-suggestions \ --region
us-east-1
\ --domain-nameexample.com
\ --suggestion-count10
\ --only-availableOutput:
{ "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" } ] }
-
For API details, see GetDomainSuggestions
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 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); } }
-
For API details, see GetDomainSuggestions 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 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(" ") } } }
-
For API details, see GetDomainSuggestions
in AWS SDK for Kotlin API reference.
-