Skip to content

Update HyperSync client initialization and API token requirements#788

Merged
DZakh merged 4 commits intomainfrom
claude/update-nodejs-examples-kJDaP
Jan 30, 2026
Merged

Update HyperSync client initialization and API token requirements#788
DZakh merged 4 commits intomainfrom
claude/update-nodejs-examples-kJDaP

Conversation

@DZakh
Copy link
Member

@DZakh DZakh commented Jan 29, 2026

Summary

Updated HyperSync documentation to reflect changes in the client API and API token requirements. This includes updating client initialization syntax, removing deprecated enum imports, and clarifying that API tokens are now required for all usage (not just production).

Key Changes

  • Client Initialization: Updated from HypersyncClient.new() to new HypersyncClient() constructor syntax across all documentation examples
  • API Token Requirement: Changed from optional (production-only) to required for all usage, with environment variable ENVIO_API_TOKEN
  • Field Selection: Simplified field selection from enum references (e.g., LogField.Data) to string literals (e.g., "Data")
  • Removed Deprecated Imports: Removed unused imports of LogField, BlockField, TransactionField, and JoinMode enums
  • URL Protocol: Updated HTTP URLs to HTTPS for all HyperSync endpoints
  • Removed joinMode: Eliminated joinMode: JoinMode.JoinTransactions from query examples as it appears to be deprecated

Files Modified

  • docs/HyperSync-LLM/hypersync-complete.mdx
  • docs/HyperSync/api-tokens.mdx
  • docs/HyperSync/quickstart.md

Implementation Details

All code examples now follow the updated pattern:

const client = new HypersyncClient({
  url: "https://eth.hypersync.xyz",
  apiToken: process.env.ENVIO_API_TOKEN!,
});

Field selections use string literals instead of enum constants for improved simplicity and flexibility.

https://claude.ai/code/session_01JAAsE6JFJf2ZzESAetVVgk

Summary by CodeRabbit

  • Documentation
    • Updated client initialization syntax and API authentication examples throughout documentation
    • Switched all network endpoints from HTTP to HTTPS
    • Simplified field selection in API queries to use string literals instead of enum references

✏️ Tip: You can customize this high-level summary in your review settings.

- Use `new HypersyncClient()` constructor instead of `HypersyncClient.new()`
- Use `apiToken` parameter instead of `bearerToken`
- Use `https://` URLs instead of `http://`
- Use string field names (e.g., "Data", "Address") instead of enum references

https://claude.ai/code/session_01JAAsE6JFJf2ZzESAetVVgk
- apiToken is now required for all HyperSync client initializations
- Updated all examples to include apiToken: process.env.ENVIO_API_TOKEN
- Updated "API Token for Production Use" sections to reflect token is required

https://claude.ai/code/session_01JAAsE6JFJf2ZzESAetVVgk
@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
envio-docs Ready Ready Preview, Comment Jan 29, 2026 0:50am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

The PR updates HyperSync client documentation examples to use the new constructor pattern new HypersyncClient() with apiToken parameter, replaces HTTP with HTTPS URLs, switches from enum-based field selections to string literals, and removes unused imports across multiple documentation files.

Changes

Cohort / File(s) Summary
HyperSync Documentation Updates
docs/HyperSync-LLM/hypersync-complete.mdx, docs/HyperSync/quickstart.md
Replaces HypersyncClient.new({ url: ... }) with new HypersyncClient({ url: ..., apiToken: ... }) constructor pattern; updates HTTP to HTTPS URLs; switches from enum-based field references (LogField.\*) to string literals ("Data", "Address", "Topic0"); removes imports of LogField and JoinMode; adds viem imports (keccak256, toHex) where needed; updates authentication guidance from bearerToken to apiToken using environment variable ENVIO_API_TOKEN.
API Token Documentation
docs/HyperSync/api-tokens.mdx
Updates client instantiation from HypersyncClient.new({ ... }) to new HypersyncClient({ ... }) constructor syntax.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • nikbhintade
  • moose-code

Poem

🐰✨ With tokens and HTTPS so bright,
The docs now shine in constructor light!
String fields dance where enums once stood,
Authentication reformed as it should! 🔐

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: updating client initialization patterns and API token requirements across HyperSync documentation examples.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
docs/HyperSync/api-tokens.mdx (1)

37-46: Documentation text doesn't match TypeScript example.

Line 37 states "pass it as a bearer_token" but the TypeScript example on lines 43-46 uses apiToken. The intro text should be updated to reflect that parameter names vary by language (TypeScript uses apiToken, Python uses bearer_token, Rust uses api_token).

📝 Suggested text fix
-To use an API token, pass it as a `bearer_token` when creating a HyperSync client:
+To use an API token, pass it when creating a HyperSync client (parameter name varies by language):
docs/HyperSync/quickstart.md (1)

63-70: Code block language mismatch: uses TypeScript syntax in JavaScript block.

Line 63 declares the code block as javascript, but line 69 uses TypeScript's non-null assertion operator (!). This syntax is invalid JavaScript and will cause confusion for developers copying this code.

Either change the language identifier to typescript or remove the non-null assertion and handle the undefined case.

📝 Option 1: Change to TypeScript
-```javascript
+```typescript
 import { HypersyncClient } from "@envio-dev/hypersync-client";
📝 Option 2: Keep JavaScript, handle undefined
 const client = new HypersyncClient({
   url: "https://eth.hypersync.xyz",
-  apiToken: process.env.ENVIO_API_TOKEN!,
+  apiToken: process.env.ENVIO_API_TOKEN,
 });
docs/HyperSync-LLM/hypersync-complete.mdx (2)

1947-1961: Inconsistent environment variable names with standalone api-tokens.mdx.

The Python and Rust examples in this consolidated file use HYPERSYNC_BEARER_TOKEN, but the standalone docs/HyperSync/api-tokens.mdx file uses ENVIO_API_TOKEN consistently across all languages. This creates documentation inconsistency.

Additionally, the Rust example uses bearer_token field but the standalone file uses api_token.

📝 Suggested fix for Python (lines 1947-1950)
 client = hypersync.HypersyncClient(hypersync.ClientConfig(
     url="https://eth.hypersync.xyz",
-    bearer_token=os.environ.get("HYPERSYNC_BEARER_TOKEN")
+    bearer_token=os.environ.get("ENVIO_API_TOKEN")
 ))
📝 Suggested fix for Rust (lines 1957-1961)
 let client = Client::new(ClientConfig {
-    bearer_token: Some(std::env::var("HYPERSYNC_BEARER_TOKEN").unwrap_or_default()),
+    api_token: std::env::var("ENVIO_API_TOKEN").expect("ENVIO_API_TOKEN must be set"),
     ..Default::default()
 })
-.unwrap();
+.unwrap()

1984-1987: Environment variable name inconsistency.

The .env example uses HYPERSYNC_BEARER_TOKEN, but should use ENVIO_API_TOKEN for consistency with the standalone api-tokens.mdx file and the TypeScript examples.

📝 Suggested fix
 # Example .env file
-HYPERSYNC_BEARER_TOKEN=your_secret_token_here
+ENVIO_API_TOKEN=your_secret_token_here

Comment on lines +280 to +281
```bash
export ENVIO_API_TOKEN="your-api-token-here"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is better than showing hardcoding the token in the code 🗡️

Copy link
Contributor

@JasoonS JasoonS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dmitry, looks great

@DZakh DZakh merged commit 34f6b18 into main Jan 30, 2026
3 checks passed
@DZakh DZakh deleted the claude/update-nodejs-examples-kJDaP branch January 30, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants