Skip to content

Conversation

tejasbadadare
Copy link
Contributor

Summary

  • Add Lazer REST API support to PythLazerClient. Previously, the client was only focused on the WS streaming API. This PR adds support for our other consumer endpoints and makes the SDK more useful.

    • Add get_symbols() -- fetch feed metadata, with optional query and asset filters
    • Add get_latest_price() -- fetch latest prices by ID or symbol
    • Add get_price() -- fetch historical prices by ID or symbol
  • Update config. Now that the client also handles REST endpoints and not just WS, expanded the configuration to account for these. The config is now:

    • export type LazerClientConfig = {
        token: string;
        metadataServiceUrl?: string; // Metadata URL with default (currently history service)
        priceServiceUrl?: string; // Price URL with default (currently router)
        logger?: Logger; // Optional logger
        webSocketPoolConfig?: WebSocketPoolConfig; // Old config (WS params)
      };
    • I named the URL params based on the product surface they expose rather than internal service names, since these will change once the endpoints are unified under an API gateway.
  • Add more examples to showcase different APIs. Check it out: https://asciinema.org/a/T4rLhqb3EAt2tM7dB1JtrngNA

    • pnpm run example:streaming: streams prices over WS, parses them to human-friendly format using the exponent, and renders them in-place on the terminal to showcase the fast update rate
    • pnpm run example:symbols: get all symbols, search by symbol name and/or asset type
    • pnpm run example:history: get latest price and timestamped price

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

devin-ai-integration bot and others added 8 commits September 22, 2025 23:17
- Add LazerClientConfig type wrapping WebSocketPoolConfig with historyServiceUrl
- Implement get_symbols() method to query /v1/symbols endpoint
- Add TypeScript interfaces for SymbolResponse and query parameters
- Update example to demonstrate BTC symbol search and subscription
- Add cross-fetch dependency for Node.js compatibility
- Bump version to 2.1.0 following semver for new feature

Co-Authored-By: Tejas Badadare <tejas@dourolabs.xyz>
…ce endpoints

- Add TypeScript interfaces for LatestPriceRequest, PriceRequest, and JsonUpdate
- Update LazerClientConfig to include routerServiceUrl with default
- Implement get_latest_price() and get_price() HTTP methods in PythLazerClient
- Create router-example.ts demonstrating all Router endpoint use cases
- Bump version to 2.2.0 to reflect new Router service functionality
- Add router-example script to package.json for easy testing

Co-Authored-By: Tejas Badadare <tejas@dourolabs.xyz>
…ithub.com:pyth-network/pyth-crosschain into devin/1758582450-expand-lazer-sdk-history-support
Copy link

vercel bot commented Sep 23, 2025

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

Project Deployment Preview Comments Updated (UTC)
api-reference Ready Ready Preview Comment Sep 23, 2025 6:03pm
component-library Ready Ready Preview Comment Sep 23, 2025 6:03pm
developer-hub Ready Ready Preview Comment Sep 23, 2025 6:03pm
proposals Ready Ready Preview Comment Sep 23, 2025 6:03pm
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
entropy-explorer Skipped Skipped Sep 23, 2025 6:03pm
insights Skipped Skipped Sep 23, 2025 6:03pm
staking Skipped Skipped Sep 23, 2025 6:03pm

keyvankhademi
keyvankhademi previously approved these changes Sep 23, 2025
@tejasbadadare tejasbadadare requested a review from a team as a code owner September 23, 2025 17:12
@vercel vercel bot temporarily deployed to Preview – staking September 23, 2025 17:12 Inactive
@vercel vercel bot temporarily deployed to Preview – insights September 23, 2025 17:12 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer September 23, 2025 17:12 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer September 23, 2025 17:58 Inactive
@vercel vercel bot temporarily deployed to Preview – staking September 23, 2025 17:58 Inactive
@vercel vercel bot temporarily deployed to Preview – component-library September 23, 2025 17:58 Inactive
@vercel vercel bot temporarily deployed to Preview – insights September 23, 2025 17:58 Inactive
@vercel vercel bot temporarily deployed to Preview – developer-hub September 23, 2025 17:58 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference September 23, 2025 17:59 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals September 23, 2025 17:59 Inactive
Copy link
Contributor

@darunrs darunrs left a comment

Choose a reason for hiding this comment

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

LGTM! Some nitpicks.


console.log(`\u001B[36m${(index + 1).toString()}. ${displayName}\u001B[0m`);
console.log(
` 💰 Price: \u001B[32m$${readablePrice.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 8 })}\u001B[0m`,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I feel like if we want to commit to doing things like coloring our logs, it's better to add something like chalk. Seeing ANSI codes just feels weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeahh didn't wanna add a dependency just for this since its not really service logs or a core part of the package.

Comment on lines +59 to +65
// Print out the binary hex messages if you want:
// if ("solana" in message.value) {
// console.info("solana message:", message.value.solana?.toString("hex"));
// }
// if ("evm" in message.value) {
// console.info("evm message:", message.value.evm?.toString("hex"));
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left it in as a hint for people who want to use the binary message

Comment on lines +9 to +10
// Ignore debug messages
console.debug = () => {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be doing this at a file level? I feel like we should respect the log level that is passed into the execution call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah there is no console.setLevel unfortunately, this is a common workaround to set "log level" when using console directly as a logger. Functionally its the same as passing in a ts-log instance or something, but again its just an example so didn't want to prescribe things like which logger to pass in.

LE_ECDSA: 1_296_547_300,
LE_UNSIGNED: 1_499_680_012,
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully maintaining this isn't a big problem. I wonder if we should set up something where we define the types in Rust somewhere once, and then derive types from it for other languages. Maybe @cprussin has some ideas. This is probably fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's a good point, i don't have a strong opinion here -- in the Hermes client, we get the types from the hermes /docs OpenAPI json, which seems as good a place as any to consider the source of truth for types. We don't have OpenAPI support yet in router yet though. There's some interesting projects out there for this as well: https://github.com/Aleph-Alpha/ts-rs

@tejasbadadare tejasbadadare merged commit db01db1 into main Sep 23, 2025
13 checks passed
@tejasbadadare tejasbadadare deleted the tb/lazer-js-sdk/add-endpoints-and-examples branch September 23, 2025 18:38
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.

4 participants