ic-dashboard

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

IC Dashboard APIs

IC Dashboard API

What This Is

这是什么

These public REST APIs power dashboard.internetcomputer.org. They expose read-only access to canister metadata, ICRC ledgers, SNS data, the ICP ledger, and network metrics via OpenAPI specs and Swagger UI. Agents and scripts can call them over HTTPS from off-chain (no canister deployment or cycles required). Prefer v2 or higher API versions where available; they provide cursor-based pagination (
after
,
before
,
limit
) and are the same surface the dashboard uses.
这些公开REST API为dashboard.internetcomputer.org提供支持,通过OpenAPI规范和Swagger UI提供对canister元数据、ICRC账本、SNS数据、ICP账本以及网络指标的只读访问权限。Agent和脚本可以通过HTTPS从链下调用这些API(无需部署canister或消耗cycles)。优先使用v2或更高版本的API(如果有可用版本);这些版本支持基于游标分页(
after
before
limit
),与仪表盘使用的接口一致。

Prerequisites

前置条件

  • Any HTTP client:
    curl
    ,
    fetch
    ,
    axios
    , or the language’s native HTTP library.
  • No
    icp-cli
    or canister deployment needed for read-only API access.
  • For OpenAPI-based codegen: optional use of the
    openapi.json
    URLs with your preferred OpenAPI tooling.
  • 任意HTTP客户端:
    curl
    fetch
    axios
    或编程语言原生的HTTP库。
  • 只读API访问无需
    icp-cli
    或部署canister。
  • 基于OpenAPI的代码生成:可选择将
    openapi.json
    链接与你偏好的OpenAPI工具配合使用。

API Base URLs and Docs

API基础地址与文档

APIBase URLOpenAPI specSwagger / DocsPrefer
IC API
https://ic-api.internetcomputer.org
/api/v3/openapi.json
/api/v3/swagger
v4 for canisters, subnets (cursor pagination)
ICRC API
https://icrc-api.internetcomputer.org
/openapi.json
/docs
v2 for ledgers (TestICP and other ICRC tokens; not mainnet ICP)
SNS API
https://sns-api.internetcomputer.org
/openapi.json
/docs
v2 for snses, proposals, neurons
Ledger API (mainnet ICP)
https://ledger-api.internetcomputer.org
/openapi.json
/swagger-ui/
Use for ICP token; v2 for cursor pagination
Metrics API
https://metrics-api.internetcomputer.org
/api/v1/openapi.json
/api/v1/docs
v1 (no newer version)
Full URLs for specs and UI:
API基础URLOpenAPI规范Swagger / 文档优先版本
IC API
https://ic-api.internetcomputer.org
/api/v3/openapi.json
/api/v3/swagger
v4(用于canister、子网,支持游标分页)
ICRC API
https://icrc-api.internetcomputer.org
/openapi.json
/docs
v2(用于账本,包括TestICP和其他ICRC代币;不包含主网ICP)
SNS API
https://sns-api.internetcomputer.org
/openapi.json
/docs
v2(用于SNS、提案、神经元)
账本API(主网ICP)
https://ledger-api.internetcomputer.org
/openapi.json
/swagger-ui/
用于ICP代币;v2支持游标分页
指标API
https://metrics-api.internetcomputer.org
/api/v1/openapi.json
/api/v1/docs
v1(无更新版本)
规范与UI的完整链接:

How It Works

