# @pythnetwork/price-service-client

> Pyth price service client

Latest version **1.11.0** (published 2026-02-06) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @pythnetwork/price-service-client
pnpm add @pythnetwork/price-service-client
yarn add @pythnetwork/price-service-client
bun add @pythnetwork/price-service-client
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.11.0 |
| Published | 2026-02-06 |
| First published | 2023-03-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^24.0.0 |
| Dependencies | 7 |
| Unpacked size | 64.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 255 |
| Author | Pyth Data Association |
| Maintainers | marc.pyth, jayantk2, pythrelease, cprussin |
| Keywords | pyth, oracle |

## Links

- npm: https://www.npmjs.com/package/@pythnetwork/price-service-client
- Repository: https://github.com/pyth-network/pyth-crosschain
- Homepage: https://pyth.network
- Issues: https://github.com/pyth-network/pyth-crosschain/issues
- npm.io page: https://npm.io/package/@pythnetwork/price-service-client

## Dependencies (7)

- [ws](https://npm.io/package/ws.md) ^8.6.0
- [axios](https://npm.io/package/axios.md) ^1.5.1
- [ts-log](https://npm.io/package/ts-log.md) ^2.2.4
- [@types/ws](https://npm.io/package/@types/ws.md) ^8.5.3
- [axios-retry](https://npm.io/package/axios-retry.md) ^4.0.0
- [isomorphic-ws](https://npm.io/package/isomorphic-ws.md) ^4.0.1
- [@pythnetwork/price-service-sdk](https://npm.io/package/@pythnetwork/price-service-sdk.md) 1.9.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.11.0 (latest) — 2026-02-06
- 1.10.0 — 2025-11-07
- 1.9.1 — 2025-10-20
- 1.9.0 — 2024-02-23
- 1.8.2 — 2023-11-01
- 1.8.1 — 2023-10-16
- 1.8.0 — 2023-09-22
- 1.7.0 — 2023-09-19
- 1.6.2 — 2023-08-16
- 1.6.1 — 2023-07-10
- 1.6.0 — 2023-06-28
- 1.5.0 — 2023-05-29
- 1.4.1 — 2023-05-01
- 1.4.0 — 2023-03-29

## README

> **⚠️ DEPRECATION NOTICE**
>
> This package is deprecated and is no longer maintained. Please use [@pythnetwork/hermes-client](https://www.npmjs.com/package/@pythnetwork/hermes-client) instead.

# Price Service Client

[Pyth Network](https://pyth.network/) provides real-time pricing data in a variety of asset classes, including cryptocurrency, equities, FX and commodities.
These prices are available either via HTTP or WebSocket from [Hermes](/apps/hermes).
This library is a client for interacting with Hermes, allowing your application to consume Pyth real-time prices in on- and off-chain Javascript/Typescript applications.

## Installation

### npm

```
$ npm install --save @pythnetwork/price-service-client
```

### Yarn

```
$ yarn add @pythnetwork/price-service-client
```

## Quickstart

Typical usage of the connection is along the following lines:

```typescript
const connection = new PriceServiceConnection("https://hermes.pyth.network", {
  priceFeedRequestConfig: {
    // Provide this option to retrieve signed price updates for on-chain contracts.
    // Ignore this option for off-chain use.
    binary: true,
  },
}); // See Hermes endpoints section below for other endpoints

const priceIds = [
  // You can find the ids of prices at https://pyth.network/developers/price-feed-ids
  "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", // BTC/USD price id
  "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace", // ETH/USD price id
];

// Get the latest values of the price feeds as json objects.
// If you set `binary: true` above, then this method also returns signed price updates for the on-chain Pyth contract.
const currentPrices = await connection.getLatestPriceFeeds(priceIds);

// You can also call this function to get price updates for the on-chain contract directly.
const priceUpdateData = await connection.getLatestVaas(priceIds);
```

`PriceServiceConnection` also allows subscribing to real-time price updates over a websocket connection:

```typescript
connection.subscribePriceFeedUpdates(priceIds, (priceFeed) => {
  // priceFeed here is the same as returned by getLatestPriceFeeds above.
  // It will include signed price updates if the binary option was provided to the connection constructor.
  console.log(
    `Received update for ${priceFeed.id}: ${priceFeed.getPriceNoOlderThan(60)}`
  );
});

// When using the subscription, make sure to close the websocket upon termination to finish the process gracefully.
setTimeout(() => {
  connection.closeWebSocket();
}, 60000);
```

### On-chain Applications

On-chain applications will need to submit the price updates returned by Hermes to the Pyth contract on their blockchain.
These applications should pass the `binary: true` option to the constructor as shown above, to ensure that all methods on `PriceServiceConnection` return the required information.
This option will add a `vaa` field to `PriceFeed` that represents a signed price update.
The `vaa` is a binary blob serialized as a base64 string.
Depending on the blockchain, you may need to reformat this into hex or another format before submitting it to the Pyth contract.

### Examples

The [PriceServiceClient](./src/examples/PriceServiceClient.ts) example demonstrates both the HTTP and websocket APIs described above.
You can run it with `npm run example`.
A full command that prints BTC and ETH price feeds, in the testnet network, looks like so:

```bash
npm run example -- \
  --endpoint https://hermes.pyth.network \
  --price-ids \
    0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 \
    0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
```

## Hermes endpoints

Pyth offers a free public endpoint at [https://hermes.pyth.network](https://hermes.pyth.network). However, it is
recommended to obtain a private endpoint from one of the Hermes RPC providers for more reliability. You can find more
information about Hermes RPC providers
[here](https://docs.pyth.network/documentation/pythnet-price-feeds/hermes#public-endpoint).

---
_Source: https://npm.io/package/@pythnetwork/price-service-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
