Aptos Names

K
Account

Getting an API Key

To use API v3, you'll need an API key from Geomi. API keys are free and provide access to the Aptos Names API with improved rate limits and reliability.

Why Do I Need an API Key?

API keys allow us to:

  • Provide better rate limits and reliability
  • Monitor API usage to improve service quality
  • Offer enhanced support
  • Ensure sustainable API access for all users

How to Get Your API Key

For comprehensive information about API keys, including key types, client usage, and best practices, see the Geomi API Keys documentation.

Step 1: Visit Geomi

Navigate to Geomi to get started.

Step 2: Sign Up or Log In

Create a new account or log in to your existing Geomi account.

Step 3: Generate an API Key

  1. Navigate to the API Keys section in your Geomi dashboard
  2. Click "Create New API Key"
  3. Give your API key a descriptive name (e.g., "Production App" or "Development")

Step 4: Store Your API Key Securely

Important: Treat your API key like a password. Never commit it to version control or share it publicly.

Recommended: Environment Variables

Store your API key in an environment variable:

# .env (add to .gitignore)
APTOS_NAMES_API_KEY=your_api_key_here

Using in Your Code

export function getApiKeyFromEnvironment() {
  const API_KEY = process.env.APTOS_NAMES_API_KEY;

  if (!API_KEY) {
    throw new Error("APTOS_NAMES_API_KEY environment variable is required");
  }

  return API_KEY;
}

Using Your API Key

Include your API key in the X-API-Key header for all API v3 requests:

curl -H "X-API-Key: YOUR_API_KEY" \
  https://www.aptosnames.com/api/mainnet/v3/address/test
export async function fetchWithApiKey(name: string) {
  const API_KEY = process.env.APTOS_NAMES_API_KEY;

  if (!API_KEY) {
    throw new Error("APTOS_NAMES_API_KEY environment variable is required");
  }

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

  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }

  return response.json();
}