Skip to main content
API, MCP, CLI

CLI Intro

Written By Nansen Team

Last updated About 12 hours ago

Get Started

What is Nansen CLI?

Nansen CLI gives AI agents and developers direct terminal access to Nansen's onchain intelligence. Smart Money tracking, wallet profiling, token analytics, and DEX trading, all through structured JSON output.

Built for automation and agent-first workflows.

How do I install it?

Its very simple, just type in Terminal:

npm install -g nansen-cli 

Requires Node.js v18+. No additional dependencies.

How do I authenticate?

nansen login 

This prompts for your API key. Stored in ~/.nansen/config.json. Or use an environment variable:

export NANSEN_API_KEY=your_api_key_here 

How do I set up Nansen CLI for an AI agent?

npx skills add nansen-ai/nansen-cli 

Adds a SKILL.md file that Claude Code, Codex, OpenClaw, and other compatible agents can read to understand available commands and output formats. Seven pre-built skills are available.

Do I need a Nansen Pro subscription to use the CLI?

No, you don’t need a Pro subscription to use the CLI.

Users can even use the CLI without logging by paying via x402 per call. x402 is ideal for agents and builders who prefer usage-based pricing without managing an account.

Agent Integration

Which agents are supported?

Seven pre-built skills covering Claude Code, Codex (OpenAI), OpenClaw, and more. Install any skill:

npx skills add nansen-ai/nansen-cli 

Each SKILL.md tells the agent which commands are available, what parameters they accept, and what the JSON output looks like.

How does an agent introspect available endpoints without reading the docs?

nansen schema 

Returns the full JSON schema for every endpoint — parameters, response shapes, supported chains. Agents can read this once and construct queries dynamically. No docs required.

Can I use Nansen CLI alongside the Nansen MCP server?

Yes. They serve different use cases:

• Nansen CLI — One npm install. No server to run. Ideal for agents that execute shell commands.
• Nansen MCP — Better for LLMs using Model Context Protocol (Claude Desktop, Cursor).

Use whichever fits your agent's architecture. Both access the same underlying Nansen data.

Troubleshooting

I’m getting ‘nansen: command not found’ after installing, what do I do?

Make sure your global npm bin is in your PATH:

export PATH="$(npm bin -g):$PATH" 

Or install via a Node version manager (nvm, fnm) where global bins are automatically available.

Your API key is missing or invalid. Re-run nansen login --api-key <key> and paste your key from app.nansen.ai/account (API tab). If using an environment variable, verify it's exported in the current shell session.

What happens if I get empty results from perp endpoints

Perp data is protocol-specific. Verify the chain and protocol are supported:

nansen schema perp 

If the protocol isn't listed, it isn't supported yet.

I’m getting a ‘CREDITS_EXHAUSTED’ error

Your x402 USDC balance is depleted, or your Pro monthly API credits are used up. For x402: top up your linked wallet. For Pro: check usage in Account Settings or wait for the monthly reset.

It’s telling me ‘Response is too large / agent context overflow’

Use --fields and --limit together:

nansen research smart-money netflow --chain ethereum --fields token,netflow --limit 20

If piping into an agent, summarise results before passing them into context.

Was this helpful?

Still need help? Share an idea