How to get nft activities 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 from time to time
In order to get nft activities from time to time, Blocklens provides you a getNftActivitiesFromTimeToTime endpoint to do so.
Here you'll need parameters: from_time
, to_time
.
Once you've obtained all the from_time
, to_time
, 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.getNftActivitiesFromTimeToTime({"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": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Mjc5OTgyMjYyMDAwMDAwLCJwYWdlIjoxLCJmcm9tX3RpbWUiOiIxNjk2MDQ4MjU5IiwidG9fdGltZSI6IjE2OTYwNDgyNTkiLCJpYXQiOjE2OTcwNTc5MTR9._dnu62U6c1ivtLzvRxEP-fDQebKQN1J4NmJQncWLCqM",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"transfer_type": "0x3::token::DepositEvent",
"transaction_version": 279982262,
"timestamp": 1696048259,
"token_data_id_hash": "c4526582d65ff1fefa30583ae3fc12736031e8bc434145bf059416f248069e03",
"token_amount": 1,
"to_address": "0x673edba0e0b864ca3eb458fdd45d55f6eced59bb5bdc3b1f3671fae0f9ea4e4d",
"name": "aboard.apt",
"property_version": 1,
"from_address": "null",
"event_sequence_number": 6507,
"event_index": 1,
"event_creation_number": 2,
"event_account_address": "0x673edba0e0b864ca3eb458fdd45d55f6eced59bb5bdc3b1f3671fae0f9ea4e4d",
"collection_name": "Aptos Names V1",
"collection_data_id_hash": "09e63a48047b1c2bc51c0abc4b67ffcd9922e0adc99a6cc36532662172976a4b",
"coin_type": "null",
"coin_amount": "null",
"creator_address": "0x305a97874974fdb9a7ba59dc7cab7714c8e8e00004ac887b6e348496e1981838",
"block_height": 97922844
}
]
}
Congratulations 🥳 you just found the get nft activities 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.