Your first Prep query
Try the playground first
Open Prep Playground to choose an example, select fields and run a public testnet query in your browser.
Fetch Zcash block headers with the JavaScript client. This example reads testnet blocks 0 and 1 and prints the selected fields.
Prerequisites
Node.js 22.18+ and pnpm, or npm using the alternative below. The public testnet preview requires no personal API token.
1. Install the client
mkdir prep-quickstart
cd prep-quickstart
npm init -y
pnpm add @zeer-dev/prep-client@0.1.0
With npm, use npm install @zeer-dev/prep-client@0.1.0 instead.
2. Write your query
Save this as read-blocks.mjs:
import { PrepClient } from "@zeer-dev/prep-client";
const client = new PrepClient({ url: "https://zeer.endpx.cloud/api/prep" });
const coverage = await client.getHeight();
if (!coverage.ready || coverage.start_block > 0 ||
coverage.indexed_height === null || coverage.indexed_height < 1) {
throw new Error("Blocks 0 and 1 are not available from this source.");
}
const query = {
from_block: 0,
to_block: 2,
field_selection: { block: ["height", "hash", "time"], transaction: [] },
};
for await (const page of client.stream(query)) {
console.log(page.data.blocks);
}
3. Run
node read-blocks.mjs
The output contains block heights 0 and 1, each with its hash and timestamp. to_block is exclusive, so 2 is outside the requested range.
How it works
| Part | Purpose |
|---|---|
PrepClient | Connects to the chosen network URL |
getHeight() | Checks available coverage and readiness |
field_selection | Returns only the fields you request; transaction: [] omits transaction records |
stream(query) | Follows response cursors until the captured range is complete |
Next steps
- Clients — methods, types and resources.
- Fields & filters — select transactions and public pool activity.
- cURL examples — call the API directly.
- Getting started — build a repeatable integration.