# Direct Lookup

Lookup domain information directly based on the human readable domain name.&#x20;

In order to get the information of a domain name you need to:

1. Get the domain name public key
2. Retrieve the account info

```typescript
import { getDomainKeySync, NameRegistryState } from "@bonfida/spl-name-service";
const domainName = "bonfida"; // With or without the .sol at the end

// Step 1
const { pubkey } = getDomainKeySync(domainName);

// Step 2
// The registry object contains all the info about the domain name
// The NFT owner is of type PublicKey | undefined
const { registry, nftOwner } = await NameRegistryState.retrieve(
  connection,
  pubkey
);

// Subdomain derivation
const subDomain = "dex.bonfida"; // With or without the .sol at the end
const { pubkey: subKey } = getDomainKeySync(subDomain);

// Record derivation (e.g IPFS record)
const record = "IPFS.bonfida"; // With or without the .sol at the end
const { pubkey: recordKey } = getDomainKeySync(record, true);

```

The `retrieve` method returns an object made of two fields:

* `registry` is of type `NameRegistryState`
* `nftOwner` is of type `PublicKey | undefined`
  * When `nftOwner` is of type `PublicKey` it means that the domain is tokenized and the current NFT holder is `nftOwner`. When a domain is tokenized `registry.owner` is an escrow account that is program owner. Funds should be sent to `nftOwner`
  * When `nftOwner` is of type `undefined` it means that the domain is not tokenized and funds should be sent to `registry.owner`

`NameRegistryState.retrieveBatch` can be used to retrieve multiple name registries at once. Pass the connection, and an array of domain name public keys as arguments to the function.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sns.id/dev/sns-sdk/images-and-media/direct-lookup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
