How to get nft activities of collection from time to time
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 of collection from time to time
In order to get nft activities of collection from time to time, Blocklens provides you a getNftActivitiesOfCollectionFromTimeToTime endpoint to do so.
Here you'll need parameters: from_time
, to_time
, collection_data_id_hash
.
Once you've obtained all the from_time
, to_time
, collection_data_id_hash
, you can copy the following code:
import Blocklens from "blocklens-sdk";
const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });
const runApis = async () => {
const response = await blocklens.APTOS_MAINNET.getNftActivitiesOfCollectionFromTimeToTime("29c6893059a4c77fad7e7160b416a39ee44723830eb79187d97e9c7cdf36aa07", {"from_time":"1696048259","to_time":"1696048260"});
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": "string",
"page": 0,
"limit": 0,
"total_items": 0,
"data": [
{
"transfer_type": "0x3::token::MutateTokenPropertyMapEvent",
"transaction_version": 130,
"block_time": "2023-08-28 09:24:31.0",
"timestamp": 1693214669,
"token_data_id_hash": "2665375481df1ebbcdc9449cc4880e18f21a33fadda6b9ebf259797cc0a0e291",
"token_amount": 20,
"to_address": "09e63a48047b1c2bc51c0abc4b67ffcd9922e0adc99a6cc36532662172976a4b",
"name": "rockeric.apt",
"property_version": 0,
"from_address": "0x305a97874974fdb9a7ba59dc7cab7714c8e8e00004ac887b6e348496e1981838",
"event_sequence_number": 5,
"event_index": 2,
"event_creation_number": 1,
"event_account_address": "Aptos Names V1",
"collection_name": "09e63a48047b1c2bc51c0abc4b67ffcd9922e0adc99a6cc36532662172976a4b",
"collection_data_id_hash": "09e63a48047b1c2bc51c0abc4b67ffcd9922e0adc99a6cc36532662172976a4b",
"coin_type": "coin type",
"coin_amount": 1000,
"creator_address": "09e63a48047b1c2bc51c0abc4b67ffcd9922e0adc99a6cc36532662172976a4b",
"block_height": 1000
}
]
}
Congratulations 🥳 you just found the get nft activities of collection from time to time 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.