開発者へ / アプリケーション API

エクスプローラー API

ノードが意図的にそうではないアーカイブです。履歴のすべてを保持し、このチェーンで呼び出しトレースを持つ唯一の面であり、最も強い意味で読み取り専用です。POST はどれも 405 になります。

なぜこれが存在するか

ノードが保持する履歴の窓は短く、およそ 2 分ぶんのブロックです。その外側へのクエリは エラーではなく null を返します。これは意図的な取引です。現在を速く提供し、 過去はそのために作られたものに委ねる。このサービスがその「もの」です。シーケンサーは すべてのログを進みながら Postgres へ写し、この API はそのインデックスを読みます。

だから、ここでしか答えられない問いが二つあります。

  • ノードの窓より古いすべて。今朝のトランザクション、先週のブロック、 あるトークンの転送の歴史のすべて。
  • 呼び出しトレース。ノードは debug 名前空間をまったく 公開しないので、トランザクションの内部呼び出しを見られるのはこのチェーンで GET /tx/{hash} だけです。
これはインデックスであって、二台目のノードではありません

いくつかのルートのいくつかのフィールドは、リクエストを処理する時点でノードから生で 読まれます。残高、ネームサービスのレコード、コントラクトの探り、インデックスがまだ 追いついていないブロックのミニブロックなどです。ノードに届かないときそれらは null か 欠落として返り、残りの答えはインデックスから提供されます。だから部分的な答えは正常で あり、エラーにはなりません。

ベース URL と CORS

エンドポイントValue
公開https://explorer.picklechain.xyz/api/ネームサービスとツールキットのサイトでも /api/ にマウントされています
自分で動かすスタックhttp://127.0.0.1:4010サービス自身のポート。同梱の compose ファイルではコンテナネットワークの外に公開されません
CORS許可リストOPTIONS は GET と OPTIONS を許可して 204 を返し、リストにない Origin は 403 で拒否されます

チェーン

ブロック、ミニブロック、トランザクション、そして手数料の分配。

Params
none
戻り値
a flat object of counters

Chain-wide counters: block and transaction totals, wallets, gas used, the cadence figures the node reports, the mini-block head, index lag and the spool's own health.

こちらでも。 GET /

知っておくとよいこと。 Recomputed once a second by a background thread and served from a cache for six tenths of a second, so two calls in the same instant give the same answer. It also carries a rate counter this reference does not quote: the site publishes no throughput figure, and the number is local anyway.

Params
none
戻り値
{stats, charts, blocks, txs, topAccounts}

The explorer's front page in one call: the cached stats, 48 chart points, the 8 most recent blocks that carried transactions, 12 transactions and the 8 busiest accounts.

知っておくとよいこと。 Use this instead of five calls. Its parts are the other routes' defaults and nothing about it is configurable.

Params
limit (default 48, clamped to 200)
戻り値
[{number, timestamp, txCount, gasUsed}]

A bare array, oldest first.

知っておくとよいこと。 It prefers blocks that carried transactions and falls back to all blocks only when fewer than four match, so the series is not evenly spaced in time and must not be read as one.

Params
limit, offset, active=1
戻り値
[{number, hash, timestamp, gasUsed, txCount, miniCount}]

A bare array, newest first. `active=1` returns only blocks that carried transactions.

知っておくとよいこと。 No total is returned, so there is nothing to page against except asking until you get a short answer.

Params
limit, offset over the block's transactions
戻り値
one block with its transactions and mini-blocks

The number is parsed permissively: decimal and 0x both work.

知っておくとよいこと。 `limit` defaults to 50 here rather than 25, and the mini-blocks fall back to a live read against the node when the index has none for the block. 404 when unknown.

Params
limit, offset
戻り値
{total, minis: [...]}

Mini-blocks, newest first. One of the few routes that does return a total.

知っておくとよいこと。 Timestamps are `timestamp_us`: MICROSECONDS, not seconds, and a decimal number rather than a hex quantity.

Params
limit, offset over the transactions
戻り値
one mini-block

By decimal number or by hash.

知っておくとよいこと。 When the index does not have it, the service asks the node - and the answer then ALSO carries `stateDiffHash`, `sequencerSig` and `receipts`, which the indexed answer does not. The shape depends on where it was found.

