Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Acquire an Access Token
description: Request and manage access tokens for Pyth Pro
slug: /price-feeds/pro/acquire-access-token
---

import { Callout } from "fumadocs-ui/components/callout";

This guide explains how to acquire an access token for Pyth Pro, which is required to authenticate websocket connections and subscribe to price updates.

## Request Access Token

Please fill out [this form](https://tally.so/r/3xG8E5) to get in touch with our authorized distribution partners (Pyth Data Distributors) and obtain an access token.

<Callout type="info">
Access tokens are required for all Pyth Pro websocket connections. Make sure
to keep your token secure and do not share it publicly.
</Callout>

## Using the Access Token

Once you receive your access token, use it to authenticate the websocket connection by passing it as an `Authorization` header with the value `Bearer {token}`.

### Example Usage

```js copy
import { PythLazerClient } from "@pythnetwork/pyth-lazer-sdk";

const client = await PythLazerClient.create(
[
"wss://pyth-lazer-0.dourolabs.app/v1/stream",
"wss://pyth-lazer-1.dourolabs.app/v1/stream",
],
"YOUR_ACCESS_TOKEN",
);
```

## Next Steps

After acquiring your access token, you can proceed to [subscribe to price feeds](./subscribe-price-updates.mdx) using the Pyth Pro websocket API.
171 changes: 171 additions & 0 deletions apps/developer-hub/content/docs/price-feeds/pro/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
title: Getting Started
description: Learn how to access, configure, and use Pyth Pro price feeds
slug: /price-feeds/pro/getting-started
---

import { Callout } from "fumadocs-ui/components/callout";
import { Step, Steps } from "fumadocs-ui/components/steps";

Pyth Pro is a high-performance, low-latency service that provides real-time financial market data.
This guide will walk you through setting up and running a basic JavaScript example to subscribe to Pyth Pro price feeds.

## Prerequisites

Before getting started, make sure you have the following installed:

- **Node.js** (version 18 or higher)
- **pnpm** package manager
- **Git** for cloning the examples repository
- A **Pyth Pro Access Token** - see [How to Acquire an Access Token](./acquire-access-token) if you don't have one

<Steps>
<Step>
### Clone the Examples Repository
First, clone the Pyth examples repository which contains the JavaScript SDK example:

```bash copy
git clone https://github.com/pyth-network/pyth-examples.git
cd pyth-examples/lazer/js
```

</Step>
<Step>
### Install Dependencies
Install the required dependencies using pnpm:

```bash copy
pnpm install
```

This will install `@pythnetwork/pyth-lazer-sdk`, which will be used to subscribe to Pyth Pro prices.

<Callout type="info">
**Pyth Pro was previously known as Pyth Lazer**. The SDK remains the same.
</Callout>
</Step>
<Step>
### Configure Your Access Token
Set your Pyth Pro access token as an environment variable:

```bash copy
export ACCESS_TOKEN=your_actual_token_here
```

<Callout type="warning">
Replace `your_actual_token_here` with your actual Pyth Pro access token. If you
don't have one, follow the [access token guide](./acquire-access-token) to
obtain it.
</Callout>
</Step>
<Step>
### Run the Basic WebSocket Example
Now you can run the basic example that demonstrates connecting to Pyth Pro and receiving price updates:

```bash copy
pnpm run start
```

This command will subscribe to Pyth Pro updates for two price feeds, receiving streaming updates.
Each update is then printed to the terminal on receipt.
You should see output similar to the following:

```bash copy
got message: {
type: 'json',
value: {
type: 'streamUpdated',
subscriptionId: 1,
parsed: { timestampUs: '1758034015200000', priceFeeds: [Array] },
solana: {
encoding: 'hex',
data: 'b9011a82036df6ced259a33949ab9b2c48a61a2d3b0b9436cba24c3ef8a600b72767927d14a459fcc3abce280b3f8194e16e8b32f9322ac0b84a9c0b792e19857962a60180efc1f480c5615af3fb673d42287e993da9fbc3506b6e41dfa32950820c2e6c2a0075d3c79300a3fa30ec3e060003020100000001009053802f790a00000200000001004234106d67000000'
}
}
}
stream updated for subscription 1 : [
{ priceFeedId: 1, price: '11515604259728' },
{ priceFeedId: 2, price: '444211409986' }
]
got message: {
type: 'json',
value: {
type: 'streamUpdated',
subscriptionId: 1,
parsed: { timestampUs: '1758034015400000', priceFeeds: [Array] },
solana: {
encoding: 'hex',
data: 'b9011a826f5ff7e25ac4056c4ec3a08c428baf38e7b78c46014296ccbcfd5395c38c9f7bc23865a048401c66788e791f0edc3a6701b0ea4a5399f50ec8b1795757854f0180efc1f480c5615af3fb673d42287e993da9fbc3506b6e41dfa32950820c2e6c2a0075d3c79340b0fd30ec3e060003020100000001005821a32f790a00000200000001004334106d67000000'
}
}
}
stream updated for subscription 1 : [
{ priceFeedId: 1, price: '11515606540632' },
{ priceFeedId: 2, price: '444211409987' }
]
```

</Step>
<Step>
### Understand the Example Code
The main example code in `src/index.ts` demonstrates the core Pyth Pro integration pattern:

```typescript copy
import { PythLazerClient } from "@pythnetwork/pyth-lazer-sdk";

const client = await PythLazerClient.create({
urls: [
"wss://pyth-lazer-0.dourolabs.app/v1/stream",
"wss://pyth-lazer-1.dourolabs.app/v1/stream",
],
token: process.env.ACCESS_TOKEN!,
});

// The message listener is called every time a new message is received.
client.addMessageListener((message) => {
// Add your logic to consume messages here
console.log("got message:", message);
});

// Subscribe to price feeds
client.subscribe({
type: "subscribe",
subscriptionId: 1,
priceFeedIds: [1, 2],
properties: ["price"],
formats: ["solana"],
deliveryFormat: "json",
channel: "fixed_rate@200ms",
jsonBinaryEncoding: "hex",
});
```

NOTE: Every property passed to `client.subscribe` are explained in the [API Reference](https://pyth-lazer.dourolabs.app/docs).

</Step>
</Steps>

## What's Next?

Now that you've successfully run the basic Pyth Pro example, you can explore more advanced integration patterns:

### More Information

Explore additional Pyth Pro capabilities:

- **[Subscribe to Price Updates](./subscribe-price-updates)** - Detailed guide on WebSocket subscriptions and message handling
- **[Price Feed IDs](./price-feed-ids)** - Complete list of available price feeds and their identifiers

### Blockchain Integration

Learn how to integrate Pyth Pro price feeds into your smart contracts:

- **[Solana Integration](./integrate-as-consumer/svm)** - Build SVM smart contracts that consume Pyth Pro price feeds with cryptographic verification
- **[EVM Integration](./integrate-as-consumer/evm)** - Integrate Pyth Pro into Ethereum and other EVM-compatible chains

### Example Applications

Check out more comprehensive examples in the [pyth-examples repository](https://github.com/pyth-network/pyth-examples/tree/main/lazer):

- **Solana Examples** - Post price data to Solana smart contracts with Ed25519 and ECDSA verification
- **EVM Examples** - Smart contract integration for Ethereum-compatible chains
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: How Pyth Pro Works
description: Understand the services that power Pyth Pro’s low-latency price delivery
slug: /price-feeds/pro/how-lazer-works
---

Pyth Pro is a permissioned service that provides ultra-low-latency market data to consumers.
It aggregates data from multiple publishers and distributes it to consumers through a multi-tier architecture.

## System Services

The architecture consists of five main types of services that work together to provide ultra-low-latency data to consumers.
Each service has multiple instances running to ensure high availability and low latency.

### Publishers

Publishers are the entities that provide market data to Pro. They submit updates via authenticated WebSocket connections.
Each publisher is configured with specific permissions defining which feeds they can update.

### Relayers

The Relayer service is the ingestion layer that receives and validates all incoming updates from publishers.

**Key responsibilities:**

- **Authentication**: Validates publisher access tokens and optional Ed25519 signatures.
- **Validation**: Performs sanity checks on incoming updates by examining feed IDs, timestamps, and values to ensure data integrity and proper formatting.
- **Rate limiting**: Enforces configurable limits on publisher updates.
- **Message forwarding**: Publishes validated updates to an internal message queue.

Douro Labs operates the relayer service for the Pyth Pro network. It follows a strict, deterministic processing model:

- **No price dropping outside of circuit breakers**: All validated updates are forwarded to the message queue without dropping any prices (except for when a circuit breaker is triggered).
- **FCFS processing**: Updates are processed on a first-come-first-served basis without prioritization.

This ensures reliable, predictable data flow from publishers to consumers.

### Message Queue

The system uses a distributed message queue for pub/sub messaging with stream persistence.
This allows the system to be deployed in a multi-datacenter environment and ensures reliable message delivery between services.

**Message ordering**: The message queue ensures reliable delivery and maintains the exact sequence of messages within each data stream.
This means every publisher update will be delivered at least once, and messages will be processed in the same order they arrived at the Relayer.
This sequential processing is essential for keeping all aggregators synchronized with the same feed state.

### Routers

The Router is the real-time distribution layer that serves data to consumers.
It embeds aggregation logic to compute median prices, confidence intervals (using interquartile range), and best bid/ask prices, funding rates, and more from multiple publisher inputs.

**Key features:**

- **WebSocket streaming**: Provides `/v1/stream` endpoint for real-time price updates
- **HTTP REST API**: Offers `/v1/latest_price` for on-demand price queries
- **Channel types**: Supports real-time and fixed-rate channels (50ms, 200ms, 1s)
- **Multi-chain support**: Generates on-chain payloads for Solana, EVM, and other chains

#### Aggregation logic

Each Router embeds an aggregator component that consumes publisher updates from the Message Queue and computes aggregated data feeds. The aggregator:

- Computes median values resistant to outlier data from individual publishers.
- Calculates confidence intervals using interquartile range to measure data spread.
- Determines best bid/ask values filtered to ensure market consistency.
- Automatically removes stale publisher data based on configurable timeouts.

Pro guarantees deterministic aggregation: all aggregators produce the exact same aggregated results by relying solely on the consistent stream of price updates from the Message Queue.
This ensures that every Router instance maintains identical feed state, providing consistent data to all consumers regardless of which Router they connect to.

### History Service

The History Service provides persistence and historical data queries.

**Key responsibilities:**

- Data persistence: Stores all publisher updates, aggregated data, and transactions.
- Historical queries: Provides REST API for querying historical data.
- OHLC API: Provides Open, High, Low, Close (OHLC) data for charting applications through the history service.
19 changes: 14 additions & 5 deletions apps/developer-hub/content/docs/price-feeds/pro/index.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
---
title: Pyth Pro
description: Introduction to Pyth Pro Price Feeds
description: Explore Pyth Pro's enterprise-grade, customizable price data offering
slug: /price-feeds/pro
---

import { ProductCard } from "../../../../src/components/ProductCard";
import { Key, Lightning, ChartLine } from "@phosphor-icons/react/dist/ssr";
import {
Key,
Lightning,
CurrencyDollarSimple,
} from "@phosphor-icons/react/dist/ssr";

Pyth Pro delivers customizable, enterprise-grade price data directly from first-party publishers. Subscribers can configure their price feeds, update schedules, and usage rights for display or redistribution. The service is delivered through standard APIs for seamless integration.
import { Callout } from "fumadocs-ui/components/callout";

<Callout type="info">Pyth Pro was previously known as Pyth Lazer.</Callout>

Pyth Pro delivers customizable, enterprise-grade price data directly from first-party publishers.
Subscribers can configure their price feeds, update schedules, and usage rights for display or redistribution.
The service is delivered through standard APIs for seamless integration.

<Cards>
<Card
Expand All @@ -21,7 +30,7 @@ Pyth Pro delivers customizable, enterprise-grade price data directly from first-
description="Configure real-time Pyth Pro price delivery."
/>
<Card
icon={<ChartLine size={12.5} />}
icon={<CurrencyDollarSimple size={12.5} />}
title="Pricing"
description="Review subscription tiers and usage-based pricing details."
/>
Expand Down
Loading
Loading