Skip to main content

How to get nfts

Prerequisites

Before getting started, make sure you have the following ready:

  • Node v.14+
  • NPM

Step 1: Setup Blocklens

First register your Blocklens account and get your Blocklens API Key.

Once you have your Blocklens API Key, install the Blocklens SDK in your project.

npm i blocklens-sdk

Step 2: Get NFTs

In order to get nfts, Blocklens provides you a getNfTs endpoint to do so.

import Blocklens from "blocklens-sdk";

const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });

const runApis = async () => {
const response = await blocklens.APTOS_MAINNET.getNfTs();
console.log(response);
};

runApis();

Step 3: Run the script

ts-node index.ts

In your terminal, you should see the following JSON response with the data: In your terminal, you should see the following JSON response with the data blocks:

{
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImYyOWM5OWEyMjYzZTg5M2U1MDE2NjNjYjJjODNmMDJmYTg3OTVjMmEwOTY1OTFiYWJlMTkzMDA0Y2Y5OTc4YzEiLCJwYWdlIjoxLCJpYXQiOjE2OTcwNTk5NjZ9.Ztxr0Lt7mRx0-BCv4VuglyGmMb48e8r6woGHa9Q2mPs",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"collection_data_id_hash": "null",
"collection_name": "null",
"creator_address": "null",
"name": "null",
"property_version": null,
"token_data_id_hash": "a9754ddaaf4e33c38a097ee0ec549eb5cfb1a88aa56fdc0140aa49991390eee8",
"token_properties": null,
"transaction_version": -2147483648,
"transaction_timestamp": 1695788888841,
"block_height": -2147483648
}
]
}

Congratulations 🥳 you just found the get nfts on multiple chains with only a few lines of code using the Blocklens Wallet API!

API Reference

If you want to know more details on the endpoint and optional parameters, check out:

Support

If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.