Package Exports
- nansen-cli
- nansen-cli/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nansen-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Nansen CLI
Built by agents, for agents. We prioritize the best possible AI agent experience.
Command-line interface for the Nansen API with structured JSON output, designed for AI agents and automation.
Installation
# Install globally via npm
npm install -g nansen-cli
# Or run directly with npx
npx nansen-cli help
# Or clone and install locally
git clone https://github.com/nansen-ai/nansen-cli.git
cd nansen-cli
npm install
npm linkConfiguration
For AI Agents (Recommended)
Use the AI Agent Setup flow:
- Your agent will ask you to visit: app.nansen.ai/auth/agent-setup
- Sign in with your Nansen account
- Copy the message shown
- Paste it back to your agent
Your agent saves the key and handles everything else automatically.
Manual Setup
Option 1: Interactive login
nansen login
# Enter your API key when prompted
# ✓ Saved to ~/.nansen/config.jsonOption 2: Environment variable (best for agents)
export NANSEN_API_KEY=your-api-keyOption 3: Direct config file
mkdir -p ~/.nansen && echo '{"apiKey":"<key>","baseUrl":"https://api.nansen.ai"}' > ~/.nansen/config.json && chmod 600 ~/.nansen/config.jsonGet your API key at app.nansen.ai/api.
Auth Priority
NANSEN_API_KEYenv var (highest)~/.nansen/config.jsonfile- Interactive prompt
Verify It Works
# Check CLI is installed (no API key needed):
nansen schema | head -1
# Verify API access:
nansen research token screener --chain solana --limit 1Quick Start
# Get trending tokens on Solana
nansen research token screener --chain solana --timeframe 24h --pretty
# Check Smart Money activity
nansen research smart-money netflow --chain solana --pretty
# Profile a wallet
nansen research profiler balance --address 0x28c6c06298d514db089934071355e5743bf21d60 --chain ethereum --pretty
# Search for tokens/entities
nansen research search "Vitalik Buterin" --prettyCommands
All analytics live under nansen research, trading under nansen trade, and wallet management under nansen wallet.
research - Research & Analytics
nansen research <category> <subcommand> [options]Category aliases: sm (smart-money), tgm (token), prof (profiler), port (portfolio)
research smart-money - Smart Money Analytics
Track trading and holding activity of sophisticated market participants.
| Subcommand | Description |
|---|---|
netflow |
Net capital flows (inflows vs outflows) |
dex-trades |
Real-time DEX trading activity |
perp-trades |
Perpetual trading on Hyperliquid |
holdings |
Aggregated token balances |
dcas |
DCA strategies on Jupiter |
historical-holdings |
Historical holdings over time |
Smart Money Labels: Fund, Smart Trader, 30D Smart Trader, 90D Smart Trader, 180D Smart Trader, Smart HL Perps Trader
research profiler - Wallet Profiling
ENS Name Resolution: You can use .eth names anywhere an --address is accepted:
nansen research profiler balance --address vitalik.eth
nansen research profiler labels --address nansen.eth --chain ethereum
nansen research profiler transactions --address vitalik.eth --tableENS names are automatically resolved to 0x addresses via public APIs (with onchain RPC fallback). Works on all EVM chains. The resolved name and address are included as _ens metadata in JSON output.
| Subcommand | Description |
|---|---|
balance |
Current token holdings |
labels |
Behavioral and entity labels |
transactions |
Transaction history |
pnl |
PnL and trade performance |
search |
Search for entities by name |
historical-balances |
Historical balances over time |
related-wallets |
Find wallets related to an address |
counterparties |
Top counterparties by volume |
pnl-summary |
Summarized PnL metrics |
perp-positions |
Current perpetual positions |
perp-trades |
Perpetual trading history |
research token - Token God Mode
| Subcommand | Description |
|---|---|
screener |
Discover and filter tokens |
holders |
Token holder analysis |
flows |
Token flow metrics |
dex-trades |
DEX trading activity |
pnl |
PnL leaderboard |
who-bought-sold |
Recent buyers and sellers |
flow-intelligence |
Detailed flow intelligence by label |
transfers |
Token transfer history |
jup-dca |
Jupiter DCA orders for token |
ohlcv |
OHLCV candle data for a token |
perp-trades |
Perp trades by token symbol |
perp-positions |
Open perp positions by token symbol |
perp-pnl-leaderboard |
Perp PnL leaderboard by token |
research search / research perp / research portfolio / research points
See nansen research help or nansen schema --pretty for full details.
trade - DEX Trading
# Get a swap quote
nansen trade quote --from USDC --to SOL --amount 10 --chain solana
# Execute the swap
nansen trade execute --from USDC --to SOL --amount 10 --chain solanawallet - Local Wallet Management
| Subcommand | Description |
|---|---|
create |
Create a new wallet (EVM + Solana keypair) |
list |
List all wallets |
show |
Show wallet addresses |
export |
Export private keys |
default |
Set default wallet |
delete |
Delete a wallet |
send |
Send tokens (native or ERC-20/SPL) |
Wallets are passwordless by default (keys stored like SSH keys). Set NANSEN_WALLET_PASSWORD env var for encryption at rest.
schema - Schema Discovery
No API key required. Machine-readable command reference for agent introspection.
nansen schema --pretty # All commands
nansen schema research --pretty # Research commandsDeprecated Flat Commands
The old flat commands (nansen smart-money, nansen token, nansen profiler, nansen search, nansen perp, nansen portfolio, nansen points, nansen quote, nansen execute) still work but print a deprecation warning to stderr. Use the new research and trade namespaces instead.
Options
| Option | Description |
|---|---|
--pretty |
Format JSON output for readability |
--table |
Format output as human-readable table |
--fields <list> |
Comma-separated fields to include (reduces response size) |
--stream |
Output as NDJSON for incremental processing |
--cache / --no-cache |
Enable/disable response caching |
--cache-ttl <s> |
Cache TTL in seconds (default: 300) |
--chain <chain> |
Blockchain to query |
--chains <json> |
Multiple chains as JSON array |
--limit <n> |
Number of results |
--days <n> |
Date range in days (default: 30) |
--sort <field:dir> |
Sort results (e.g., --sort value_usd:desc) |
--symbol <sym> |
Token symbol for perp endpoints (e.g., BTC, ETH) |
--filters <json> |
Filter criteria as JSON |
--labels <label> |
Smart Money label filter |
--smart-money |
Filter for Smart Money only |
--timeframe <tf> |
Time window (5m, 10m, 1h, 6h, 24h, 7d, 30d) |
Supported Chains
ethereum solana base bnb arbitrum polygon optimism avalanche linea scroll zksync mantle ronin sei plasma sonic unichain monad hyperevm iotaevm
Run
nansen schemato get the current chain list (source of truth).
Agent-Optimized Patterns
Reduce Token Burn with --fields
# ❌ Returns everything (huge JSON, wastes agent context)
nansen research smart-money netflow --chain solana
# ✅ Only what you need
nansen research smart-money netflow --chain solana --fields token_symbol,net_flow_usd,chain --limit 10Use --stream for Large Results
# NDJSON mode — process line by line, don't buffer giant arrays
nansen research token dex-trades --chain solana --limit 100 --streamx402 Micropayments
When the API returns a 402 Payment Required, the CLI automatically handles payment if a funded wallet exists:
- CLI detects 402 response with payment requirements
- Signs a USDC payment ($0.05/call) using your wallet
- Retries the request with the payment signature
- Falls back from EVM to Solana if first network has insufficient funds
# Fund your wallet, then API calls auto-pay
nansen wallet create
# Send USDC to the displayed address
nansen research smart-money netflow --chain solana # auto-pays if no API keyPagination
Use --limit N to control result count. The CLI always fetches page 1 (there is no --page flag).
Detecting the last page: If results returned < your --limit, you've reached the end.
Output Format
Response envelope
// Success
{ "success": true, "data": <raw_api_response> }
// Error
{ "success": false, "error": "message", "code": "ERROR_CODE", "status": 401, "details": {...} }Response shapes vary by endpoint
The data field structure differs across endpoints:
| Shape | Example endpoints |
|---|---|
data.data (array) |
token screener |
data.results (array) |
entity search |
data.data.results (array) |
most profiler endpoints |
data.netflows |
smart-money netflow |
data.trades |
smart-money dex-trades |
data.holdings |
smart-money holdings |
data.holders |
token holders |
--table and --stream handle this automatically. For raw JSON parsing:
nansen research smart-money netflow --chain solana | jq 'keys, .data | keys'Error codes
| Code | Action |
|---|---|
CREDITS_EXHAUSTED |
Stop all API calls immediately — do not retry. Check your plan at app.nansen.ai. |
RATE_LIMITED |
Auto-retry handles this. |
UNSUPPORTED_FILTER |
Remove the filter and retry. |
UNAUTHORIZED |
Key is wrong or missing. Re-auth. |
INVALID_ADDRESS |
Check address format for the chain. |
Troubleshooting
| Symptom | Fix |
|---|---|
command not found: nansen |
npm install -g nansen-cli or npx nansen-cli |
UNAUTHORIZED after login |
Check cat ~/.nansen/config.json. Write directly if needed. |
| Login hangs | Skip nansen login, write config directly. |
| Huge JSON response | Use --fields to select only needed columns. |
| Perp endpoints empty | Use --symbol BTC not --token. Perps are Hyperliquid-only. |
UNSUPPORTED_FILTER on token holders |
Not all tokens have smart money data. Remove --smart-money. |
CREDITS_EXHAUSTED |
Check your plan at app.nansen.ai. |
Development
npm test # Run tests (mocked, no API key needed)
npm run test:coverage # With coverage
npm run test:live # Against live API (needs NANSEN_API_KEY)See AGENTS.md for contributor guidance (architecture, testing patterns, style guide).
API Coverage
| Category | Endpoints | Coverage |
|---|---|---|
| Smart Money | 6 | 100% |
| Profiler | 11 | 100% |
| Token God Mode | 12 | 100% |
| Portfolio | 1 | 100% |
| Search | 1 | 100% |
| Total | 31 | 100% |