개발자를 위한 문서 / 애플리케이션 API

애플리케이션 API

네 개의 퍼스트파티 서비스가 체인 옆에 앉아 있습니다. 어느 것도 체인이 아니고, 어느 것도 버전이 없으며, 각각 자기만의 방식으로 실패합니다 - 이 섹션이 있는 이유가 그것입니다.

이것들은 무엇인가

체인의 인터페이스는 JSON-RPC입니다. 이 페이지들에 있는 모든 것은 어떤 애플리케이션이 자기를 위해 만들고 나서 닿을 수 있게 남겨 둔 것입니다. 시퀀서의 로그 스풀 위의 Postgres 인덱스, 키를 들고 있는 프로세스, 게임 루프입니다. 편리하고, 퍼스트파티이며, 권위 있는 것은 아닙니다.

여기서의 읽기는 체인에서의 읽기가 아닙니다

여기의 모든 수치는 인덱서나 캐시, 또는 둘 다를 거쳤습니다. 멈춘 인덱서는 마지막 상태로 계속 답하고 응답의 어느 필드도 그것을 말해 주지 않습니다. 알려 주는 것은 헬스 라우트뿐이며, 그것도 물어봐야 합니다. 답이 돈을 결정한다면 체인을 읽으십시오.

A read-only view of what the Pepper indexer has derived from the chain's logs: constant-product pools, concentrated pools, swaps, liquidity events and positions. It reads Postgres rather than the chain, deliberately.

스택
Python, standard-library ThreadingHTTPServer, psycopg pool of at most 8 connections, HTTP/1.1
마운트 위치
/api/ on the Pepper origin

The archive the node deliberately is not. Blocks, mini-blocks, transactions, receipts, logs, call traces, decoded transfers, accounts, tokens, NFTs and the name-service record, all from a Postgres index fed by the sequencer's own log spool.

스택
Python, standard-library ThreadingHTTPServer, psycopg pool of at most 12 connections, plus live reads against the node
마운트 위치
/api/ on the explorer origin

The only first-party service that WRITES to the chain. It holds the faucet operator key and submits the drip on your behalf, which is why the page needs no wallet.

스택
Python, standard-library SimpleHTTPRequestHandler serving a static site as well as the API, signing with eth-account
마운트 위치
its own origin; the home origin re-exposes two of its routes

A WebSocket server for the games, with a small HTTP surface beside it for health and for the figures the site's chrome draws. The socket is the interface; the HTTP routes are a snapshot of it.

스택
Node, `ws` in noServer mode behind a plain http server, one event loop for eight game rooms
마운트 위치
/api/ and /ws/ on the arcade origin

어디서 응답하는가

서비스베이스 URL
익스플로러 APIhttps://explorer.picklechain.xyz/api/네임 서비스와 툴킷 사이트도 /api/에 마운트합니다
Pepper DEX APIhttps://pepper.picklechain.xyz/api/동일 출처 전용. 다른 출처의 브라우저는 호출할 수 없습니다
Faucethttps://faucet.picklechain.xyz홈 출처가 POST /drip과 GET /faucet-status를 다시 노출합니다
Arcadehttps://minigame.picklechain.xyz/api/그리고 소켓은 wss://minigame.picklechain.xyz/ws/<room>입니다

이 서비스들 중 자기 호스트명을 가진 것은 하나도 없습니다. 각각은 어느 프런트엔드 출처 위의 /api/ 마운트이며, 그래서 공개 베이스는 서비스의 사실이 아니라 nginx의 사실입니다. 사이트를 옮기는 배포는 그 API도 함께 옮기고, 안쪽의 경로는 그대로입니다. 직접 운영하는 스택에서는 같은 서비스들이 루프백에서, 각자의 페이지가 적어 둔 포트에서 답합니다.

어디에도 버전이 없습니다

넷 중 어느 것에도 /v1도, 버전 헤더도, 폐기 정책도 없습니다. 저장소에 OpenAPI 문서도 JSON Schema도 없으므로, 두 배포 사이에서 필드의 모양이 바뀌어도 대조할 것이 없습니다. 방어적으로 읽으십시오. 모르는 키는 무시하고, 사라진 키에 실패하지 마십시오.

인증

