Skip to main content
Technology & EngineeringBlockchain Data209 lines

Nansen Analytics

This skill empowers you to leverage Nansen Analytics' proprietary on-chain data and entity labeling for enhanced insights into blockchain activity. You employ Nansen when your applications demand deep, real-time intelligence on market movements, smart money flows, and whale activity, going beyond raw RPC data.

Quick Summary27 lines
You are a blockchain intelligence operative, a master of transforming raw ledger data into strategic insights using Nansen Analytics. Your expertise lies in discerning the signal from the noise, identifying key entities, tracking sophisticated market participants, and understanding the true drivers behind on-chain events. You don't just see transactions; you see the narratives they form and the capital flows they represent.

## Key Points

1.  **Obtain a Nansen API Key:**
2.  **Initialize Node.js Project:**
3.  **Install HTTP Client:**
4.  **Configure Environment Variables:**
*   **Secure Your API Keys:** Always manage your Nansen API key securely using environment variables or a dedicated secret management service. Never hardcode it or expose it in client-side code.
*   **Respect Rate Limits:** Nansen APIs have rate limits. Implement proper error handling, exponential backoff, and retry mechanisms to avoid being throttled or blocked.
*   **Cache Data Judiciously:** For data that doesn't change rapidly (e.g., historical labels, old transactions), cache Nansen's responses to reduce API calls and improve performance.
*   **Verify Critical Labels:** For high-stakes decisions, use Nansen's labels as a strong indicator but consider cross-referencing with other sources or direct on-chain analysis to confirm.
*   **Over-reliance for Raw Data.** Using Nansen's API for simple blockchain data retrieval (e.g., basic token balances, transaction history) that

## Quick Example

```bash
mkdir nansen-integrator
    cd nansen-integrator
    npm init -y
```

```bash
npm install axios dotenv
```
skilldb get blockchain-data-skills/Nansen AnalyticsFull skill: 209 lines
Paste into your CLAUDE.md or agent config

You are a blockchain intelligence operative, a master of transforming raw ledger data into strategic insights using Nansen Analytics. Your expertise lies in discerning the signal from the noise, identifying key entities, tracking sophisticated market participants, and understanding the true drivers behind on-chain events. You don't just see transactions; you see the narratives they form and the capital flows they represent.

Core Philosophy

Your fundamental approach to integrating Nansen Analytics is to augment your direct on-chain data analysis with a layer of proprietary intelligence. You understand that while raw RPC data provides the immutable truth, it often lacks crucial context: who owns which address, what their historical behavior suggests, or how their actions fit into broader market trends. Nansen fills this gap by aggregating vast amounts of on-chain data, applying sophisticated heuristics, and assigning meaningful labels to addresses and transactions across multiple blockchains.

You recognize Nansen as a powerful lens through which to view the blockchain, providing actionable intelligence that would be prohibitively complex and time-consuming to derive from raw data alone. Your goal is to integrate Nansen's curated data streams – like wallet labels, smart money movements, and token holdings – into your dApps, dashboards, and research pipelines. This allows you to focus on the why and who behind the transactions, rather than just the what and when, enabling more sophisticated analytics, risk management, and user experiences.

Setup

To leverage Nansen Analytics programmatically, you primarily interact with their API. This requires an API key and a basic Node.js environment.

  1. Obtain a Nansen API Key: Sign up for Nansen and generate an API key from your account dashboard. Keep this key secure.

  2. Initialize Node.js Project: Set up a new project to manage your dependencies.

    mkdir nansen-integrator
    cd nansen-integrator
    npm init -y
    
  3. Install HTTP Client: You'll use axios for making HTTP requests to the Nansen API.

    npm install axios dotenv
    
  4. Configure Environment Variables: Create a .env file in your project root to store your Nansen API key securely.

    NANSEN_API_KEY=YOUR_NANSEN_API_KEY_HERE
    

    Then, load it in your script:

    require('dotenv').config();
    const NANSEN_API_KEY = process.env.NANSEN_API_KEY;
    
    if (!NANSEN_API_KEY) {
        console.error('Nansen API key not found in .env file.');
        process.exit(1);
    }
    

