### Install @pythnetwork/client with npm Source: https://github.com/pyth-network/pyth-client-js/blob/main/README.md Installs the @pythnetwork/client package using npm. This is the first step to integrate Pyth network data into your JavaScript project. ```bash $ npm install --save @pythnetwork/client ``` -------------------------------- ### Install @pythnetwork/client with Yarn Source: https://github.com/pyth-network/pyth-client-js/blob/main/README.md Installs the @pythnetwork/client package using Yarn. This is an alternative package manager for installing the library. ```bash $ yarn add @pythnetwork/client ``` -------------------------------- ### Request Pyth Price Updates via HTTP Source: https://github.com/pyth-network/pyth-client-js/blob/main/README.md Fetches all Pyth product data, including current prices and metadata, using an HTTP request. It iterates through symbols and logs price details. ```typescript const pythClient = new PythHttpClient(connection, pythPublicKey); const data = await pythClient.getData(); for (let symbol of data.symbols) { const price = data.productPrice.get(symbol)! // Sample output: // Crypto.SRM/USD: $8.68725 ±$0.0131 Status: Trading console.log(`${symbol}: $${price.price} \xB1$${price.confidence} Status: ${PriceStatus[price.status]}`) } ``` -------------------------------- ### Stream Pyth Price Updates via WebSocket Source: https://github.com/pyth-network/pyth-client-js/blob/main/README.md Establishes a WebSocket connection to Pythnet to receive real-time price updates. It uses `PythConnection` and `onPriceChange` to log symbol, price, confidence, and status. ```typescript const pythConnection = new PythConnection(pythnetWeb3Connection, getPythProgramKeyForCluster(pythnetClusterName)) pythConnection.onPriceChange((product, price) => { // sample output: // Crypto.SRM/USD: $8.68725 ±$0.0131 Status: Trading console.log(`${product.symbol}: $${price.price} \xB1$${price.confidence} Status: ${PriceStatus[price.status]}`) }) // Start listening for price change events. pythConnection.start() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.