Aptos Names

K
Account

Convert Name to Address

Learn how to retrieve an address for a name using the REST API.

Example

Using CURL

curl -H "X-API-Key: YOUR_API_KEY" \
  https://www.aptosnames.com/api/mainnet/v3/address/test

Using JavaScript

export async function convertNameToAddress() {
  // Replace "test" with your ANS name.
  const name = "test";

  // Replace "mainnet" or "testnet" with your desired network
  const network = "mainnet";

  // Replace "YOUR_API_KEY" with your actual API key
  const apiKey = "YOUR_API_KEY";

  const response = await fetch(`https://www.aptosnames.com/api/${network}/v3/address/${name}`, {
    headers: {
      "X-API-Key": apiKey,
    },
  });

  const { address } = await response.json();

  return address;
}