> For the complete documentation index, see [llms.txt](https://docs.ainetwork.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ainetwork.ai/ai-agents/developer-reference/ainft-tutorial/search-and-retrieve-ainft.md).

# Search and Retrieve AINFT

This tutorial describe how to retrieve AINFTs by id, name, symbol and userAddress.

### Retrieve AINFTs

You can retrieve AINFTs using `geAinftsByAccount` or `getAinftsByAinftObject` .

```jsx
ainftJs.nft.getAinftsByAccount(userAddress)
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	})
```

```jsx
ainftJs.nft.getAinftsByAinftObject(ainftObjectId)
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	})
```

### Search Ainft object and AINFTs

Also, you can search ainft objects or AINFTs. Search options are below.

* ainftObjectId - The ID of Ainft object
* name - The name of Ainft object
* symbol - The symbol of Ainft object
* tokenId - Token ID of AINFT
* userAddress - Address of AINFT owner

```jsx
ainftJs.nft.searchAinftObjects({ ainftObjectId })
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	});
```

```jsx
ainftJs.nft.searchNfts({ ainftObjectId })
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	});
```

#### Response

```jsx
// Return Type
{
	nfts: Array<{
		owner: string,
		tokenId: string,
		tokenURI: string,
		ainftObject: {
			id: string,
			name: string,
			symbol: string,
			owner: string,
		}
		metadata: object,
	}>,
	isFinal: boolean,
	cursor: string,
}

{
	ainftObjects: Array<{
		id: string,
		name: string,
		symbol: string,
		owner: string,
	}>,
	isFinal: boolean,
	cursor: string,
}
```

### Limit

Search function retrieves 20 items by default. If you want to set number of result items, you can use limit option. Maximum limit value is 100.

```jsx
const ainftObjects = await ainftJs.nft.searchAinftObjects({ limit: 5 })
```

then, you can retrieve more with using cursor.

```jsx
const nextAinftObjects = await ainftJs.nft.searchAinftObjects({ limit: 5, cursor: '0x460e3BC2E6D98Bc2b434DE4854Bf4a08E63eb3A2' });
```

The cursor value is included in result of search. If you search nfts, usage is the same.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ainetwork.ai/ai-agents/developer-reference/ainft-tutorial/search-and-retrieve-ainft.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
