Update HyperSync client initialization and API token requirements#788
Update HyperSync client initialization and API token requirements#788
Conversation
- 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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe PR updates HyperSync client documentation examples to use the new constructor pattern Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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 usesapiToken. The intro text should be updated to reflect that parameter names vary by language (TypeScript usesapiToken, Python usesbearer_token, Rust usesapi_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
typescriptor 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 standalonedocs/HyperSync/api-tokens.mdxfile usesENVIO_API_TOKENconsistently across all languages. This creates documentation inconsistency.Additionally, the Rust example uses
bearer_tokenfield but the standalone file usesapi_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
.envexample usesHYPERSYNC_BEARER_TOKEN, but should useENVIO_API_TOKENfor 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
| ```bash | ||
| export ENVIO_API_TOKEN="your-api-token-here" |
There was a problem hiding this comment.
I guess this is better than showing hardcoding the token in the code 🗡️
JasoonS
left a comment
There was a problem hiding this comment.
Thanks Dmitry, looks great
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
HypersyncClient.new()tonew HypersyncClient()constructor syntax across all documentation examplesENVIO_API_TOKENLogField.Data) to string literals (e.g.,"Data")LogField,BlockField,TransactionField, andJoinModeenumsjoinMode: JoinMode.JoinTransactionsfrom query examples as it appears to be deprecatedFiles Modified
docs/HyperSync-LLM/hypersync-complete.mdxdocs/HyperSync/api-tokens.mdxdocs/HyperSync/quickstart.mdImplementation Details
All code examples now follow the updated pattern:
Field selections use string literals instead of enum constants for improved simplicity and flexibility.
https://claude.ai/code/session_01JAAsE6JFJf2ZzESAetVVgk
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.