Command-line interface for the Glassnode API
Linux / macOS
curl -sSL https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.sh | bashInstalls the latest release to /usr/local/bin (uses sudo if needed). To install elsewhere:
INSTALL_DIR=~/bin curl -sSL https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.sh | bashWindows (PowerShell)
irm https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.ps1 | iexInstalls to %LOCALAPPDATA%\glassnode\bin and adds it to your user PATH if needed.
Download the archive for your OS and architecture from Releases, extract it, then move the binary into your PATH and make it executable (chmod +x gn on Unix).
go install github.com/glassnode/glassnode-cli@latestThe binary from go install is named glassnode-cli. To get the same gn command as the release, build with: go build -o gn . and put gn in your PATH.
# Set your API key
export GLASSNODE_API_KEY=your-key
# List available assets
gn asset list
# Fetch Bitcoin's closing price for the last 30 days
gn metric get market/price_usd_close --asset BTC --since 30dThe CLI resolves the API key in the following priority order:
--api-keyflag (highest priority)GLASSNODE_API_KEYenvironment variable~/.gn/config.yamlconfiguration file
To persist the key in the config file:
gn config set api-key=your-keyList all available assets.
gn asset list
gn asset list --filter "asset.semantic_tags.exists(tag,tag=='stablecoin')"
gn asset list --filter "asset.id=='BTC'"Use --prune to return only specific fields as an array of objects (e.g. for scripting or piping to jq):
# Only asset IDs (array of objects with one field)
gn asset list --prune id -o json
# ID and symbol
gn asset list -p id,symbol -o json| Flag | Short | Description |
|---|---|---|
--filter |
CEL filter expression | |
--prune |
-p |
Comma-separated fields to keep (e.g. id, symbol, name); output is array of objects with only those fields |
Show details about an asset.
gn asset describe BTCList all available metrics, optionally filtered by metadata query parameters.
gn metric list
gn metric list --asset BTC
gn metric list -a BTC -e binance -i 24h
gn metric list --assets BTC --assets ETH
gn metric list --from-exchange binance --to-exchange coinbase| Flag | Short | Description |
|---|---|---|
--asset |
-a |
Filter by asset (single) |
--assets |
Filter by multiple assets (repeat for each, e.g. --assets BTC --assets ETH) |
|
--currency |
-c |
Filter by currency (e.g. native, usd) |
--exchange |
-e |
Filter by exchange (e.g. binance, coinbase) |
--format |
-f |
Filter by response format (e.g. json, csv) |
--interval |
-i |
Filter by time interval (e.g. 1h, 24h) |
--from-exchange |
Source exchange for inter-exchange metrics | |
--to-exchange |
Destination exchange for inter-exchange metrics | |
--miner |
Miner identifier for mining-related metrics | |
--maturity |
Maturity period for derivatives metrics | |
--network |
Network/blockchain for cross-chain metrics | |
--period |
Time period for aggregation | |
--quote-symbol |
Quote currency symbol for trading pairs |
Show metadata for a metric: supported assets, intervals, exchanges, currencies, and parameters.
gn metric describe market/price_usd_close
gn metric describe market/price_usd_close --asset BTCFetch metric data from the API.
gn metric get market/price_usd_close --asset BTC --interval 24h
gn metric get market/price_usd_close --asset BTC --since 2024-01-01 --until 2024-02-01
gn metric get indicators/sopr --asset BTC --interval 24h --since 30d
gn metric get distribution/balance_exchanges --asset BTC --exchange binance --currency usd
# Bulk: append /bulk to the path; use -a '*' for all assets or multiple -a for specific ones
gn metric get market/marketcap_usd/bulk -a '*' --since 30d| Flag | Short | Description |
|---|---|---|
--asset |
-a |
Asset symbol (repeatable for bulk metrics; use * for all assets) |
--since |
-s |
Start time (ISO date or relative: 30d, 1h) |
--until |
-u |
End time (ISO date or relative) |
--interval |
-i |
Resolution (1h, 24h, 1w, 1month) |
--currency |
-c |
Currency for the metric (usd, native) |
--exchange |
-e |
Exchange filter (repeatable for bulk) |
--network |
-n |
Network filter |
For bulk metrics, append /bulk to the path (e.g. market/marketcap_usd/bulk). To pass multiple assets, repeat the -a (or --asset) flag for each: -a BTC -a ETH -a SOL. Use -a '*' to request all assets.
Set a configuration value.
gn config set api-key=your-key
gn config set output=csvRead a configuration value, or all values.
gn config get api-key
gn config get all| Flag | Short | Description |
|---|---|---|
--api-key |
Glassnode API key | |
--output |
-o |
Output format: json (default), csv, table |
--dry-run |
Print the request URL without executing | |
--timestamp-format |
Timestamp format in output |
- json (default) — structured JSON, suitable for piping to
jq - csv — comma-separated values for spreadsheets and data pipelines
- table — human-readable ASCII table
# Pipe JSON to jq
gn metric get market/price_usd_close -a BTC --since 7d | jq '.[].v'
# Export to CSV
gn metric get market/price_usd_close -a BTC --since 30d -o csv > prices.csv
# Quick look in the terminal
gn metric get market/price_usd_close -a BTC --since 7d -o tablegn metric list --asset BTC
gn metric describe market/price_usd_close --asset BTCgn metric get market/price_usd_close --asset BTC --since 30d --dry-runAppend /bulk to the metric path. Specify multiple assets by repeating -a for each, or use -a '*' for all:
# Multiple specific assets (repeat -a for each)
gn metric get market/marketcap_usd/bulk -a BTC -a ETH -a SOL -s 2024-01-01
# All assets (wildcard)
gn metric get market/marketcap_usd/bulk -a '*' --interval 24h --since 30dgn asset list --filter "asset.semantic_tags.exists(tag,tag=='stablecoin')"git clone https://github.com/glassnode/glassnode-cli.git
cd glassnode-cli
go build -o gn .go test ./...