使用方法

  1. Prefer v2+ APIs with cursor pagination. IC API v4 (
    /api/v4/canisters
    ,
    /api/v4/subnets
    ), ICRC API v2 (
    /api/v2/ledgers
    ,
    /api/v2/ledgers/{id}/transactions
    , etc.), and SNS API v2 (
    /api/v2/snses
    ,
    /api/v2/snses/{id}/proposals
    ,
    /api/v2/snses/{id}/neurons
    ) use
    after
    ,
    before
    , and
    limit
    for stable, efficient paging. Avoid v1/offset-based endpoints when a v2+ alternative exists.
  2. Choose the right API for the data you need: IC API (canisters, subnets, NNS neurons/proposals), Ledger API for mainnet ICP (accounts, transactions, supply), ICRC API for other ICRC ledgers only (ckBTC, SNS tokens, testicp — ICRC API does not expose mainnet ICP), SNS API (SNS list, neurons, proposals), Metrics API (governance, cycles, Bitcoin, etc.).
  3. Use the OpenAPI spec to get exact path, query, and body schemas and response shapes; prefer the spec over hand-written docs to avoid drift.
  4. Call over HTTPS with
    GET
    (or documented method). Use the
    next_cursor
    /
    previous_cursor
    from v2+ responses to request the next or previous page.
  1. 优先使用支持游标分页的v2+版本API。IC API v4(
    /api/v4/canisters
    /api/v4/subnets
    )、ICRC API v2(
    /api/v2/ledgers
    /api/v2/ledgers/{id}/transactions
    等)以及SNS API v2(
    /api/v2/snses
    /api/v2/snses/{id}/proposals
    /api/v2/snses/{id}/neurons
    )使用
    after
    before
    limit
    实现稳定、高效的分页。当存在v2+替代接口时,避免使用v1/基于偏移量的端点。
  2. 根据需求选择正确的API:IC API(canister、子网、NNS神经元/提案)、账本API用于主网ICP(账户、交易、供应量)、ICRC API仅用于其他ICRC账本(ckBTC、SNS代币、testicp——ICRC API不暴露主网ICP)、SNS API(SNS列表、神经元、提案)、指标API(治理、cycles、比特币等)。
  3. 使用OpenAPI规范获取准确的路径、查询参数、请求体schema以及响应结构;优先使用规范而非手写文档,避免出现内容偏差。
  4. 通过HTTPS调用,使用
    GET
    (或文档中指定的方法)。使用v2+响应中的
    next_cursor
    /
    previous_cursor
    请求下一页或上一页数据。

Mistakes That Break Your Build

