Para desarrolladores / API de las aplicaciones
La API del explorador
El archivo que el nodo deliberadamente no es. Guarda toda la historia, es la única superficie de esta cadena con trazas de llamadas, y es de solo lectura en el sentido fuerte - todo POST es un 405.
Por qué existe
El nodo guarda una ventana corta de historia - unos dos minutos de bloques - y una consulta fuera de ella responde null en lugar de un error. Es un compromiso deliberado: sirve el presente deprisa y confía el pasado a algo construido para eso. Este servicio es ese algo. El secuenciador copia cada log en Postgres sobre la marcha, y esta API lee ese índice.
Así que dos preguntas encuentran aquí su respuesta, y en ningún otro sitio:
- Todo lo más antiguo que la ventana del nodo. Una transacción de esta mañana, un bloque de la semana pasada, todo el historial de transferencias de un token.
- Las trazas de llamadas. El nodo no expone ningún espacio de nombres
debug, así queGET /tx/{hash}es el único lugar de esta cadena donde ver las llamadas internas de una transacción.
Algunos campos de algunas rutas se leen en vivo desde el nodo en el momento de servir la petición - un saldo, un registro del servicio de nombres, una sonda de contrato, los minibloques de un bloque que el índice no ha alcanzado. Cuando el nodo es inalcanzable vuelven nulos o ausentes mientras el resto de la respuesta se sirve desde el índice: una respuesta parcial es, pues, normal y no levanta ningún error.
URL de base y CORS
| Punto de acceso | Value |
|---|---|
| Público | https://explorer.picklechain.xyz/api/también montada en /api/ por los sitios del servicio de nombres y de la caja de herramientas |
| Una pila propia | http://127.0.0.1:4010el puerto propio del servicio; no se publica fuera de la red de contenedores en el fichero compose que se entrega |
| CORS | una lista de permitidosOPTIONS responde 204 con GET y OPTIONS autorizados; un Origin que no esté en la lista se rechaza con 403 |
La cadena
Bloques, minibloques, transacciones y el reparto de comisiones.
/stats
GET- Params
- none
- Devuelve
- 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.
También en. GET /
Conviene saberlo. 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.
/overview
GET- Params
- none
- Devuelve
- {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.
Conviene saberlo. Use this instead of five calls. Its parts are the other routes' defaults and nothing about it is configurable.
/charts
GET- Params
- limit (default 48, clamped to 200)
- Devuelve
- [{number, timestamp, txCount, gasUsed}]
A bare array, oldest first.
Conviene saberlo. 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.
/blocks
GET- Params
- limit, offset, active=1
- Devuelve
- [{number, hash, timestamp, gasUsed, txCount, miniCount}]
A bare array, newest first. `active=1` returns only blocks that carried transactions.
Conviene saberlo. 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
- Devuelve
- one block with its transactions and mini-blocks
The number is parsed permissively: decimal and 0x both work.
Conviene saberlo. `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.
/minis
GET- Params
- limit, offset
- Devuelve
- {total, minis: [...]}
Mini-blocks, newest first. One of the few routes that does return a total.
Conviene saberlo. Timestamps are `timestamp_us`: MICROSECONDS, not seconds, and a decimal number rather than a hex quantity.
- Params
- limit, offset over the transactions
- Devuelve
- one mini-block
By decimal number or by hash.
Conviene saberlo. 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
- Devuelve
- a bare array, newest first
Transaction summaries.
Conviene saberlo. No total.
/tx/{hash}
GET- Params
- none
- Devuelve
- 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.
Conviene saberlo. 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.
/fees
GET- Params
- none
- Devuelve
- {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.
Conviene saberlo. `{"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.
Las cuentas
Quién ha transaccionado, y todo lo que se sabe de una dirección.
/accounts
GET- Params
- limit, offset
- Devuelve
- {total, accounts: [...]}
Accounts ordered by how much they have transacted.
Conviene saberlo. The ordering is by transaction count, not by balance.
- Params
- limit, offset over the transaction lists
- Devuelve
- 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.
Conviene saberlo. `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, NFT y nombres
Metadatos fusionados con el registro, y la única ruta que no es JSON.
/tokens
GET- Params
- none
- Devuelve
- 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.
Conviene saberlo. 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.
/nfts
GET- Params
- none
- Devuelve
- {nfts: [...]}
At most 40 collections, verified ones first, then by how many have been minted.
Conviene saberlo. The collection list is DISCOVERED from transfer logs rather than registered, so a collection nobody has traded is absent.
- Params
- limit, clamped to 48
- Devuelve
- the collection, its items and its 30 most recent transfers
Collection metadata merged from the chain and the registry.
Conviene saberlo. 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
- Devuelve
- one item plus `collectionMeta`
One token of a collection.
Conviene saberlo. 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.
/name/{name}
GET- Params
- none
- Devuelve
- {name, label, available, reserved, owner, resolved, expires, price, twitter, website, description}
A name-service lookup, read live from the registry contract.
Conviene saberlo. 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
- Devuelve
- raw image bytes
The only non-JSON, non-stream route. The content type is inferred from the stored file's extension.
Conviene saberlo. 404 as JSON when there is no logo, so a client must check the status before treating the body as an image.
El directo, y los dos verbos que no son GET
El flujo de eventos, el preflight y el 405.
/live
GET- Params
- none
- Devuelve
- text/event-stream, one stats frame per update
Server-sent events carrying the same object /stats returns, pushed when it changes.
Conviene saberlo. 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
- Devuelve
- 204
The preflight. Allowed methods are GET and OPTIONS, allowed header is Content-Type.
Conviene saberlo. 403 when an Origin is present and not on the allowlist, rather than a 204 without the allow header.
any
POST- Params
- none
- Devuelve
- 405
This API is read-only and answers 405 to every POST, in JSON and with the CORS headers.
Conviene saberlo. 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.
Límites, paginación y cachés
| Límite | Value |
|---|---|
| Request rate | 300 per minute per client addressthen 429; the window is wall-clock and resets on the minute |
| Client identity | the 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 body | 600,000 bytesthere is nothing to POST, but the cap exists |
| List paging | limit <= 100, offset >= 0a non-numeric limit silently becomes the default rather than erroring |
| Live streams | 32 concurrent, 300 seconds each503 above the first, silent close at the second |
| Answer cache | about 3 secondson /address, /tokens, /nfts and the NFT routes; the stats cache is shorter |
El límite de tasa es por dirección cliente, y se comparte con la propia página del explorador
Trescientas peticiones por minuto es generoso para una persona y escaso para una recuperación de historial. La ventana es de reloj de pared: se reinicia al minuto en lugar de deslizarse, así que una ráfaga en el cambio de minuto puede gastar dos ventanas en dos segundos y luego responder 429 durante todo el resto de la segunda. No hay cabecera retry-after en este servicio - espacie usted mismo los reintentos.
La identidad tras el contador es la dirección cliente transmitida, leída en el extremo derecho de la cadena porque la entrada más a la izquierda es lo que quien llama haya querido escribir. Detrás de un proxy que no añade nada, todos los que llaman se hunden en un solo cubo y todo internet comparte un presupuesto.
La paginación es limit y offset, acotada a cien. Un límite no numérico se convierte en el valor por defecto en lugar de en un error, y uno negativo se convierte en uno - así que una petición mal formada obtiene una respuesta plausible en lugar de una queja. La mayoría de las rutas de lista no devuelven total; /minis y /accounts son las excepciones.
/address, /tokens, /nfts y las rutas de NFT se mantienen en una caché de vida corta indexada por ruta y paginación, y /stats se recalcula en un hilo de fondo y se sirve desde una caché aún más corta. Dos peticiones idénticas en el mismo instante dan respuestas idénticas, lo que está bien para una página y mal para un bucle de confirmación. Sondee el nodo para un recibo, no esto.
Frescura y retraso
/stats lleva los números que dicen hasta qué punto el índice está al día: indexedBlock frente a latestBlock, indexLag como la diferencia, y derivedLag para las vistas materializadas - los saldos de tokens y la propiedad de los NFT los construyen trabajadores separados y pueden arrastrarse por detrás de las transacciones de las que vienen.
# 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'La paginación por offset se desliza bajo una lista que crece
Cada lista de aquí va de lo más reciente a lo más antiguo, y las filas nuevas llegan por la cabeza. La página dos, recuperada un instante después de la página uno, se solapa por tanto con ella - y hay filas que pueden saltarse por completo mientras usted camina. Para una recuperación de historial que deba ser completa, pagine por número de bloque y baje, o recupere un bloque cada vez; offset está hecho para una interfaz, no para un importador.
Una última asimetría que conviene conocer antes de indexar nada por clave: esta cadena enumera logIndex por transacción en lugar de por bloque, así que el par (blockNumber, logIndex) no es único. Incluya el hash de la transacción en cualquier clave que construya.