ic-query
ic-query provides read-only Internet Computer metadata query code, and
ic-query-cli provides the icq executable wrapper.
icq currently supports NNS, SNS, and generic ICRC metadata queries: registry
version, subnet catalog lookup, node/provider/operator/data-center inventory,
topology reports, deployed SNS reports, and ICRC ledger capabilities, token,
balance, allowance, index, transaction history, block type, archive, and tip
certificate reports.
Install
From this checkout:
From crates.io after publication:
Library
Use ic-query for typed report models and renderers without the icq process
wrapper:
[]
= { = "0.5", = false }
The library default feature set is empty. Enable host for native live-call
adapters, or cli for the family-level command adapters used by
ic-query-cli. No-default builds expose pure report DTOs and text renderers
for generic ICRC reports, NNS registry-version reports, and deployed SNS list
reports, plus subnet catalog JSON/model/resolver helpers, without native
live-call dependencies. This is a host/CLI dependency boundary, not a no_std
promise.
Commands
Use icq nns <family> help, icq nns topology <report> help, or
icq icrc <command> help, or icq sns <command> help for command options.
Most commands support text output by default and JSON output with
--format json:
Generic ICRC ledgers can be queried directly by ledger canister id. These
commands are live-only, include the queried source endpoint in text and JSON
reports, and support endpoint overrides with --source-endpoint:
Cache
The NNS subnet, node, provider, operator, data-center, and topology commands
use project-local cache files under .icq/. Refresh commands fetch current
mainnet registry data and replace the matching cache atomically:
List/info commands populate their component cache on first use and print the API endpoint they are calling before creating it. Refresh commands force a fresh fetch and replace the matching cache.
SNS neuron commands keep quick --sort api output on a bounded live query.
Whole-collection neuron sorts use complete snapshots and require an explicit
refresh first:
Complete SNS neuron snapshots live under
.icq/sns/ic/<root-principal>/neurons/full.json. Failed or capped refresh
attempts are recorded separately and do not replace the last complete snapshot.
Refresh shows a same-line stderr progress counter with pages and rows fetched
when running in a terminal.
Inspect local SNS neuron snapshots and their latest refresh-attempt metadata without making live calls:
Cache list and status commands are local-only; malformed, unsupported, or identity-mismatched snapshot files are shown as invalid local cache rows.
Live API neuron listings are capped at 100 rows per call. Cache-backed sorts
can use larger --limit values because they read from the complete local
snapshot.
Neuron IDs are shortened to eight characters in text tables by default. Use
icq sns neurons 1 --verbose to show full neuron IDs.
Text output shows current SNS token amounts, including token fee, total supply,
stake, maturity, and staked maturity, as token decimals with two places. JSON
keeps the raw base-unit and e8s fields.
SNS governance nervous system parameters can be queried by list id or root principal:
NNS governance proposals can be queried from the mainnet NNS governance
canister. Without a complete local snapshot, list views are bounded live
queries; status filters are sent to governance where supported, topic filters
are applied to returned rows, query filters search returned title, action,
summary, and URL text, and local sort modes mirror the SNS proposal direction
rules. Text and JSON list reports include result_scope so bounded live views
are distinguishable from complete-cache views:
NNS proposal list views support
--proposer <neuron-id>, --query <text>, and
--sort api|id|status|reward-status|topic|proposer|title|action|yes|no|total-votes|tally-time|voting-power|ballots|reject-cost|reward-round|proposed|deadline|decided|executed|failed.
Local sort modes accept --asc or --desc; status, reward status, topic,
proposer, title, and action default to ascending, while id, tally values, tally
time, ballot count, reject cost, reward round, voting power, and timestamp
sorts default to descending.
Complete NNS proposal snapshots can be refreshed and inspected explicitly. A refresh pages through NNS governance until the API is exhausted, writes progress to stderr in a terminal, and publishes only complete snapshots:
Complete NNS proposal snapshots live under
.icq/nns/ic/governance/proposals/full.json. Failed or capped refresh attempts
are recorded separately and do not replace the last complete snapshot. Proposal
list and detail lookups reuse an existing complete snapshot when it can satisfy
the request, then fall back to live governance lookup.
Cache list and status commands are local-only; malformed, unsupported, or
identity-mismatched snapshot files are shown as invalid local cache rows.
SNS governance proposals can be queried as cached list views or direct live
detail lookups. Normal proposal list views auto-create a complete local
snapshot on first use, then apply supported view options locally. Proposal
detail lookups reuse an existing complete local snapshot when it contains the
requested proposal, then fall back to live detail lookup. Status and topic
filters that can be reproduced from complete proposal rows use the local
snapshot, including decided/adopted/rejected status filters; reward eligibility
can be filtered with --eligible any|yes|no, and proposer neuron ids can be
filtered by prefix with --proposer. Use --query <text> to search proposal
title, action, summary, URL, and payload text:
Proposal list views support
--eligible any|yes|no, --proposer <neuron-id-prefix>, --query <text>, and
--sort api|id|status|topic|proposer|title|action|action-id|yes|no|total-votes|tally-time|ballots|eligible|reject-cost|reward-round|reward-end|created|decided|executed|failed.
Local sort modes accept --asc or --desc; status, topic, proposer, title,
and action default to ascending, while id, action id, tally values, tally time,
ballot count, reward eligibility, reject cost, reward round, and timestamp
sorts default to descending. Cache-compatible views filter and sort complete
local snapshots before applying --limit.
Complete SNS proposal snapshots can also be refreshed and inspected manually:
Cache list and status commands are local-only; malformed, unsupported, or identity-mismatched snapshot files are shown as invalid local cache rows.
Integration
icq is a standalone metadata lookup tool. Orchestration, deployment, and
application repositories can call the CLI when they need IC metadata instead of
linking registry adapters directly. For one integration example, see
Canic.
Status
The command namespace is intentionally small:
nnsis implemented.nns proposal listandnns proposal infoare cache-aware mainnet NNS governance proposal queries: they reuse complete local snapshots when those snapshots can satisfy the request, then fall back to bounded or direct live governance queries where applicable.nns proposal refreshcaches complete mainnet NNS governance proposal snapshots.nns proposal cache list|statusinspects local complete NNS proposal snapshots and refresh-attempt metadata without live calls.sns list,sns info,sns token,sns params,sns proposal,sns proposals, andsns neuronsare implemented for deployed mainnet SNS instances.sns proposalsauto-creates and reuses complete proposal snapshots for cache-compatible list views.sns proposals refreshforce-refreshes complete proposal snapshots.sns proposals cache list|statusinspects local complete proposal snapshots and refresh-attempt metadata without live calls.sns neurons refreshcaches complete neuron snapshots for cache-backed sorting.sns neurons cache list|statusinspects local complete neuron snapshots and refresh-attempt metadata without live calls.- Additional IC query families can be added without coupling query code to deployment tooling.