/txs

GET
Params
limit, offset
戻り値
a bare array, newest first

Transaction summaries.

知っておくとよいこと。 No total.

Params
none
戻り値
the full transaction

The richest object in the API: input data, the decoded method for known selectors, logs with labelled addresses, CALL TRACES, token transfers and NFT transfers.

知っておくとよいこと。 The traces are the reason this route exists. The node exposes no debug namespace at all, so there is nowhere else on this chain to get them. 404 when unknown.

Params
none
戻り値
{deployed, router, split, burn, launches, arcadeSkims, deferred, claimed, pendingEthWei, ...}

Everything the fee split has done and everything still waiting, read from the log spool rather than over RPC.

知っておくとよいこと。 `{"deployed": false}` and NOTHING ELSE when the fee layer is not in the manifest - that is an ordinary state, not an error, because that layer is deployed by hand. The ether side and the token side are kept as separate figures and never summed.

アカウント

誰が取引したか、そして一つのアドレスについて分かるすべて。

Params
limit, offset
戻り値
{total, accounts: [...]}

Accounts ordered by how much they have transacted.

知っておくとよいこと。 The ordering is by transaction count, not by balance.

Params
limit, offset over the transaction lists
戻り値
the largest payload in the service

Balance, nonce, counts, whether it is a contract, its creator and what it created, token and NFT holdings with metadata, the name-service record, and recent transactions and transfers.

知っておくとよいこと。 `bytecode` is TRUNCATED to 400 hex characters with an ellipsis appended; `bytecodeSize` is the real length. The whole answer is cached for a few seconds under a key that includes the paging, so two different pages are two different cache entries.

トークン、NFT、名前

レジストリと突き合わせたメタデータと、唯一 JSON ではないルート。

Params
none
戻り値
a list of at most 40 tokens

PKL pinned first, then by transfer count. Each entry merges a live probe of the contract with the operator's registry entry.

知っておくとよいこと。 Forty is a hard cap and there is no paging past it. An address that probes as an NFT is skipped even if the registry calls it a token.

Params
none
戻り値
{nfts: [...]}

At most 40 collections, verified ones first, then by how many have been minted.

知っておくとよいこと。 The collection list is DISCOVERED from transfer logs rather than registered, so a collection nobody has traded is absent.

Params
limit, clamped to 48
戻り値
the collection, its items and its 30 most recent transfers

Collection metadata merged from the chain and the registry.

知っておくとよいこと。 Items are fetched one at a time up to the clamp, and off-chain metadata is resolved by a BACKGROUND thread - so the first request for a cold collection returns items whose metadata is still missing, and a second request a moment later returns more. Held for fifteen seconds in a cache of its own.

Params
none
戻り値
one item plus `collectionMeta`

One token of a collection.

知っておくとよいこと。 The token id must be all digits, or the path does not match this route at all and you get the 404 for an unknown route.

Params
none
戻り値
{name, label, available, reserved, owner, resolved, expires, price, twitter, website, description}

A name-service lookup, read live from the registry contract.

知っておくとよいこと。 A trailing suffix is stripped, and the label must be 3 to 32 characters. A name outside that range, and any lookup at all when the name service is not configured, is a 404 - which is indistinguishable from a name that does not exist.

Params
none
戻り値
raw image bytes

The only non-JSON, non-stream route. The content type is inferred from the stored file's extension.

知っておくとよいこと。 404 as JSON when there is no logo, so a client must check the status before treating the body as an image.

ライブと、GET ではない二つの動詞

イベントのストリーム、プリフライト、そして 405。

Params
none
戻り値
text/event-stream, one stats frame per update

Server-sent events carrying the same object /stats returns, pushed when it changes.

知っておくとよいこと。 Bounded to 32 concurrent streams - the 33rd gets 503 - and the server CLOSES every stream after five minutes. A client that does not reconnect simply stops receiving, with no error.

any

OPTIONS
Params
none
戻り値
204

The preflight. Allowed methods are GET and OPTIONS, allowed header is Content-Type.

知っておくとよいこと。 403 when an Origin is present and not on the allowlist, rather than a 204 without the allow header.