넷 중 어느 것도 인증을 받지 않으며, 중요한 차이는 인증 없이 각자 무엇을 할 수 있는가입니다.

  • 익스플로러, DEX API, 아케이드는 인증을 받지 않습니다. 읽기 전용이고 공개입니다. 익스플로러는 모든 POST에 405로 답하고, DEX API는 GET 외의 어떤 동사도 구현하지 않습니다.
  • Faucet도 인증을 받지 않으면서 체인에 씁니다. 그 할당량이 엄격하고 무엇이 서명되기 전에 미리 잡히는 이유가 전적으로 그것입니다.

아케이드 소켓에는 인증이 없고 그 프로세스는 키를 들고 있습니다

그 앞에 인증 계층은 없고 계획도 없습니다. 프록시는 업그레이드를 넘겨줄 뿐입니다. 그것을 지키는 것은 연결의 모든 차원이 묶여 있다는 사실입니다. 개수, 출처, 프레임 크기, 메시지 속도, 버퍼된 바이트이며, 넘치는 것은 큐에 쌓이는 대신 버려집니다. 클라이언트가 그 소켓으로 하는 말은 무엇도 허가하지 않습니다. 누가 놀 수 있는지는 컨트랙트가 정합니다.

브라우저에서 호출하기

CORS는 서비스마다 설정되어 있고 서로 일치하지 않으므로, 먼저 확인할 것은 여러분 출처의 페이지가 원하는 그것을 아예 호출할 수 있는지입니다.

  • DEX API는 CORS 헤더를 보내지 않고 OPTIONS 핸들러도 없습니다. 브라우저에서 출처를 넘는 fetch는 곧바로 실패하는데 서버에서 보낸 같은 요청은 성공하며, 그것이 네트워크 탓으로 돌려지는 버그의 모양입니다. 프록시하거나 백엔드에서 부르십시오.
  • 익스플로러와 Faucet은 허용 목록을 둡니다. 목록에 없는 출처의 사전 요청은 403으로 거절되며, 적어도 분명한 답입니다.
  • 아케이드는 업그레이드에서 Origin을 확인하고 핸드셰이크 전에 403으로 거절하므로, 소켓이 열렸다가 조용해지는 대신 아예 열리지 않습니다.

한도와 페이징

요청 속도를 제한하는 것은 익스플로러뿐입니다. 나머지 셋은 대신 제한, 할당량, 또는 연결 상한에 기댑니다.

서비스한도
Pepper DEX API`limit` is clamped to 1..500 on every list route and defaults to 50. There is no request-rate limit in the service.
Explorer API300 requests per minute per client address, then 429. Request bodies are capped at 600,000 bytes. Live streams are capped at 32 concurrent.
FaucetQuota is reserved before the transaction is signed: 5 a day per address seen, 2 a day per funded address, 1000 a day in total. Request bodies are capped at 4096 bytes.
Arcade server256 sockets in total and 8 per source address, then the upgrade is refused 429. Inbound frames are 4 KiB at most and rate-limited per socket. A socket more than 512 KiB behind is cut.

잘린 목록은 조용히 짧은 목록입니다

DEX API에 스왑 천 개를 달라고 하면 오백 개를 받으며, 200과 함께 답이 잘렸다고 말해 주는 것은 없습니다. 익스플로러에 블록 이백 개를 달라고 하면 백 개를 받습니다. 두 서비스 모두 대부분의 목록 라우트에서 총계를 돌려주지 않으므로 페이지 길이와 비교할 필드가 없습니다. 더 있다는 유일한 신호는 정확히 그 한도만큼 받았다는 것뿐입니다.

페이징이 있는 곳에서는 커서가 아니라 limit과 offset입니다. 그것은 머리에서 자라는 목록이 두 페이지 사이에 발밑에서 밀린다는 뜻입니다. 이미 본 행이 다시 나타나고, 보지 못한 행이 건너뛰어질 수 있습니다. 완전해야 하는 것이라면 offset이 아니라 여러분이 통제하는 키 - 블록 번호나 해시 - 로 페이징하십시오.

관례

