> For the complete documentation index, see [llms.txt](https://docs.solscan.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.solscan.io/build-with-ai/solscan-cli.md).

# Solscan CLI

Explore Solana on-chain data from the command line — accounts, tokens, transactions, NFTs, blocks, markets, and programs — with clean JSON by default (or human-readable tables for people). 59+ actions across the full Solscan Pro API v2.0

[GitHub →](https://github.com/solscanofficial/solscan-cli)&#x20;

<figure><img src="/files/Cuj2rA8D9OeqfxbZdcKv" alt=""><figcaption></figcaption></figure>

### Get started

#### Step 1 — Install

The CLI runs on [Node.js](https://nodejs.org) 18 or newer.

Install globally from npm:

```bash
npm install -g solscan-cli
```

Or run it without installing, using `npx`:

```bash
npx solscan-cli <command>
```

Verify the install:

```bash
solscan --version
```

#### Step 2 — Authenticate

First, get a Solscan API key from your [API management page](https://solscan.io/user/profile#api_management) if you do not have one. Both **free** and **paid (Pro)** keys work — a paid key raises rate limits and unlocks the full endpoint set.

Save your key so every command picks it up:

```bash
solscan config set-api-key YOUR_API_KEY_HERE
```

The CLI resolves the key in priority order: the `--api-key` flag, then the `SOLSCAN_API_KEY` environment variable, then the stored config file. Confirm what's active with:

```bash
solscan config show
```

#### Step 3 — Run your first commands

Get trending tokens (JSON by default):

```bash
solscan token trending
```

Look up an account's portfolio with USD values:

```bash
solscan account portfolio --address 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM
```

Switch any command to a readable table with `--no-json`:

```bash
solscan token trending --no-json
```

***

### Command reference

Commands follow `solscan <resource> <action> [options]`, mirroring the Pro API. JSON is the default output; switch it with `--no-json`. List endpoints accept `--page` / `--page-size` (or `--limit`) for pagination.

| Resource      | Covers                                                                            |
| ------------- | --------------------------------------------------------------------------------- |
| `account`     | Balances, transfers, DeFi activity, stake, rewards, portfolio, labels, CSV export |
| `token`       | Metadata, holders, price, markets, transfers, DeFi activity, search               |
| `transaction` | Full details, decoded actions, batch lookup, network fees                         |
| `nft`         | Activities, collections, items, new mints                                         |
| `block`       | Latest blocks, block detail, block transactions                                   |
| `market`      | DEX pools, market info, historical volume, positions                              |
| `program`     | Active programs, popular platforms, program analytics                             |
| `monitor`     | API key compute-unit usage                                                        |

For a resource's actions and every flag, run:

```bash
solscan <resource> --help
solscan account --help
solscan token search --help
```

The full option reference lives in the [README](https://github.com/solscanofficial/solscan-cli#usage).

***

### Practical workflows

Common tasks and the commands you would run for each.

#### Research a wallet

Check whether it's a known/labeled address, then read its holdings and activity:

```bash
solscan account metadata --address <WALLET>
```

Portfolio with USD values, low-quality tokens filtered out:

```bash
solscan account portfolio --address <WALLET> --exclude-low-score-tokens
```

Large-value outgoing transfers only ($100–$999,999):

```bash
solscan account transfers --address <WALLET> --flow out --value 100,999999
```

Swap history across direct and aggregator routes:

```bash
solscan account defi --address <WALLET> \
  --activity-type ACTIVITY_TOKEN_SWAP,ACTIVITY_AGG_TOKEN_SWAP
```

#### Analyze a token before trading

Confirm identity and price:

```bash
solscan token meta --address <MINT>
solscan token price-latest --addresses <MINT>
```

Check holder concentration — filter to large holders:

```bash
solscan token holders --address <MINT> --from-amount 1000000 --page-size 20
```

Find the deepest liquidity pools:

```bash
solscan token markets --token <MINT> --sort-by tvl
```

#### Filter raw transactions by instruction

`transactions-enhanced` returns raw transaction objects with full server-side filtering — by program, signer, token, time, slot, or a specific instruction. Filter a wallet's history to one program, successful only:

```bash
solscan account transactions-enhanced --address <WALLET> \
  --program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 \
  --status true --limit 20
```

Target a single instruction by discriminator. The value is the program address plus the first 2 bytes (Shank IDL) or 8 bytes (Anchor IDL) of the instruction data, in hex:

```bash
solscan account transactions-enhanced --address pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA \
  --instruction pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA66063d1201daebea
```

#### Export history to CSV for tax or accounting

Each `-export` action returns up to 5000 rows (max 10 requests/min). Print to stdout, or save with `--output`:

```bash
solscan account reward-export --address <WALLET> --output rewards.csv
solscan account defi-export --address <WALLET> --output defi.csv
solscan account transfer-export --address <WALLET> --output transfers.csv
```

#### Build scripts and agent workflows

JSON is the default, so piping into `jq` or an agent needs no flags:

```bash
solscan account defi --address <WALLET> | jq '.data[0]'
```

Redirect a CSV export straight into a data pipeline:

```bash
solscan token defi-export --address <MINT> --output token-defi.csv
```

#### Quick market overview

```bash
solscan token trending --limit 20 --no-json
solscan token latest --platform-id pumpfun --page-size 20
solscan market list --sort-by volumes_24h --sort-order desc
solscan program list --sort-by num_txs --sort-order desc
solscan monitor usage
```

***

### Output modes

**JSON (default)** — every command returns formatted JSON with a `success` flag and a `data` array, ideal for `jq`, Python, or an AI agent.

**Human-readable** — add `--no-json` for a table/text view meant for reading in the terminal.

### Error handling

The CLI maps Pro API errors to clear messages and a suggested fix:

| HTTP code | Meaning                  | Suggested action                                               |
| --------- | ------------------------ | -------------------------------------------------------------- |
| `400`     | Bad request              | Check address format and enum values (type, page\_size, range) |
| `401`     | Authentication failed    | Run `solscan config set-api-key <KEY>`                         |
| `403`     | Insufficient permissions | Upgrade your API plan                                          |
| `429`     | Rate limit exceeded      | Wait a moment and retry                                        |
| `500`     | Server error             | Retry; report if it persists                                   |

If no key is configured, the CLI tells you to set one via `solscan config set-api-key <KEY>` or the `SOLSCAN_API_KEY` environment variable.