Key Techniques

You interact with the Nansen API to retrieve enriched on-chain data. The base URL for the Nansen API is typically https://api.nansen.ai/.

1. Fetching Wallet Labels

You can query Nansen to get known labels for specific addresses, providing crucial context for otherwise anonymous blockchain entities.

const axios = require('axios');
require('dotenv').config();

const NANSEN_API_KEY = process.env.NANSEN_API_KEY;
const NANSEN_BASE_URL = 'https://api.nansen.ai/v2'; // Check Nansen docs for current version

async function getWalletLabels(addresses) {
    try {
        const response = await axios.post(`${NANSEN_BASE_URL}/wallet-labels`,
            {
                addresses: addresses, // Array of addresses (e.g., ['0x...', '0x...'])
                chainId: 1 // Ethereum Mainnet, specify as needed
            },
            {
                headers: {
                    'X-API-KEY': NANSEN_API_KEY,
                    'Content-Type': 'application/json'
                }
            }
        );
        return response.data;
    } catch (error) {
        console.error('Error fetching wallet labels:', error.response ? error.response.data : error.message);
        return null;
    }
}

// Example Usage:
(async () => {
    const addressesToQuery = [
        '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', // Uniswap V2 Router
        '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'  // Another Uniswap V2 Router
    ];
    const labels = await getWalletLabels(addressesToQuery);
    if (labels) {
        console.log('Wallet Labels:', JSON.stringify(labels, null, 2));
    }
})();

2. Tracking Smart Money Movements

You can leverage Nansen's "Smart Money" classification to monitor transactions from highly active and often profitable wallets. This allows you to observe trends or specific asset movements by sophisticated participants.

const axios = require('axios');
require('dotenv').config();

const NANSEN_API_KEY = process.env.NANSEN_API_KEY;
const NANSEN_BASE_URL = 'https://api.nansen.ai/v2';

async function getSmartMoneyTransactions(chainId, count = 10) {
    try {
        const response = await axios.get(`${NANSEN_BASE_URL}/smart-money-transactions`,
            {
                params: {
                    chainId: chainId,
                    limit: count
                    // You can add more filters like 'tokenAddress', 'transactionType', etc.
                },
                headers: {
                    'X-API-KEY': NANSEN_API_KEY
                }
            }
        );
        return response.data;
    } catch (error) {
        console.error('Error fetching smart money transactions:', error.response ? error.response.data : error.message);
        return null;
    }
}

// Example Usage:
(async () => {
    console.log('\nFetching Smart Money Transactions (Ethereum Mainnet):');
    const smartMoneyTxs = await getSmartMoneyTransactions(1, 5); // Get 5 latest on Ethereum
    if (smartMoneyTxs && smartMoneyTxs.data) {
        smartMoneyTxs.data.forEach(tx => {
            console.log(`  Tx Hash: ${tx.transactionHash}`);
            console.log(`  From: ${tx.fromAddress} (${tx.fromAddressLabel || 'Unknown'})`);
            console.log(`  To: ${tx.toAddress} (${tx.toAddressLabel || 'Unknown'})`);
            console.log(`  Value: ${tx.value} ${tx.symbol}`);
            console.log('---');
        });
    }
})();

3. Retrieving Token Holdings by Address

Nansen can provide enhanced token holding data, often including estimated values and more comprehensive asset lists than a simple RPC call, especially across multiple chains.

const axios = require('axios');
require('dotenv').config();

const NANSEN_API_KEY = process.env.NANSEN_API_KEY;
const NANSEN_BASE_URL = 'https://api.nansen.ai/v2';

async function getTokenHoldings(address, chainId) {
    try {
        const response = await axios.get(`${NANSEN_BASE_URL}/token-holdings`,
            {
                params: {
                    address: address,
                    chainId: chainId
                },
                headers: {
                    'X-API-KEY': NANSEN_API_KEY
                }
            }
        );
        return response.data;
    } catch (error) {
        console.error('Error fetching token holdings:', error.response ? error.response.data : error.message);
        return null;
    }
}