any

POST
Params
none
戻り値
405

This API is read-only and answers 405 to every POST, in JSON and with the CORS headers.

知っておくとよいこと。 It had one write route: a token-metadata edit signed by the contract's owner. It is gone, along with the form that called it, because an explorer that takes visitor-supplied identity for an asset is an impersonation surface.

制限、ページング、キャッシュ

制限Value
Request rate300 per minute per client addressthen 429; the window is wall-clock and resets on the minute
Client identitythe rightmost trusted X-Forwarded-For entryindexed from the right by the number of trusted proxy hops, because the leftmost entry is whatever the client wrote
Request body600,000 bytesthere is nothing to POST, but the cap exists
List paginglimit <= 100, offset >= 0a non-numeric limit silently becomes the default rather than erroring
Live streams32 concurrent, 300 seconds each503 above the first, silent close at the second
Answer cacheabout 3 secondson /address, /tokens, /nfts and the NFT routes; the stats cache is shorter

レート制限はクライアントのアドレスごとで、エクスプローラー自身のページとも共有されます

1 分あたり 300 リクエストは、人にとっては潤沢で、バックフィルにとっては細い数字です。 窓は実時計で、滑るのではなく分の変わり目でリセットされます。だから分の境目の一瞬に 集中させると、二つの窓ぶんを 2 秒で使い切り、あとは二つ目の窓が終わるまで 429 を 返し続けることになります。このサービスに retry-after のヘッダーはありません。 自分でバックオフしてください。

数え上げの基準になる同一性は、転送されたクライアントのアドレスで、連鎖の右端から読まれます。 左端の項目は呼び出し側が書いたものでしかないからです。追記しないプロキシの背後では、 すべての呼び出し側が一つのバケツに潰れ、インターネット全体が一つの予算を共有します。

ページングは limit と offset で、100 に切り詰められます。数値で ない limit はエラーではなく既定値になり、負の値は 1 になります。だから壊れたリクエストは 苦情ではなく、もっともらしい答えを受け取ります。ほとんどの一覧のルートは総数を返しません。/minis と /accounts が例外です。

応答は数秒間キャッシュされます

/address、/tokens、/nfts と NFT 系のルートは、 パスとページングをキーにした短命のキャッシュに保持され、/stats は背景の スレッドで再計算されてさらに短いキャッシュから提供されます。同じ瞬間の同一のリクエスト 二つは同一の答えを返します。ページにはそれでよく、確認のループには誤りです。レシートは これではなくノードに問い合わせてください。

新しさと遅れ

/stats は、インデックスがどれだけ最新かを述べる数値を運びます。latestBlock に対する indexedBlock、その差である indexLag、そして実体化ビューのための derivedLag です。トークンの 残高と NFT の所有は別のワーカーが作るので、元になったトランザクションから遅れることが あります。

bash
# Is the archive current? Compare the two, do not trust either alone.
curl -s "$EXPLORER_API/stats" | jq '{latestBlock, indexedBlock, indexLag, derivedLag}'

# One transaction, whole, traces included. This is the route with no substitute.
curl -s "$EXPLORER_API/tx/$HASH" | jq '{success, decoded, traces: (.traces|length), tokenTransfers}'

# Page an address's history by offset - and see the note below before relying on it.
curl -s "$EXPLORER_API/address/$ADDR?limit=100&offset=0" | jq '.transactions | length'

オフセットのページングは、伸びていく一覧の下でずれます

ここの一覧はどれも新しい順で、新しい行は先頭に届きます。だから 1 ページ目の直後に取った 2 ページ目はそれと重なり、歩いているあいだに行がまるごと飛ばされることもあります。完全で なければならないバックフィルでは、ブロック番号でページングして下へ進むか、一度に 1 ブロックずつ取ってください。offset はユーザーインターフェースのための ものであり、取り込みのためのものではありません。

何かにキーを付ける前に知っておくとよい非対称性がもう一つあります。このチェーンは logIndex をブロックごとではなくトランザクションごとに採番するので、(blockNumber, logIndex) の組は一意ではありません。組み立てるキーには トランザクションハッシュを含めてください。