1

Sign up for a Free Helius Account

Head over to the Helius Dashboard and create your free account.

2

Grab Your API Key

Go to the API Keys section of your dashboard and copy your key.

3

Make Your First API Call

Paste your API key into the input field and click the button to fetch a random NFT from the owner address 86xCn…o2MMY using the getAssetsByOwner method.

4

Success!

Success! You’ve fetched a random NFT owned by the address 86xCn…o2MMY which is the wallet address of Anatoly Yakovenko, one of the founders of Solana.

Now let’s do it using code

We’ll use Node.js for this example. If you don’t have it yet, you can download it here.

1

Create a new file

touch fetchRandomNFT.js
2

Copy the following code into the file

fetchRandomNFT.js
async function fetchRandomNFT() {
  const response = await fetch(`https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: '1',
      method: 'getAssetsByOwner',
      params: {
        ownerAddress: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY'
      },
    }),
  })

  const data = await response.json()

  if (data.error) {
    console.error('Error fetching NFTs:', data.error.message)
    return
  }
  if (data.result && data.result.items && data.result.items.length > 0) {
    const randomIndex = Math.floor(Math.random() * data.result.items.length)
    const selectedNft = data.result.items[randomIndex]
    console.log(`Id: ${selectedNft.id}`)
    console.log(`Name: ${selectedNft.content?.metadata?.name || 'Unnamed NFT'}`)
    console.log(`Symbol: ${selectedNft.content?.metadata?.symbol || 'N/A'}`)
    console.log(`Image: ${selectedNft.content.files[0].uri || 'No image available'}`)
  }
}

fetchRandomNFT();
3

Replace the API key

Replace YOUR_API_KEY with your API key.

4

Run the code

node fetchRandomNFT.js
5

Success!

Success! You should see the ID, name, symbol, and image of a random NFT owned by the address 86xCn…o2MMY in your terminal.

Next Steps

Explore more quickstarts to get the most out of Helius: