Convert Address to Primary Name
Learn how to retrieve the primary name for an address using the REST API.
Example
Using CURL
curl -H "X-API-Key: YOUR_API_KEY" \
https://www.aptosnames.com/api/mainnet/v3/primary-name/0x1234...abcdef
Using JavaScript
export async function convertAddressToPrimaryName() {
// Replace "0x1234...abcdef" with the address you want to lookup.
const address = "0x1234...abcdef";
// 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/primary-name/${address}`,
{
headers: {
"X-API-Key": apiKey,
},
},
);
const { name } = await response.json();
return name;
}