Use ListDomains 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 ListDomains with an Amazon SDK or CLI

The following code examples show how to use ListDomains.

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> /// List the domains for the account. /// </summary> /// <returns>A collection of domain summary records.</returns> public async Task<List<DomainSummary>> ListDomains() { var results = new List<DomainSummary>(); var paginateDomains = _amazonRoute53Domains.Paginators.ListDomains( new ListDomainsRequest()); // Get the entire list using the paginator. await foreach (var domain in paginateDomains.Domains) { results.Add(domain); } return results; }
  • For API details, see ListDomains in Amazon SDK for .NET API Reference.

CLI
Amazon CLI

To list the domains that are registered with the current Amazon account

The following list-domains command lists summary information about the domains that are registered with the current Amazon account.

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 list-domains --region us-east-1

Output:

{ "Domains": [ { "DomainName": "example.com", "AutoRenew": true, "TransferLock": true, "Expiry": 1602712345.0 }, { "DomainName": "example.net", "AutoRenew": true, "TransferLock": true, "Expiry": 1602723456.0 }, { "DomainName": "example.org", "AutoRenew": true, "TransferLock": true, "Expiry": 1602734567.0 } ] }
  • For API details, see ListDomains in Amazon 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 Amazon Code Examples Repository.

public static void listDomains(Route53DomainsClient route53DomainsClient) { try { ListDomainsIterable listRes = route53DomainsClient.listDomainsPaginator(); listRes.stream() .flatMap(r -> r.domains().stream()) .forEach(content -> System.out.println("The domain name is " + content.domainName())); } catch (Route53Exception e) { System.err.println(e.getMessage()); System.exit(1); } }
  • For API details, see ListDomains in Amazon 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 Amazon Code Examples Repository.

suspend fun listDomains() { Route53DomainsClient { region = "us-east-1" }.use { route53DomainsClient -> route53DomainsClient .listDomainsPaginated(ListDomainsRequest {}) .transform { it.domains?.forEach { obj -> emit(obj) } } .collect { content -> println("The domain name is ${content.domainName}") } } }
  • For API details, see ListDomains in Amazon SDK for Kotlin API reference.

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.