会导致构建失败的常见错误

  1. Wrong base URL or API version. IC API uses
    /api/v3/
    (and v4 for canisters/subnets); ICRC has
    /api/v1/
    and
    /api/v2/
    (ICRC API does not serve mainnet ICP — use Ledger API). Ledger API uses unversioned paths for some endpoints (e.g.
    /accounts
    ,
    /supply/total/latest
    ) and
    /v2/
    for cursor-paginated lists. Metrics API uses
    /api/v1/
    . Using the wrong prefix returns 404 or wrong schema.
  2. Canister ID format. Canister IDs in paths and queries must match the principal-like pattern: 27 characters, five groups of five plus a final three (e.g.
    ryjl3-tyaaa-aaaaa-aaaba-cai
    ). Subnet IDs use the longer pattern (e.g. 63 chars). Sending a raw principal string in the wrong encoding or length causes 422 or 400.
  3. Using ICRC API for mainnet ICP. ICRC API exposes test ICP (TestICP) only, not mainnet ICP. For mainnet ICP token data (accounts, transactions, supply) use Ledger API (
    ledger-api.internetcomputer.org
    ). Use ICRC API for other ICRC ledgers (e.g. ckBTC, SNS tokens) and for TestICP.
  4. ICRC API: ledger_canister_id in path. ICRC endpoints require
    ledger_canister_id
    in the path (e.g.
    /api/v2/ledgers/{ledger_canister_id}/transactions
    ). Use the canister ID of the ledger you want (e.g. ckBTC
    mxzaz-hqaaa-aaaar-qaada-cai
    ). Do not use ICRC API for mainnet ICP — use Ledger API instead.
  5. Using v1 or offset-based pagination when v2+ exists. Always prefer v2 or higher endpoints that support cursor pagination (
    after
    ,
    before
    ,
    limit
    ). IC API v4 (canisters, subnets), ICRC API v2 (ledgers, accounts, transactions), and SNS API v2 (snses, proposals, neurons) return
    next_cursor
    /
    previous_cursor
    and accept cursor query params. Older v1/offset/
    max_*_index
    endpoints are legacy; using the wrong pagination model returns empty or incorrect pages.
  6. Timestamps. Most time-range query params (
    start
    ,
    end
    ) expect Unix seconds (integer). Sending milliseconds or ISO strings causes validation errors (422).
  7. Account identifier format. Ledger API and ICRC/ICP endpoints use account identifiers (hex hashes), not raw principals, for account-specific paths. Use the same encoding the API documents (e.g. 64-char hex for account_identifier where required).
  8. Assuming authentication. These public dashboard APIs do not require API keys or auth for the documented read endpoints. If you get 401/403, confirm you are not hitting a different environment or a write endpoint that requires auth.
  1. 错误的基础URL或API版本。IC API使用
    /api/v3/
    (canister/子网使用v4);ICRC API有
    /api/v1/
    /api/v2/
    (ICRC API不提供主网ICP数据——请使用账本API)。账本API的部分端点使用无版本路径(如
    /accounts
    /supply/total/latest
    ),而游标分页列表使用
    /v2/
    。指标API使用
    /api/v1/
    。使用错误的前缀会返回404或错误的schema。
  2. Canister ID格式错误。路径和查询参数中的Canister ID必须符合类似主体的格式:27个字符,分为五组各五个字符加最后三个字符(例如
    ryjl3-tyaaa-aaaaa-aaaba-cai
    )。子网ID使用更长的格式(例如63个字符)。发送编码错误或长度不符的原始主体字符串会导致422或400错误。
  3. 使用ICRC API获取主网ICP数据。ICRC API仅暴露测试ICP(TestICP),不包含主网ICP。如需获取主网ICP代币数据(账户、交易、供应量),请使用账本API
    ledger-api.internetcomputer.org
    )。ICRC API适用于其他ICRC账本(如ckBTC、SNS代币)和TestICP。
  4. ICRC API:路径中缺少ledger_canister_id。ICRC端点要求路径中包含
    ledger_canister_id
    (例如
    /api/v2/ledgers/{ledger_canister_id}/transactions
    )。请使用目标账本的canister ID(如ckBTC的
    mxzaz-hqaaa-aaaar-qaada-cai
    )。不要使用ICRC API获取主网ICP数据——请改用账本API。
  5. 当存在v2+版本时仍使用v1或基于偏移量的分页。始终优先选择支持游标分页(
    after
    before
    limit
    )的v2或更高版本端点。IC API v4(canister、子网)、ICRC API v2(账本、账户、交易)以及SNS API v2(SNS、提案、神经元)会返回
    next_cursor
    /
    previous_cursor
    并接受游标查询参数。旧版v1/基于偏移量/
    max_*_index
    端点已过时;使用错误的分页模型会返回空页或错误数据。
  6. 时间戳格式错误。大多数时间范围查询参数(
    start
    end
    )要求使用Unix秒数(整数)。发送毫秒数或ISO字符串会导致验证错误(422)。
  7. 账户标识符格式错误。账本API和ICRC/ICP端点在账户相关路径中使用账户标识符(十六进制哈希),而非原始主体。请使用API文档中指定的编码格式(如要求的64字符十六进制账户标识符)。
  8. 错误假设需要认证。这些公开仪表盘API的文档中列出的只读端点不需要API密钥或认证。如果收到401/403错误,请确认你没有访问错误环境或需要认证的写入端点。

Implementation

实现示例

IC API — Canisters and subnets (prefer v4 with cursor pagination)

IC API — Canister与子网(优先使用支持游标分页的v4版本)

bash
undefined
bash
undefined

List canisters (v4: cursor pagination, next_cursor/previous_cursor in response)

列出canister(v4:游标分页,响应中包含next_cursor/previous_cursor)

Next page: use after= from previous response's next_cursor (see OpenAPI for cursor format)

下一页:使用上一次响应中next_cursor的after=值(请查看OpenAPI了解游标格式)

Get one canister by ID (v3; no v4 single-canister endpoint)

通过ID获取单个canister(v3;无v4版本的单个canister端点)

List subnets (v4: cursor pagination)

列出子网(v4:游标分页)

List NNS proposals (v3; use limit)

列出NNS提案(v3;使用limit参数)

ICRC API — Other ICRC ledgers only (v2 with cursor pagination)

ICRC API — 仅适用于其他ICRC账本(支持游标分页的v2版本)

ICRC API exposes TestICP and other ICRC ledgers (e.g. ckBTC, SNS tokens), not mainnet ICP. For mainnet ICP use Ledger API.
bash
undefined
ICRC API仅暴露TestICP和其他ICRC账本(如ckBTC、SNS代币),不包含主网ICP。如需主网ICP数据请使用账本API。
bash
undefined

List ledgers (v2: after/before/limit, next_cursor/previous_cursor in response)

列出账本(v2:支持after/before/limit,响应中包含next_cursor/previous_cursor)

Get one ledger (e.g. ckBTC — mainnet ICP is not on ICRC API)

