Para desenvolvedores / APIs das aplicações

A API do explorador

O arquivo que o nó deliberadamente não é. Ele guarda todo o histórico, é a única superfície desta cadeia com rastros de chamadas, e é somente de leitura no sentido forte - todo POST dá 405.

Por que isto existe

O nó guarda uma janela curta de histórico - cerca de dois minutos de blocos - e uma consulta fora dela responde null em vez de um erro. É uma troca deliberada: ele serve o presente rápido e entrega o passado a algo construído para isso. Este serviço é esse algo. O sequenciador copia cada log para o Postgres à medida que anda, e esta API lê esse índice.

Duas perguntas encontram resposta aqui, e em nenhum outro lugar:

  • Tudo o que é mais antigo que a janela do nó. Uma transação desta manhã, um bloco da semana passada, todo o histórico de transferências de um token.
  • Os rastros de chamadas. O nó não expõe nenhum espaço de nomes debug, então GET /tx/{hash} é o único lugar nesta cadeia onde ver as chamadas internas de uma transação.
É um índice, não um segundo nó

Alguns campos de algumas rotas são lidos ao vivo do nó no momento em que a requisição é servida - um saldo, um registro do serviço de nomes, uma sondagem de contrato, os miniblocos de um bloco que o índice ainda não alcançou. Quando o nó está inalcançável, eles voltam nulos ou ausentes enquanto o resto da resposta é servido do índice: uma resposta parcial é portanto normal e não levanta erro.

URL de base e CORS

Ponto de acessoValue
Públicohttps://explorer.picklechain.xyz/api/também montada em /api/ pelos sites do serviço de nomes e da caixa de ferramentas
Uma pilha suahttp://127.0.0.1:4010a porta própria do serviço; ela não é publicada fora da rede de contêineres no arquivo compose entregue
CORSuma lista de permissõesOPTIONS responde 204 com GET e OPTIONS autorizados; uma Origin fora da lista é recusada com 403

A cadeia

Blocos, miniblocos, transações e a divisão das taxas.

Params
none
Retorno
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.

Também em. GET /

Vale saber. 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
Retorno
{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.

Vale saber. 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)
Retorno
[{number, timestamp, txCount, gasUsed}]

A bare array, oldest first.

Vale saber. 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
Retorno
[{number, hash, timestamp, gasUsed, txCount, miniCount}]

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

Vale saber. 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
Retorno
one block with its transactions and mini-blocks

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

Vale saber. `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
Retorno
{total, minis: [...]}

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

Vale saber. Timestamps are `timestamp_us`: MICROSECONDS, not seconds, and a decimal number rather than a hex quantity.

Params
limit, offset over the transactions
Retorno
one mini-block

By decimal number or by hash.

Vale saber. 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
Retorno
a bare array, newest first

Transaction summaries.

Vale saber. No total.

Params
none
Retorno
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.

Vale saber. 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
Retorno
{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.

Vale saber. `{"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.

As contas

Quem transacionou, e tudo o que se sabe de um endereço.

Params
limit, offset
Retorno
{total, accounts: [...]}

Accounts ordered by how much they have transacted.

Vale saber. The ordering is by transaction count, not by balance.

Params
limit, offset over the transaction lists
Retorno
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.

Vale saber. `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.

Tokens, NFTs e nomes

Metadados fundidos com o registro, e a única rota que não é JSON.

Params
none
Retorno
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.

Vale saber. 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
Retorno
{nfts: [...]}

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

Vale saber. The collection list is DISCOVERED from transfer logs rather than registered, so a collection nobody has traded is absent.

Params
limit, clamped to 48
Retorno
the collection, its items and its 30 most recent transfers

Collection metadata merged from the chain and the registry.

Vale saber. 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
Retorno
one item plus `collectionMeta`

One token of a collection.

Vale saber. 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
Retorno
{name, label, available, reserved, owner, resolved, expires, price, twitter, website, description}

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

Vale saber. 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
Retorno
raw image bytes

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

Vale saber. 404 as JSON when there is no logo, so a client must check the status before treating the body as an image.

O ao vivo, e os dois verbos que não são GET

O fluxo de eventos, o preflight, e o 405.

Params
none
Retorno
text/event-stream, one stats frame per update

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

Vale saber. 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
Retorno
204

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

Vale saber. 403 when an Origin is present and not on the allowlist, rather than a 204 without the allow header.

any

POST
Params
none
Retorno
405

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

Vale saber. 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.

Limites, paginação e caches

LimiteValue
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

O limite de taxa é por endereço de cliente, e é compartilhado com a própria página do explorador

Trezentas requisições por minuto é generoso para uma pessoa e magro para uma recuperação de histórico. A janela é de relógio de parede: ela se reinicia na virada do minuto em vez de deslizar, então uma rajada na virada pode gastar o equivalente a duas janelas em dois segundos e depois responder 429 por todo o resto da segunda. Não há cabeçalho retry-after neste serviço - recue você mesmo.

A identidade por trás da contagem é o endereço de cliente repassado, lido pela ponta direita da cadeia, porque a entrada mais à esquerda é o que quem chamou quis escrever. Atrás de um proxy que não acrescenta nada, todos os chamadores desabam num único balde e a internet inteira divide um só orçamento.

A paginação é limit e offset, travada em cem. Um limite não numérico vira o valor padrão em vez de um erro, e um limite negativo vira um - uma requisição malformada recebe portanto uma resposta plausível em vez de uma reclamação. A maioria das rotas de lista não devolve total; /minis e /accounts são as exceções.

As respostas ficam em cache por alguns segundos

/address, /tokens, /nfts e as rotas de NFT são mantidas num cache de curta duração indexado por caminho e paginação, e /stats é recalculado por uma linha de execução de fundo e servido de um cache mais curto ainda. Duas requisições idênticas no mesmo instante dão respostas idênticas, o que serve para uma página e não serve para um laço de confirmação. Sonde o nó por um recibo, não isto.

Atualidade e atraso

/stats carrega os números que dizem o quanto o índice está em dia: indexedBlock contra latestBlock, indexLag como diferença, e derivedLag para as visões materializadas - os saldos de tokens e a propriedade dos NFTs são construídos por trabalhadores separados e podem ficar atrás das transações de onde vêm.

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'

A paginação por offset desliza sob uma lista que cresce

Toda lista aqui vai do mais recente ao mais antigo, e as linhas novas chegam pela cabeça. A página dois, buscada um instante depois da página um, sobrepõe-se a ela - e linhas podem ser puladas por inteiro enquanto você caminha. Para uma recuperação de histórico que precisa ser completa, pagine por número de bloco descendo, ou busque um bloco por vez; offset é para uma interface, não para um importador.

Uma última assimetria que vale conhecer antes de indexar o que quer que seja: esta cadeia enumera o logIndex por transação e não por bloco, então o par (blockNumber, logIndex) não é único. Inclua o hash da transação em qualquer chave que você construir.