관례Value
VersioningNone of them is versionedno /v1, no version header, no deprecation policy. A field can change shape between two deployments. Read defensively and pin nothing.
SchemaThere is no OpenAPI documentand no JSON Schema anywhere in the repository. Every shape documented here was read out of a route handler, which is why each record names the line.
Errors{"error": "..."}a human-readable string, occasionally with a second key. There are no error codes and no stable error strings - match on the HTTP status, never on the message.
Cachingcache-control: no-storeon every route of all four services, without exception. Nothing here is safe to cache, and nothing offers you an ETag to revalidate against.
Content typeJSONwith two exceptions: the explorer's logo route returns raw image bytes, and its live route is an event stream.
Unitsnot uniformtoken amounts and wei are DECIMAL STRINGS, not numbers, because they do not survive a double. Mini-block timestamps are in MICROSECONDS. Concentrated-pool swap amounts are SIGNED.

금액은 문자열이고, 그중 일부는 부호가 있습니다

토큰 수량, wei, 잔액은 전부 십진 문자열로 돌아옵니다. double을 견디지 못하기 때문입니다. 큰 정수 타입으로 파싱하십시오. 집중 유동성 풀 라우트에서는 금액에 부호도 붙습니다. 모든 스왑의 한쪽 다리가 음수이며 그것이 거래가 어느 방향이었는지를 말해 줍니다 - 그러니 절댓값을 취하지 않는 합계는 시장 하나를 통째로 0으로 만듭니다.

javascript
// The shape of a careful call against any of these: a timeout, a status check
// before the body, and a big-integer parse of anything that looks like money.
const res = await fetch(`${BASE}/pools`, { signal: AbortSignal.timeout(5000) });
if (!res.ok) throw new Error(`pools: ${res.status}`);          // never the message
const { pools } = await res.json();                              // an object, not an array
const reserve0 = BigInt(pools[0].reserve0);                      // a decimal string

하나가 죽었을 때

넷은 저마다 다르게 실패하며, 그중 바깥에서 실패처럼 보이는 것은 하나뿐입니다.

  • DEX API는 503 index not ready로 답합니다. 데이터베이스에 닿을 수 없거나 인덱서가 한 번도 돌지 않아 테이블이 없을 때입니다. 그쪽이 정직한 경우입니다. 정직하지 않은 쪽은 멈춘 인덱서입니다. 모든 라우트가 도달했던 상태로 계속 답하고, 그것을 말해 주는 것은 /health의 lagBlocks뿐입니다.
  • 익스플로러는 노드에 닿을 수 없어도 인덱스를 계속 제공합니다. 실시간 읽기가 필요한 부분 - 잔액, 네임 서비스 레코드, 수수료 라우터의 미지급 잔액 - 은 오류를 내는 대신 null이나 부재로 돌아옵니다. /stats의 indexLag 필드가 지켜볼 수치입니다.
  • Faucet은 노드가 응답하지 않을 때 502로 답하며, 아무것도 서명되지 않은 상태입니다. 503은 자금이 떨어졌거나 드립이 revert했다는 뜻입니다.
  • 아케이드의 /ready는 노드로 가는 소켓이 죽었을 때, 또는 마지막으로 적용한 미니블록이 다섯 초보다 오래되었을 때 503으로 답합니다. 대신 도착을 재면 멈춰 버린 프로세스가 아무것도 움직이지 않으면서 200으로 답할 수 있었습니다.
쓰기가 아니라 상태를 재시도하십시오

쓰는 것은 Faucet뿐이며, 거기서 오는 502는 아무것도 제출되지 않았다는 뜻입니다 - 그것은 안전하게 재시도할 수 있습니다. 트랜잭션이 나간 뒤의 503은 그렇지 않습니다. 드립이 착지했을 수 있고 할당량 예약은 이미 되돌려졌으므로, 다시 보내지 말고 체인에서 영수증을 폴링하십시오.

다른 곳에 문서화된 것

  • The node. Chain state, transactions, logs and subscriptions are JSON-RPC and are documented in this reference's own RPC pages, not here.
  • Contracts. What the pools, the faucet and the games actually do on chain - their functions, their events and their revert reasons - is the contract reference.
  • Prices. Several answers here carry a dollar figure or a price snapshot. Those fields come from a layer this page does not own; read its own reference for what the number means, how old it is and when it is absent.