How get all the NFTs in a collection in Solana?

Viewed 2576

Hello to fetch all the NFTs in a collection using the symbol of the collection. Is any API available that provides the data?

1 Answers

Here's a simplest example by using Mataplex.JS

import { Metadata } from "@metaplex-foundation/mpl-token-metadata";
import { Connection } from "@solana/web3.js";

const connectionMetaplex = new Connection(
"https://api.metaplex.solana.com",
"confirmed"
);
const walletAddress = "6vRx1iVZo3xfrBHdpvuwArL2jucVj9j9nLpd2VUTTGMG"
const nftsmetadata = await Metadata.findDataByOwner(connectionMetaplex, walletAddress);
console.log(nftsmetadata);
  "dependencies": {
    "@metaplex-foundation/mpl-core": "^0.0.5",
    "@metaplex-foundation/mpl-token-metadata": "^1.2.5",
    "@project-serum/anchor": "^0.22.1",
    "@solana/buffer-layout": "^4.0.0",
    "@solana/spl-token": "^0.2.0",
    "@solana/web3.js": "^1.36.0"
  }
Related