HyperSync Client Libraries
HyperSync provides powerful client libraries that enable you to integrate high-performance blockchain data access into your applications. These libraries handle the communication with HyperSync servers, data serialization/deserialization, and provide convenient APIs for querying blockchain data.
Quick Linksโ
| Client | Resources |
|---|---|
| Node.js | ๐ API Docs ยท ๐ฆ NPM ยท ๐ป GitHub ยท ๐งช Examples |
| Python | ๐ฆ PyPI ยท ๐ป GitHub ยท ๐งช Examples |
| Rust | ๐ฆ Crates.io ยท ๐ API Docs ยท ๐ป GitHub ยท ๐งช Examples |
| Go (community) | ๐ป GitHub ยท ๐งช Examples |
| Solana (Rust) | ๐ Guide ยท ๐ฆ Crates.io ยท ๐ API Docs ยท ๐ป GitHub |
| API Tokens | ๐ Get Tokens |
Client Overviewโ
The Node.js and Python clients are bindings over the Rust client, so the three share one engine and the same defaults. The Go client is a separate, community-maintained implementation. This page describes Node.js 1.4.1, Python 1.2.1 and Rust 1.4.1.
The Node.js, Python and Rust clients share these key features:
- Optimized Transport: Responses arrive in Apache Arrow, a binary columnar format, rather than JSON
- Automatic Pagination:
streamandcollectcover a whole block range for you - Retries: Failed requests are retried with backoff, 12 times by default
- Event Decoding:
Decoderparses raw logs into typed values
Choose the client that best matches your application's technology stack:
| Feature | Node.js | Python | Rust | Go |
|---|---|---|---|---|
| Typing | TypeScript | Type Hints | Native | Native |
| Output | JS objects, Parquet | Python objects, Arrow (pyarrow), Parquet | Rust structs, Arrow, Parquet | Go structs |
| Installation | npm | pip | cargo | go get |
API at a Glanceโ
Exact names in each official client. Each one takes a query built as described in the Query Reference.
| Task | Node.js | Python | Rust |
|---|---|---|---|
| Create a client | new HypersyncClient({ url, apiToken }) | HypersyncClient(ClientConfig(url=..., api_token=...)) | Client::builder().url(..).api_token(..).build()? |
| One request | get(query) | get(query) | get(&query) |
| Stream a range | stream(query, {}), then recv() until null | stream(query, StreamConfig()), then recv() until None | stream(query, StreamConfig::default()), then recv() until None |
| Collect a range in memory | collect(query, config) | collect(query, config) | collect(query, config) |
| Logs joined with their block and transaction | getEvents, streamEvents, collectEvents | get_events, stream_events, collect_events | get_events, stream_events, collect_events |
| Arrow tables | not available | get_arrow, stream_arrow, collect_arrow | get_arrow, stream_arrow, collect_arrow |
| Write Parquet to a directory | collectParquet(dir, query, config) | collect_parquet(dir, query, config) | collect_parquet(dir, query, config) |
| Chain height and chain ID | getHeight(), getChainId() | get_height(), get_chain_id() | get_height(), get_chain_id() |
| Follow new blocks | streamHeight() | not available | stream_height() |
| Rate limit info | getWithRateLimit, rateLimitInfo, waitForRateLimit | get_with_rate_limit, rate_limit_info, wait_for_rate_limit | get_with_rate_limit, rate_limit_info, wait_for_rate_limit |
| Decode logs | Decoder.fromSignatures([...]), decodeLogs | Decoder([...]), decode_logs | Decoder::from_signatures(&[...]), decode_log |
| Decode call input | CallDecoder.fromSignatures, decodeTransactionsInput, decodeTracesInput | CallDecoder([...]), decode_transactions_input, decode_traces_input | CallDecoder::from_signatures, decode_input |
| Query keys | camelCase: fromBlock, fieldSelection | snake_case: from_block, field_selection | builder: Query::new().from_block(..) |
| Field names | "BlockNumber" | "block_number" | LogField::BlockNumber |
The request and stream methods are async: await them in Node.js and Python, and .await them in Rust (Rust's stream_height returns its receiver directly). In Rust, Client::builder().chain_id(1) sets the URL to https://1.hypersync.xyz.
The main client options are the same in every official client (camelCase in Node.js): url, api_token, http_req_timeout_millis (default 30000), max_num_retries (default 12), retry_backoff_ms (500), retry_base_ms (200), retry_ceiling_ms (5000) and proactive_rate_limit_sleep (true). Node.js also has enableChecksumAddresses. The stream options are in Stream Config & Tuning.
To react to new blocks without polling, stream the chain height. It works the same way in Rust with stream_height():
const heights = await client.streamHeight();
while (true) {
const event = await heights.recv(); // { type: "Connected" | "Height" | "Reconnecting", ... }
if (event === null) break;
if (event.type === "Height") console.log("new block", event.height);
}
Node.js Clientโ
The Node.js client provides a TypeScript-first experience for JavaScript developers.
Installationโ
# Using npm
npm install @envio-dev/hypersync-client
# Using yarn
yarn add @envio-dev/hypersync-client
# Using pnpm
pnpm add @envio-dev/hypersync-client
Python Clientโ
The Python client provides a Pythonic interface with full type hinting support.
Installationโ
pip install hypersync
Rust Clientโ
The Rust client provides the most efficient and direct access to HyperSync, with all the safety and performance benefits of Rust.
Installationโ
Add the following to your Cargo.toml:
[dependencies]
hypersync-client = "1"
tokio = { version = "1", features = ["full"] }
Solana Clientโ
Solana HyperSync has its own client, because the query and table model is Solana-shaped (slots, instruction calls, account activity) rather than EVM-shaped. It is Rust today, with unpublished Node bindings in the same repository. Everything client-side is covered in the Solana client guide.
[dependencies]
hypersync-client-solana = "0.2"
hypersync-solana-net-types = "0.2" # SolanaQuery and the selection types
tokio = { version = "1", features = ["full"] }
anyhow = "1"
The query types live in the separate hypersync-solana-net-types crate. The client doesn't re-export them, so add both.
Go Clientโ
The Go client is community maintained and marked as work-in-progress. For production use, you may want to test thoroughly or consider the officially supported clients.
The Go client provides a native Go interface for accessing HyperSync, with support for streaming and decoding blockchain data. It is written in Go rather than built on the Rust client, so the API, defaults and the stream tuning on this site don't apply to it. It has Get, Stream, GetHeight and range helpers such as StreamLogsInRange, and can call HyperRPC, but has no Parquet output.
Installationโ
go get github.com/enviodev/hypersync-client-go
The repository has no tagged releases, so this installs the latest commit on main. Set RpcEndpoint as well as Endpoint when you create a client. Without it, NewClient fails with failed to connect to RPC client: dial unix: missing address:
client, err := hypersyncgo.NewClient(ctx, options.Node{
Endpoint: "https://eth.hypersync.xyz",
RpcEndpoint: "https://eth.rpc.hypersync.xyz",
ApiToken: os.Getenv("ENVIO_API_TOKEN"),
})
Using API Tokensโ
You'll need an API token to use any HyperSync client. Get your token here.
All HyperSync clients require an API token for authentication. Tokens are used to manage access and usage limits.
To get an API token:
- Visit Envio
- Register or sign in with your github account
- Navigate to the API Tokens section
- Create a new token
For detailed instructions, see our API Tokens guide.
Client Selection Guideโ
Choose the client that best fits your use case:
Choose when: You're building JavaScript/TypeScript applications or if your team is most comfortable with the JavaScript ecosystem.
Choose when: You're doing data science work, need integration with pandas/numpy, or if your team prefers Python's simplicity.
Choose when: You need maximum performance, are doing systems programming, or building performance-critical applications.
Choose when: You're working in a Go ecosystem and want native integration with Go applications. Note that this client is community maintained.
Additional Resourcesโ
- ๐ HyperSync Usage Guide
- ๐ Query Reference
- ๐งช cURL Examples
- ๐ Supported Networks
- ๐งฑ HyperIndex blockchain indexer, the full framework with schema, handlers, and a hosted GraphQL API, powered by HyperSync
Supportโ
Need help getting started or have questions about our clients? Connect with our community: