glassnode-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Glassnode CLI (
gn
)

Glassnode CLI (
gn
)

Command-line interface for the Glassnode API.
Glassnode API的命令行界面。

Setup

安装设置

If the
gn
command is not available you need to install the CLI. See the Installation section in the README for install and setup options.
Quick start:
bash
gn asset list
gn metric get market/price_usd_close --asset BTC --since 30d
如果
gn
命令不可用,你需要安装该CLI。请查看README中的安装章节获取安装和设置选项。
快速开始:
bash
gn asset list
gn metric get market/price_usd_close --asset BTC --since 30d

Commands

命令

List assets

列出资产

bash
gn asset list
gn asset list --filter "asset.semantic_tags.exists(tag,tag=='stablecoin')"
gn asset list --filter "asset.id=='BTC'"
bash
gn asset list
gn asset list --filter "asset.semantic_tags.exists(tag,tag=='stablecoin')"
gn asset list --filter "asset.id=='BTC'"

Prune to specific fields (returns array of objects)

筛选特定字段(返回对象数组)

gn asset list --prune id -o json gn asset list -p id,symbol -o json
undefined
gn asset list --prune id -o json gn asset list -p id,symbol -o json
undefined

Describe an asset

查看资产详情

bash
gn asset describe BTC
bash
gn asset describe BTC

List metrics

列出指标

bash
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
Filter by any metadata query parameters:
--currency
,
--exchange
,
--interval
,
--from-exchange
,
--to-exchange
,
--miner
,
--maturity
,
--network
,
--period
,
--quote-symbol
, or multiple
--assets
.
bash
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
可通过以下元数据查询参数进行筛选:
--currency
--exchange
--interval
--from-exchange
--to-exchange
--miner
--maturity
--network
--period
--quote-symbol
,或使用多个
--assets
参数。

Describe a metric (discover valid parameters)

查看指标详情(了解可用参数)

bash
gn metric describe market/price_usd_close
gn metric describe market/price_usd_close --asset BTC
bash
gn metric describe market/price_usd_close
gn metric describe market/price_usd_close --asset BTC

Fetch metric data

获取指标数据

bash
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 market/price_usd_close --asset BTC --since 30d
gn metric get indicators/sopr --asset BTC --interval 24h --since 30d
gn metric get distribution/balance_exchanges --asset BTC --exchange binance --currency usd
bash
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 market/price_usd_close --asset BTC --since 30d
gn metric get indicators/sopr --asset BTC --interval 24h --since 30d
gn metric get distribution/balance_exchanges --asset BTC --exchange binance --currency usd

Bulk fetch (multiple assets)

批量获取(多资产)

Append
/bulk
to the metric path. Repeat
-a
(or
--asset
) for each asset, or use
-a '*'
for all:
bash
gn metric get market/marketcap_usd/bulk -a BTC -a ETH -a SOL -s 1d
gn metric get market/marketcap_usd/bulk -a '*' --interval 24h --since 30d
在指标路径后追加
/bulk
。重复使用
-a
(或
--asset
)指定每个资产,或使用
-a '*'
获取全部资产:
bash
gn metric get market/marketcap_usd/bulk -a BTC -a ETH -a SOL -s 1d
gn metric get market/marketcap_usd/bulk -a '*' --interval 24h --since 30d

Config set / get

配置设置/查看

bash
gn config set api-key=your-key
gn config set output=csv
gn config get api-key
gn config get all
bash
gn config set api-key=your-key
gn config set output=csv
gn config get api-key
gn config get all

Global Flags

全局标志

FlagShortDescription
--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
标志简写描述
--api-key
Glassnode API密钥
--output
-o
输出格式:
json
(默认)、
csv
table
--dry-run
打印请求URL但不执行请求
--timestamp-format
输出中的时间戳格式

Best Practices

最佳实践

  • Always call
    gn metric describe <path>
    before
    gn metric get
    to discover valid parameters, assets, exchanges, and intervals for a metric.
  • Use
    --output json
    (default) for structured output suitable for piping to
    jq
    .
  • Use
    --dry-run
    to preview the API request URL without executing:
    gn metric get market/price_usd_close --asset BTC --since 30d --dry-run
    .
  • For bulk metrics (path ending in
    /bulk
    ), use
    -a
    with specific assets or
    -a '*'
    for all.
  • Relative time values are supported for
    --since
    and
    --until
    : e.g.
    30d
    ,
    7d
    ,
    1h
    .
  • 在执行
    gn metric get
    之前,务必调用
    gn metric describe <path>
    来了解该指标的可用参数、资产、交易所和时间间隔。
  • 使用
    --output json
    (默认格式)获取结构化输出,便于通过
    jq
    进行管道处理。
  • 使用
    --dry-run
    预览API请求URL而不执行:
    gn metric get market/price_usd_close --asset BTC --since 30d --dry-run
  • 对于批量指标(路径以
    /bulk
    结尾),使用
    -a
    指定特定资产或
    -a '*'
    获取全部资产。
  • --since
    --until
    支持相对时间值:例如
    30d
    7d
    1h

Output Formats

输出格式

  • --output json
    (default) — JSON, suitable for
    jq
    processing
  • --output csv
    — CSV format, suitable for spreadsheets
  • --output table
    — human-readable ASCII table
bash
undefined
  • --output json
    (默认)—— JSON格式,适合
    jq
    处理
  • --output csv
    —— CSV格式,适合导入电子表格
  • --output table
    —— 人类可读的ASCII表格
bash
undefined

Pipe JSON to jq

将JSON通过管道传给jq

gn metric get market/price_usd_close -a BTC --since 7d | jq '.[].v'
gn metric get market/price_usd_close -a BTC --since 7d | jq '.[].v'

Export to CSV

导出为CSV

gn metric get market/price_usd_close -a BTC --since 30d -o csv > prices.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 table
undefined
gn metric get market/price_usd_close -a BTC --since 7d -o table
undefined