Indexer API
API endpoints for Merkle tree state (advanced)
Indexer API
Section titled “Indexer API”The indexer tracks Merkle tree state and provides proofs for withdrawals. These endpoints are primarily used internally but available for advanced use cases.
POST /get_merkle/{mint}/{depth}/{network}
Section titled “POST /get_merkle/{mint}/{depth}/{network}”Get the current Merkle tree state.
Request
Section titled “Request”POST /get_merkle/{mint}/{depth}/{network}| Parameter | Description |
|---|---|
mint | Token mint address |
depth | Tree depth (always 32) |
network | ”mainnet” or “devnet” |
Response
Section titled “Response”{ "address": "MerkleTreeAccountAddress", "json": { "root": [1, 2, 3, ...], "nextIndex": 1234, "depth": 32 }}Example
Section titled “Example”const response = await fetch( `https://worker.turbine.cash/get_merkle/${mint}/32/mainnet`, { method: 'POST' });const { json } = await response.json();console.log('Current root:', json.root);console.log('Next leaf index:', json.nextIndex);POST /get_proof/{mint}/{depth}/{index}/{network}
Section titled “POST /get_proof/{mint}/{depth}/{index}/{network}”Get Merkle proof for a specific leaf.
Request
Section titled “Request”POST /get_proof/{mint}/{depth}/{index}/{network}| Parameter | Description |
|---|---|
mint | Token mint address |
depth | Tree depth (32) |
index | Leaf index |
network | ”mainnet” or “devnet” |
Response
Section titled “Response”{ "address": "ProofAccountAddress", "json": { "path": [[1,2,3,...], [4,5,6,...], ...], "indices": [0, 1, 0, 1, ...] }}The proof path contains 32 sibling hashes needed to reconstruct the root.
Example
Section titled “Example”const response = await fetch( `https://worker.turbine.cash/get_proof/${mint}/32/${leafIndex}/mainnet`, { method: 'POST' });const { json } = await response.json();const proofPath = json.path;POST /get_node/{mint}/{depth}/{index}/{network}
Section titled “POST /get_node/{mint}/{depth}/{index}/{network}”Get a specific node from the Merkle tree.
Request
Section titled “Request”POST /get_node/{mint}/{depth}/{index}/{network}| Parameter | Description |
|---|---|
mint | Token mint address |
depth | Tree depth (32) |
index | Node index |
network | ”mainnet” or “devnet” |
Response
Section titled “Response”{ "address": "NodeAccountAddress", "json": { "value": [1, 2, 3, ...] }}POST /get_nullifier/{mint}/{depth}/{network}
Section titled “POST /get_nullifier/{mint}/{depth}/{network}”Check if a nullifier hash has been spent.
Request
Section titled “Request”POST /get_nullifier/{mint}/{depth}/{network}Content-Type: application/jsonBody:
{ "nullifierHash": [1, 2, 3, ...]}Response
Section titled “Response”Nullifier spent:
{ "address": "NullifierAccountAddress", "json": { "spent": true }}Nullifier not spent:
{ "address": null, "json": null}Example
Section titled “Example”async function isNullifierSpent( mint: string, nullifierHash: Uint8Array, network: string = 'mainnet'): Promise<boolean> { const response = await fetch( `https://worker.turbine.cash/get_nullifier/${mint}/32/${network}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ nullifierHash: Array.from(nullifierHash), }), } );
const data = await response.json(); return data.json !== null;}Use Cases
Section titled “Use Cases”| Use Case | Endpoint |
|---|---|
| Check current tree state | /get_merkle |
| Generate withdrawal proof | /get_proof |
| Debug tree structure | /get_node |
| Check before withdrawing | /get_nullifier |
Rate Limits
Section titled “Rate Limits”Indexer endpoints have generous rate limits for legitimate use:
| Endpoint | Limit |
|---|---|
/get_merkle | 60/minute |
/get_proof | 60/minute |
/get_node | 120/minute |
/get_nullifier | 60/minute |