ic-dashboard
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIC 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 (, , ) and are the same surface the dashboard uses.
afterbeforelimit这些公开REST API为dashboard.internetcomputer.org提供支持,通过OpenAPI规范和Swagger UI提供对canister元数据、ICRC账本、SNS数据、ICP账本以及网络指标的只读访问权限。Agent和脚本可以通过HTTPS从链下调用这些API(无需部署canister或消耗cycles)。优先使用v2或更高版本的API(如果有可用版本);这些版本支持基于游标分页(、、),与仪表盘使用的接口一致。
afterbeforelimitPrerequisites
前置条件
- Any HTTP client: ,
curl,fetch, or the language’s native HTTP library.axios - No or canister deployment needed for read-only API access.
icp-cli - For OpenAPI-based codegen: optional use of the URLs with your preferred OpenAPI tooling.
openapi.json
- 任意HTTP客户端:、
curl、fetch或编程语言原生的HTTP库。axios - 只读API访问无需或部署canister。
icp-cli - 基于OpenAPI的代码生成:可选择将链接与你偏好的OpenAPI工具配合使用。
openapi.json
API Base URLs and Docs
API基础地址与文档
| API | Base URL | OpenAPI spec | Swagger / Docs | Prefer |
|---|---|---|---|---|
| IC API | | | | v4 for canisters, subnets (cursor pagination) |
| ICRC API | | | | v2 for ledgers (TestICP and other ICRC tokens; not mainnet ICP) |
| SNS API | | | | v2 for snses, proposals, neurons |
| Ledger API (mainnet ICP) | | | | Use for ICP token; v2 for cursor pagination |
| Metrics API | | | | v1 (no newer version) |
Full URLs for specs and UI:
- IC API: https://ic-api.internetcomputer.org/api/v3/openapi.json — https://ic-api.internetcomputer.org/api/v3/swagger
- ICRC API: https://icrc-api.internetcomputer.org/openapi.json — https://icrc-api.internetcomputer.org/docs
- SNS API: https://sns-api.internetcomputer.org/openapi.json — https://sns-api.internetcomputer.org/docs
- Ledger API: https://ledger-api.internetcomputer.org/openapi.json — https://ledger-api.internetcomputer.org/swagger-ui/
- Metrics API: https://metrics-api.internetcomputer.org/api/v1/openapi.json — https://metrics-api.internetcomputer.org/api/v1/docs
| API | 基础URL | OpenAPI规范 | Swagger / 文档 | 优先版本 |
|---|---|---|---|---|
| IC API | | | | v4(用于canister、子网,支持游标分页) |
| ICRC API | | | | v2(用于账本,包括TestICP和其他ICRC代币;不包含主网ICP) |
| SNS API | | | | v2(用于SNS、提案、神经元) |
| 账本API(主网ICP) | | | | 用于ICP代币;v2支持游标分页 |
| 指标API | | | | v1(无更新版本) |
规范与UI的完整链接:
- IC API: https://ic-api.internetcomputer.org/api/v3/openapi.json — https://ic-api.internetcomputer.org/api/v3/swagger
- ICRC API: https://icrc-api.internetcomputer.org/openapi.json — https://icrc-api.internetcomputer.org/docs
- SNS API: https://sns-api.internetcomputer.org/openapi.json — https://sns-api.internetcomputer.org/docs
- 账本API: https://ledger-api.internetcomputer.org/openapi.json — https://ledger-api.internetcomputer.org/swagger-ui/
- 指标API: https://metrics-api.internetcomputer.org/api/v1/openapi.json — https://metrics-api.internetcomputer.org/api/v1/docs
How It Works
使用方法
- Prefer v2+ APIs with cursor pagination. IC API v4 (,
/api/v4/canisters), ICRC API v2 (/api/v4/subnets,/api/v2/ledgers, etc.), and SNS API v2 (/api/v2/ledgers/{id}/transactions,/api/v2/snses,/api/v2/snses/{id}/proposals) use/api/v2/snses/{id}/neurons,after, andbeforefor stable, efficient paging. Avoid v1/offset-based endpoints when a v2+ alternative exists.limit - 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.).
- 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.
- Call over HTTPS with (or documented method). Use the
GET/next_cursorfrom v2+ responses to request the next or previous page.previous_cursor
- 优先使用支持游标分页的v2+版本API。IC API v4(、
/api/v4/canisters)、ICRC API v2(/api/v4/subnets、/api/v2/ledgers等)以及SNS API v2(/api/v2/ledgers/{id}/transactions、/api/v2/snses、/api/v2/snses/{id}/proposals)使用/api/v2/snses/{id}/neurons、after和before实现稳定、高效的分页。当存在v2+替代接口时,避免使用v1/基于偏移量的端点。limit - 根据需求选择正确的API:IC API(canister、子网、NNS神经元/提案)、账本API用于主网ICP(账户、交易、供应量)、ICRC API仅用于其他ICRC账本(ckBTC、SNS代币、testicp——ICRC API不暴露主网ICP)、SNS API(SNS列表、神经元、提案)、指标API(治理、cycles、比特币等)。
- 使用OpenAPI规范获取准确的路径、查询参数、请求体schema以及响应结构;优先使用规范而非手写文档,避免出现内容偏差。
- 通过HTTPS调用,使用(或文档中指定的方法)。使用v2+响应中的
GET/next_cursor请求下一页或上一页数据。previous_cursor
Mistakes That Break Your Build
会导致构建失败的常见错误
-
Wrong base URL or API version. IC API uses(and v4 for canisters/subnets); ICRC has
/api/v3/and/api/v1/(ICRC API does not serve mainnet ICP — use Ledger API). Ledger API uses unversioned paths for some endpoints (e.g./api/v2/,/accounts) and/supply/total/latestfor cursor-paginated lists. Metrics API uses/v2/. Using the wrong prefix returns 404 or wrong schema./api/v1/ -
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.). 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.
ryjl3-tyaaa-aaaaa-aaaba-cai -
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 (). Use ICRC API for other ICRC ledgers (e.g. ckBTC, SNS tokens) and for TestICP.
ledger-api.internetcomputer.org -
ICRC API: ledger_canister_id in path. ICRC endpoints requirein the path (e.g.
ledger_canister_id). Use the canister ID of the ledger you want (e.g. ckBTC/api/v2/ledgers/{ledger_canister_id}/transactions). Do not use ICRC API for mainnet ICP — use Ledger API instead.mxzaz-hqaaa-aaaar-qaada-cai -
Using v1 or offset-based pagination when v2+ exists. Always prefer v2 or higher endpoints that support cursor pagination (,
after,before). IC API v4 (canisters, subnets), ICRC API v2 (ledgers, accounts, transactions), and SNS API v2 (snses, proposals, neurons) returnlimit/next_cursorand accept cursor query params. Older v1/offset/previous_cursorendpoints are legacy; using the wrong pagination model returns empty or incorrect pages.max_*_index -
Timestamps. Most time-range query params (,
start) expect Unix seconds (integer). Sending milliseconds or ISO strings causes validation errors (422).end -
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).
-
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.
-
错误的基础URL或API版本。IC API使用(canister/子网使用v4);ICRC API有
/api/v3/和/api/v1/(ICRC API不提供主网ICP数据——请使用账本API)。账本API的部分端点使用无版本路径(如/api/v2/、/accounts),而游标分页列表使用/supply/total/latest。指标API使用/v2/。使用错误的前缀会返回404或错误的schema。/api/v1/ -
Canister ID格式错误。路径和查询参数中的Canister ID必须符合类似主体的格式:27个字符,分为五组各五个字符加最后三个字符(例如)。子网ID使用更长的格式(例如63个字符)。发送编码错误或长度不符的原始主体字符串会导致422或400错误。
ryjl3-tyaaa-aaaaa-aaaba-cai -
使用ICRC API获取主网ICP数据。ICRC API仅暴露测试ICP(TestICP),不包含主网ICP。如需获取主网ICP代币数据(账户、交易、供应量),请使用账本API()。ICRC API适用于其他ICRC账本(如ckBTC、SNS代币)和TestICP。
ledger-api.internetcomputer.org -
ICRC API:路径中缺少ledger_canister_id。ICRC端点要求路径中包含(例如
ledger_canister_id)。请使用目标账本的canister ID(如ckBTC的/api/v2/ledgers/{ledger_canister_id}/transactions)。不要使用ICRC API获取主网ICP数据——请改用账本API。mxzaz-hqaaa-aaaar-qaada-cai -
当存在v2+版本时仍使用v1或基于偏移量的分页。始终优先选择支持游标分页(、
after、before)的v2或更高版本端点。IC API v4(canister、子网)、ICRC API v2(账本、账户、交易)以及SNS API v2(SNS、提案、神经元)会返回limit/next_cursor并接受游标查询参数。旧版v1/基于偏移量/previous_cursor端点已过时;使用错误的分页模型会返回空页或错误数据。max_*_index -
时间戳格式错误。大多数时间范围查询参数(、
start)要求使用Unix秒数(整数)。发送毫秒数或ISO字符串会导致验证错误(422)。end -
账户标识符格式错误。账本API和ICRC/ICP端点在账户相关路径中使用账户标识符(十六进制哈希),而非原始主体。请使用API文档中指定的编码格式(如要求的64字符十六进制账户标识符)。
-
错误假设需要认证。这些公开仪表盘API的文档中列出的只读端点不需要API密钥或认证。如果收到401/403错误,请确认你没有访问错误环境或需要认证的写入端点。
Implementation
实现示例
IC API — Canisters and subnets (prefer v4 with cursor pagination)
IC API — Canister与子网(优先使用支持游标分页的v4版本)
bash
undefinedbash
undefinedList 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参数)
undefinedundefinedICRC 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
undefinedICRC API仅暴露TestICP和其他ICRC账本(如ckBTC、SNS代币),不包含主网ICP。如需主网ICP数据请使用账本API。
bash
undefinedList 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
undefinedbash
undefinedList 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)
undefinedLedger API — Mainnet ICP token (prefer v2 for cursor pagination)
账本API — 主网ICP代币(优先使用支持游标分页的v2版本)
bash
undefinedbash
undefinedList 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)
总供应量(最新数据)
undefinedundefinedMetrics API
指标API
bash
undefinedbash
undefinedAverage cycle burn rate
平均cycle消耗率
Governance metrics
治理指标
ICP/XDR conversion rates (with optional start/end/step)
ICP/XDR兑换率(可选start/end/step参数)
undefinedFetching OpenAPI spec (for codegen or validation)
获取OpenAPI规范(用于代码生成或验证)
bash
undefinedbash
undefinedIC API v3
IC API v3
curl -s "https://ic-api.internetcomputer.org/api/v3/openapi.json" -o ic-api-v3.json
curl -s "https://ic-api.internetcomputer.org/api/v3/openapi.json" -o ic-api-v3.json
ICRC API
ICRC API
curl -s "https://icrc-api.internetcomputer.org/openapi.json" -o icrc-api.json
curl -s "https://icrc-api.internetcomputer.org/openapi.json" -o icrc-api.json
SNS API
SNS API
curl -s "https://sns-api.internetcomputer.org/openapi.json" -o sns-api.json
curl -s "https://sns-api.internetcomputer.org/openapi.json" -o sns-api.json
Ledger API
账本API
curl -s "https://ledger-api.internetcomputer.org/openapi.json" -o ledger-api.json
curl -s "https://ledger-api.internetcomputer.org/openapi.json" -o ledger-api.json
Metrics API v1
指标API v1
curl -s "https://metrics-api.internetcomputer.org/api/v1/openapi.json" -o metrics-api-v1.json
undefinedcurl -s "https://metrics-api.internetcomputer.org/api/v1/openapi.json" -o metrics-api-v1.json
undefinedDeploy & 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
undefinedSmoke 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
undefinedundefinedVerify It Works
验证功能正常
bash
undefinedbash
undefined1. IC API returns canister list with data array
1. IC API返回包含data数组的canister列表
curl -s "https://ic-api.internetcomputer.org/api/v3/canisters?limit=1" | head -c 200
curl -s "https://ic-api.internetcomputer.org/api/v3/canisters?limit=1" | head -c 200
Expected: JSON with "data" or similar key and at least one canister
预期结果:包含"data"或类似键且至少有一个canister的JSON
2. ICRC API returns ledger list
2. ICRC API返回账本列表
curl -s "https://icrc-api.internetcomputer.org/api/v2/ledgers?limit=1" | head -c 200
curl -s "https://icrc-api.internetcomputer.org/api/v2/ledgers?limit=1" | head -c 200
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
undefinedundefined