How to get nft activities
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 NFT activities
In order to get nft activities, Blocklens provides you a getNftActivities 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.getNftActivities();
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.eyJpZCI6MjgzMzMxMzYxMDAwMDAxLCJwYWdlIjoxLCJpYXQiOjE2OTcwNjAzMzB9.AqRhwo6iTQFKfSESvwaF4zB7MZInyX2c8rxRo8K7WkA",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"transfer_type": "0x3::token::WithdrawEvent",
"transaction_version": 283331739,
"timestamp": 1696299639,
"token_data_id_hash": "27ba8505bd12b3adffff27e8d6d71e05d0b9a13232e6460a5797614a63b4bfcd",
"token_amount": 1,
"to_address": "null",
"name": "Secret Owl Society #1060",
"property_version": 0,
"from_address": "0x7fe905c90a82164e667bd122f1aeeadbadd5cedd385201aeb40eb37e17cb3e9f",
"event_sequence_number": 14,
"event_index": 0,
"event_creation_number": 5,
"event_account_address": "0x7fe905c90a82164e667bd122f1aeeadbadd5cedd385201aeb40eb37e17cb3e9f",
"collection_name": "Secret Owl Society",
"collection_data_id_hash": "558af35e2926aabf6d4c2dfbf4c3794d9c32341c503311c6a1a51e0d19facebb",
"coin_type": "null",
"coin_amount": "null",
"creator_address": "0xdefaf3b8c05d05144ba5dbfae766b35bf2085ee4672c8d7c557533d20453b65a",
"block_height": 98982984
}
]
}
Congratulations 🥳 you just found the get nft activities 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.