Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
How do you get data about NFTs of an address using an API?

How do you get data about a user's NFTs using an API? Specifically, I want to get NFT metadata with values. For example: If there is a defined NFT, the user gets additional functionality in the service.

  
  
Posted one year ago
Edited one year ago
Votes Newest

Answers


First, pick an endpoint for the http-api. There are many places you can get this:
https://ton.org/docs/develop/dapps/apis/

Then, you can query the specific API of the NFT's metadata in accordance to the TEP-0062 standard:
https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md#get-methods-1

From your question, I'm assuming you want to do this on the web. To do this, the TONWeb SDK has some options for you.

const NftCollection = TonWeb.token.nft.NftCollection;
const NftItem = TonWeb.token.nft.NftItem;
const nftCollection = new NftCollection(provider, {
     ownerAddress: walletAddress,
     nftItemCodeHex: NftItem.codeHex
})
const nftCollectionAddress = await nftCollection.getAddress()
const getNftCollectionInfo = async () => {
     const data = await nftCollection.getCollectionData()
     console.log(data)
}

Here's the testing script for NFTs in the TonWeb package:
https://github.com/toncenter/tonweb/blob/master/src/test-nft.js

1
1
Posted one year ago
Jeremy
404 × 5 Administrator
  
  

Hi, thanks, but shouldn't it be: tonweb.provider instead of just provider? Since it gives "provider not defined".

const nftCollection = new NftCollection(tonweb.provider, { ownerAddress: walletAddress, nftItemCodeHex: NftItem.codeHex })

Also, this const nftCollectionAddress = await nftCollection.getAddress(); gives this TypeError: Cannot read properties of undefined (reading 'length') why so?

Lemmy   2 months ago Report