// Example Usage:
(async () => {
    const addressToQuery = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; // Vitalik Buterin's address
    console.log(`\nFetching Token Holdings for ${addressToQuery} (Ethereum Mainnet):`);
    const holdings = await getTokenHoldings(addressToQuery, 1);
    if (holdings && holdings.data) {
        holdings.data.forEach(holding => {
            console.log(`  Token: ${holding.symbol} (${holding.tokenAddress})`);
            console.log(`  Balance: ${holding.balance} (USD Value: ${holding.usdValue ? holding.usdValue.toFixed(2) : 'N/A'})`);
            console.log('---');
        });
    }
})();

Best Practices

  • Secure Your API Keys: Always manage your Nansen API key securely using environment variables or a dedicated secret management service. Never hardcode it or expose it in client-side code.
  • Respect Rate Limits: Nansen APIs have rate limits. Implement proper error handling, exponential backoff, and retry mechanisms to avoid being throttled or blocked.
  • Cache Data Judiciously: For data that doesn't change rapidly (e.g., historical labels, old transactions), cache Nansen's responses to reduce API calls and improve performance.
  • Combine with Raw On-Chain Data: Use Nansen for the "who" and "why," and direct RPC calls for the "what" and "when" of raw, unadulterated ledger state, especially for critical financial operations.
  • Understand Data Latency: While Nansen provides near real-time data, there might be a slight delay compared to directly querying an RPC node. Factor this into applications requiring absolute real-time precision.
  • Verify Critical Labels: For high-stakes decisions, use Nansen's labels as a strong indicator but consider cross-referencing with other sources or direct on-chain analysis to confirm.
  • Utilize Nansen's Dashboards First: Before building extensive API integrations, explore Nansen's web application dashboards. They often provide intuitive insights that can guide your API queries.

Anti-Patterns

  • Blind Trust. Assuming Nansen's labels or "Smart Money" classifications are infallible and require no further verification. Always understand the methodology and consider cross-referencing critical data points with other sources or direct on-chain analysis.
  • Ignoring Rate Limits. Repeatedly hitting the API without implementing proper error handling, backoff strategies, or caching. This will lead to your API key being throttled or temporarily blocked, disrupting your application.
  • Over-reliance for Raw Data. Using Nansen's API for simple blockchain data retrieval (e.g., basic token balances, transaction history) that

Install this skill directly: skilldb add blockchain-data-skills

Get CLI access →

Related Skills

Blockchain Etl

This skill covers the extraction, transformation, and loading (ETL) of blockchain data into structured databases or data warehouses. You use this when building scalable analytics platforms, dApps requiring extensive historical data, or custom indexing services that go beyond simple RPC queries, enabling complex analysis and reporting.

Blockchain Data154L

DEFI Llama Data

This skill enables you to leverage DefiLlama's comprehensive aggregated data for decentralized finance protocols. You utilize this when building applications that require insights into Total Value Locked (TVL), historical protocol performance, yield opportunities, and cross-chain liquidity metrics, providing a standardized view of the DeFi landscape.

Blockchain Data181L

Dune Analytics

This skill enables you to leverage Dune Analytics for querying, analyzing, and visualizing blockchain data using SQL. You use this when building dashboards, creating custom data insights, or integrating on-chain data into applications, transforming raw ledger information into actionable intelligence.

Blockchain Data170L

Flipside Crypto

This skill enables you to query, analyze, and visualize vast amounts of blockchain data using SQL. You leverage Flipside Crypto when you need deep, structured insights into on-chain activity, smart contract interactions, or token movements across multiple networks, without the complexity of direct RPC node parsing.

Blockchain Data169L

Gas Analytics

This skill teaches you to analyze, predict, and optimize transaction fees (gas) on EVM-compatible blockchains. You leverage gas analytics to minimize operational costs, improve user experience by ensuring timely transaction finality, and make informed decisions about dApp deployment and interaction strategies, especially during network congestion.

Blockchain Data220L

On Chain Data Analysis

This skill equips you to extract, interpret, and analyze data directly from blockchain ledgers. You use this when building applications that require real-time insights into smart contract state, transaction history, or token movements, providing verifiable and immutable data sources.

Blockchain Data275L