> ## Documentation Index
> Fetch the complete documentation index at: https://docs.namespace.ninja/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch L2 Subnames

> Fetch a single or multiple L2 subnames.

Indexer has methods for fetching single or multiple L2 subnames.

## 1. **getL2Subname**

The `getL2Subname` method retrieves a single subname registered on an L2 chain.

### Usage

<CodeGroup>
  ```typescript ENS Name theme={null}
  const response = await indexer.getL2Subname({
    chainId: 10,
    nameOrNamehash: "lucas.oppunk.eth",
  });
  ```

  ```typescript Namehash theme={null}
  const response = await indexer.getL2Subname({
    chainId: 10,
    nameOrNamehash: "0x15219d7dc9f1a66f9281d1436a646ed2b4d5e96dcf62db66bffeedd2155c74c0", // namehash for lucas.oppunk.eth
  });
  ```
</CodeGroup>

* `chainId`: The id of the target L2 network (e.g., `base(8453)`, `optimism(10)`, `baseSepolia(84532)`)
* `nameOrNamehash`: Name or namehash representation of an ENS name

### Return Type

```typescript theme={null}
export interface L2SubnameResponse {
  name: string;
  namehash: string;
  label: string;
  parentNamehash: string;
  owner: string;
  texts: Record<string, string>;
  addresses: Record<string, string>;
  contenthash?: string;
  chainId: number;
  expiry: number;
  mintTransaction?: {
    price: number;
    paymentReceiver: string;
  };
}
```

### Field Description

| Field             | Description                                                                           |
| ----------------- | ------------------------------------------------------------------------------------- |
| `name`            | Full subname (e.g., `alice.oppunk.eth`)                                               |
| `namehash`        | ENS-compatible namehash of the subname                                                |
| `label`           | The label (left-most part) of the subname (e.g., `alice`)                             |
| `parentNamehash`  | Namehash of the parent domain (e.g., `oppunk.eth`)                                    |
| `owner`           | Ethereum address of the current owner                                                 |
| `texts`           | Map of text records associated with the subname                                       |
| `addresses`       | Map of address records (coin type → address)                                          |
| `contenthash`     | Content hash (e.g., IPFS, Arweave link)                                               |
| `chainId`         | Chain ID where the subname is registered (e.g., `8453` for Base, `10` for Optimism)   |
| `expiry`          | Unix timestamp indicating when the subname will expire (0 for non-expirable subnames) |
| `mintTransaction` | Object describing the minting transaction                                             |
| `price`           | Minting price in ETH                                                                  |
| `paymentReceiver` | Ethereum address that received the mint payment (e.g., `0x1234...abcd`)               |

## 2. **getL2Subnames**

The `getL2Subnames` method allows you to retrieve a paginated list of Layer 2 (L2) subnames based on various filter criteria.

### Usage

<CodeGroup>
  ```typescript Fetch subnames by owner theme={null}
  // Fetch first page of subnames by owner
  const byOwner = await indexer.getL2Subnames({
    owner: "0x123400000000000000000000000000000000abcd",
    chainId: 10,
    page: 0,
    size: 10,
  });
  ```

  ```typescript Search by name substring theme={null}
  // Search by name substring
  const search = await indexer.getL2Subnames({
    stringSearch: "hello",
    chainId: 8453,
    page: 0,
    size: 5,
  });
  ```

  ```typescript Filter by parent domain theme={null}
  // Filter by parent domain
  const underParent = await indexer.getL2Subnames({
    parent: "artii.eth",
    chainId: 8453,
    page: 0,
    size: 5,
  });
  ```
</CodeGroup>

### Query Parameters

```typescript theme={null}
export interface GetL2SubnamesQuery {
  owner?: string;
  chainId?: number;
  page?: number;
  size?: number;
  parent?: string;
  isTestnet?: boolean;
  stringSearch?: string;
}
```

### Return Type

<CodeGroup>
  ```typescript L2SubnamePagedResponse theme={null}
  export interface L2SubnamePagedResponse {
    items: L2SubnameResponse[];
    total: number;
    page: number;
    size: number;
  }
  ```

  ```typescript L2SubnameResponse theme={null}
  export interface L2SubnameResponse {
    name: string;
    namehash: string;
    label: string;
    parentNamehash: string;
    owner: string;
    texts: Record<string, string>;
    addresses: Record<string, string>;
    contenthash?: string;
    chainId: number;
    expiry: number;
    mintTransaction?: {
      price: number;
      paymentReceiver: string;
    };
  }
  ```
</CodeGroup>
