> For the complete documentation index, see [llms.txt](https://docs.chiliz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chiliz.com/th/phatthana/phuenthan/how-tos/metadata-nft.md).

# ดู Metadata ของ NFT

ดึงข้อมูล metadata ของ NFT (URL รูปภาพ ชื่อ คุณสมบัติ) สำหรับ token เฉพาะบน Chiliz Chain โดยใช้ Moralis NFT API

## metadata ของ NFT คืออะไร?

metadata ของ NFT คือชุดข้อมูลเชิงพรรณนาที่จัดเก็บไว้นอก blockchain ซึ่งระบุรายละเอียดคุณสมบัติ คุณลักษณะ และเนื้อหาเพิ่มเติมที่เกี่ยวข้องกับ NFT นั้น ๆ ข้อมูลเหล่านี้อาจได้แก่ URL ของรูปภาพ ชื่อ คำอธิบาย และคุณสมบัติที่เกี่ยวข้องกับความเป็นเอกลักษณ์และความเป็นเจ้าของ

## วิธีใช้งานกับ Moralis

Moralis มี NFT API ที่คุณสามารถนำมาใช้ได้ และยังมีตัวอย่างโค้ดสำหรับกรณีการใช้งานประวัติ wallet อีกด้วย:

* [Get NFT metadata](https://docs.moralis.io/web3-data-api/evm/reference/get-nft-metadata?address=0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB\&token_id=1\&chain=eth\&format=decimal\&normalizeMetadata=true\&media_items=false)

เพื่อปรับตัวอย่างโค้ดของ Moralis ให้เหมาะสม ให้แทนที่การอ้างอิง Ethereum ด้วย ID สำหรับ Chiliz Chain คือ `0x15b38`:

```typescript
import Moralis from 'moralis';

try {
  await Moralis.start({
    apiKey: "YOUR_API_KEY"
  });

  const response = await Moralis.EvmApi.nft.getNFTMetadata({
    "chain": "0x15b38", // This is for Chiliz Chain Mainnet.
                        // For Spicy Testnet, use "0x15b32".
    "format": "decimal",
    "normalizeMetadata": true,
    "mediaItems": false,
    "address": "0xYourNFTContractAddress",
    "tokenId": "1"
  });

  console.log(response.raw);
} catch (e) {
  console.error(e);
}
```

## วิธีใช้งานกับ Tatum

Tatum มี submodule สำหรับ NFT ในเครื่องมือ blockchain abstraction ที่คุณสามารถนำมาใช้ได้ และยังมีตัวอย่างโค้ดสำหรับกรณีการดึง metadata อีกด้วย:

* [Get the metadata of a specific NFT](https://docs.tatum.io/docs/get-the-metadata-of-a-specific-nft)

เพื่อปรับตัวอย่างโค้ดของ Tatum ให้เหมาะสม ให้แทนที่การอ้างอิง Ethereum ด้วย Chiliz Chain:

```typescript
import {TatumSDK, Network, Chiliz, ResponseDto, NftTokenDetail} from '@tatumio/tatum'

const tatum = await TatumSDK.init<Chiliz>({network: Network.CHILIZ})

const metadata: ResponseDto<NftTokenDetail|null> = await tatum.nft.getNftMetadata({
  tokenAddress: '0xYourNFTContractAddress', // replace with your collection
  tokenId: '1'
})

console.log(metadata.data)
```

## วิธีใช้งานกับ thirdweb

สำหรับ thirdweb คุณสามารถนำแรงบันดาลใจจากโค้ดต้นฉบับที่โฮสต์บนเว็บไซต์เอกสารของพวกเขา:

* [ThirdwebNftMedia](https://portal.thirdweb.com/react/v4/components/ThirdwebNftMedia#usage)

ต่อไปนี้คือวิธีที่เราสามารถปรับโค้ดนั้นเพื่อดึง metadata:

```typescript
const { ThirdwebSDK } = require("@thirdweb-dev/sdk");

const sdk = new ThirdwebSDK("https://rpc.ankr.com/chiliz");
const nftContractAddress = "0xYourNFTContractAddress";
const tokenId = "YourTokenID";

async function getNFTMetadata() {
  try {
    const nftContract = await sdk.getNFTCollection(nftContractAddress);
    const nftMetadata = await nftContract.get(tokenId);
    console.log(`Metadata of NFT ${tokenId}:`, nftMetadata);
  } catch (error) {
    console.error("Error fetching NFT metadata:", error);
  }
}

getNFTMetadata();
```

## วิธีใช้งานกับ Nodit

Nodit มีตัวอย่างโค้ดดังต่อไปนี้ [ในเอกสารของพวกเขา](https://developer.nodit.io/reference/chiliz-getnftmetadatabytokenids):

```typescript
const url = 'https://web3.nodit.io/v1/chiliz/mainnet/nft/getNftMetadataByTokenIds';
const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    'X-API-KEY': 'nodit-demo'
  },
  body: JSON.stringify({
    tokens: [
      {contractAddress: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', tokenId: '1'},
      {contractAddress: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', tokenId: '2'}
    ]
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chiliz.com/th/phatthana/phuenthan/how-tos/metadata-nft.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