获取单个账本(如ckBTC — 主网ICP不在ICRC API中)

List transactions for a ledger (v2: cursor pagination)

列出某个账本的交易记录(v2:游标分页)

List accounts for a ledger (v2: after/before/limit)

列出某个账本的账户(v2:支持after/before/limit)

SNS API — SNS list and proposals (prefer v2 with cursor pagination)

SNS API — SNS列表与提案(优先使用支持游标分页的v2版本)

bash
undefined
bash
undefined

List SNSes (v2: after/before/limit, next_cursor/previous_cursor)

列出SNS(v2:支持after/before/limit,响应中包含next_cursor/previous_cursor)

List proposals for an SNS root canister (v2: cursor pagination)

列出某个SNS根canister的提案(v2:游标分页)

Replace ROOT_CANISTER_ID with a real SNS root canister ID

将ROOT_CANISTER_ID替换为真实的SNS根canister ID

List neurons for an SNS (v2: after/before/limit)

列出某个SNS的神经元(v2:支持after/before/limit)

Ledger API — Mainnet ICP token (prefer v2 for cursor pagination)

账本API — 主网ICP代币(优先使用支持游标分页的v2版本)

bash
undefined
bash
undefined

List accounts (v2: after/before/limit, next_cursor/prev_cursor)

列出账户(v2:支持after/before/limit,响应中包含next_cursor/prev_cursor)

Get account by account_identifier (64-char hex)

通过account_identifier(64字符十六进制)获取账户

List transactions (v2: cursor pagination)

列出交易记录(v2:游标分页)

Total supply (latest)

总供应量(最新数据)

Metrics API

指标API

bash
undefined
bash
undefined

Average cycle burn rate

平均cycle消耗率

Governance metrics

治理指标

ICP/XDR conversion rates (with optional start/end/step)

ICP/XDR兑换率(可选start/end/step参数)

Fetching OpenAPI spec (for codegen or validation)

获取OpenAPI规范(用于代码生成或验证)

bash
undefined
bash
undefined

IC API v3

IC API v3

ICRC API

ICRC API

SNS API

SNS API

Ledger API

账本API

Metrics API v1

指标API v1

undefined
undefined

Deploy & Test

部署与测试

No canister deployment is required. These are external HTTP APIs. Test from the shell or your app:
bash
undefined
无需部署canister。这些是外部HTTP API。可通过Shell或你的应用进行测试:
bash
undefined

Smoke test: IC API root

冒烟测试:IC API根路径

curl -s -o /dev/null -w "%{http_code}" "https://ic-api.internetcomputer.org/api/v3/"
curl -s -o /dev/null -w "%{http_code}" "https://ic-api.internetcomputer.org/api/v3/"

Expected: 200

预期结果:200

Smoke test: ICRC ledgers list

冒烟测试:ICRC账本列表

curl -s -o /dev/null -w "%{http_code}" "https://icrc-api.internetcomputer.org/api/v2/ledgers?limit=1"
curl -s -o /dev/null -w "%{http_code}" "https://icrc-api.internetcomputer.org/api/v2/ledgers?limit=1"

Expected: 200

预期结果:200

undefined
undefined

Verify It Works

验证功能正常

bash
undefined
bash
undefined

1. IC API returns canister list with data array

1. IC API返回包含data数组的canister列表

Expected: JSON with "data" or similar key and at least one canister

预期结果:包含"data"或类似键且至少有一个canister的JSON

2. ICRC API returns ledger list

2. ICRC API返回账本列表

Expected: JSON with "data" and ledger entries

预期结果:包含"data"和账本条目的JSON

3. Ledger API returns supply (array of [timestamp, value])

3. 账本API返回供应量(包含[时间戳, 数值]的数组)

Expected: JSON array with two elements (timestamp and supply string)

预期结果:包含两个元素的JSON数组(时间戳和供应量字符串)

4. OpenAPI specs are valid JSON

4. OpenAPI规范是有效的JSON

curl -s "https://ic-api.internetcomputer.org/api/v3/openapi.json" | python3 -c "import sys,json; json.load(sys.stdin); print('OK')"
curl -s "https://ic-api.internetcomputer.org/api/v3/openapi.json" | python3 -c "import sys,json; json.load(sys.stdin); print('OK')"

Expected: OK

预期结果:OK

undefined
undefined