
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
@pythnetwork/client
Advanced tools
Pyth is building a way to deliver a decentralized, cross-chain market of verifiable data from high-quality nodes to any smart contract, anywhere.
This library consumes on-chain Pyth accountInfo.data
from @solana/web3.js and returns JavaScript-friendly objects.
See our examples repo for real-world usage examples.
$ npm install --save @pythnetwork/client
$ yarn add @pythnetwork/client
import { Connection, PublicKey } from '@solana/web3.js'
import { parseMappingData, parsePriceData, parseProductData } from '@pythnetwork/client'
const connection = new Connection(SOLANA_CLUSTER_URL)
const publicKey = new PublicKey(ORACLE_MAPPING_PUBLIC_KEY)
connection.getAccountInfo(publicKey).then((accountInfo) => {
const { productAccountKeys } = parseMappingData(accountInfo.data)
connection.getAccountInfo(productAccountKeys[productAccountKeys.length - 1]).then((accountInfo) => {
const { product, priceAccountKey } = parseProductData(accountInfo.data)
connection.getAccountInfo(priceAccountKey).then((accountInfo) => {
const { price, confidence } = parsePriceData(accountInfo.data)
console.log(`${product.symbol}: $${price} \xB1$${confidence}`)
// SRM/USD: $8.68725 ±$0.0131
})
})
})
To get streaming price updates, you may want to use connection.onAccountChange
2.2.0
numQuoters
FAQs
Client for consuming Pyth price data
We found that @pythnetwork/client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.