1

I was wondering if there was a way to get the metadata for NFT tokens minted through the Metaplex standard? I was able to find the data for Solana fungible tokens using the code listed below and I want to find the same kind of data but just for Metaplex NFTs.

import { TokenListProvider } from '@solana/spl-token-registry';

function App() {
new TokenListProvider().resolve().then((tokens) => {
  const tokenList = tokens.filterByClusterSlug('mainnet-beta').getList();
  console.log(tokenList);
})
};

export default App;

2 Answers 2

2

Yep you can use the Helius API to get all token metadata! See the docs for nft metadata. You can get an API key here

Some example code for how to do this

const axios = require('axios')

const url = "https://api.helius.xyz/v0/tokens/metadata?api-key=<your-key>"
const nftAddresses = [
  "BAAzgRGWY2v5AJBNZNFd2abiRXAUo56UxywKEjoCZW2",
  "8s6kQUZfdm7GSaThAcsmSs56wMinXrbk6SdNVngutrz5"
] // Monkes
const getMetadata = async () => {
  const { data } = await axios.post(url, { mintAccounts: nftAddresses})
  console.log("metadata: ", data)
}
getMetadata()
1

Use the findByMint method from the Metaplex SDK: https://github.com/metaplex-foundation/js#findByMint enter image description here

2
  • this looks like it'll work. Do I need to have a public key? Or can I just leave that string open to get all of them?
    – Gamma1
    Commented Aug 26, 2022 at 2:38
  • take a look at findAllByMintList if you're trying to fetch in bulk. github.com/metaplex-foundation/js#findAllByMintList
    – john
    Commented Aug 26, 2022 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.