Skip to content

Commit 24ba767

Browse files
committed
feat(dev-hub) Pyth Pro pages Part-1
1 parent 35816c5 commit 24ba767

File tree

12 files changed

+1259
-5
lines changed

12 files changed

+1259
-5
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Acquire an Access Token
3+
description: Request and manage access tokens for Pyth Pro
4+
slug: /price-feeds/pro/acquire-access-token
5+
---
6+
7+
import { Callout } from "fumadocs-ui/components/callout";
8+
9+
This guide explains how to acquire an access token for Pyth Pro, which is required to authenticate websocket connections and subscribe to price updates.
10+
11+
## Request Access Token
12+
13+
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.
14+
15+
<Callout type="info">
16+
Access tokens are required for all Pyth Pro websocket connections. Make sure
17+
to keep your token secure and do not share it publicly.
18+
</Callout>
19+
20+
## Using the Access Token
21+
22+
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}`.
23+
24+
### Example Usage
25+
26+
```js copy
27+
import { PythLazerClient } from "@pythnetwork/pyth-lazer-sdk";
28+
29+
const client = await PythLazerClient.create(
30+
[
31+
"wss://pyth-lazer-0.dourolabs.app/v1/stream",
32+
"wss://pyth-lazer-1.dourolabs.app/v1/stream",
33+
],
34+
"YOUR_ACCESS_TOKEN",
35+
);
36+
```
37+
38+
## Next Steps
39+
40+
After acquiring your access token, you can proceed to [subscribe to price feeds](./subscribe-price-updates.mdx) using the Pyth Pro websocket API.
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
---
2+
title: Getting Started
3+
description: Learn how to access, configure, and use Pyth Pro price feeds
4+
slug: /price-feeds/pro/getting-started
5+
---
6+
7+
import { Callout } from "fumadocs-ui/components/callout";
8+
import { Step, Steps } from "fumadocs-ui/components/steps";
9+
10+
Pyth Pro is a high-performance, low-latency service that provides real-time financial market data.
11+
This guide will walk you through setting up and running a basic JavaScript example to subscribe to Pyth Pro price feeds.
12+
13+
## Prerequisites
14+
15+
Before getting started, make sure you have the following installed:
16+
17+
- **Node.js** (version 18 or higher)
18+
- **pnpm** package manager
19+
- **Git** for cloning the examples repository
20+
- A **Pyth Pro Access Token** - see [How to Acquire an Access Token](./acquire-access-token) if you don't have one
21+
22+
<Steps>
23+
<Step>
24+
### Clone the Examples Repository
25+
First, clone the Pyth examples repository which contains the JavaScript SDK example:
26+
27+
```bash copy
28+
git clone https://github.com/pyth-network/pyth-examples.git
29+
cd pyth-examples/lazer/js
30+
```
31+
32+
</Step>
33+
<Step>
34+
### Install Dependencies
35+
Install the required dependencies using pnpm:
36+
37+
```bash copy
38+
pnpm install
39+
```
40+
41+
This will install `@pythnetwork/pyth-lazer-sdk`, which will be used to subscribe to Pyth Pro prices.
42+
43+
<Callout type="info">
44+
**Pyth Pro was previously known as Pyth Lazer**. The SDK remains the same.
45+
</Callout>
46+
</Step>
47+
<Step>
48+
### Configure Your Access Token
49+
Set your Pyth Pro access token as an environment variable:
50+
51+
```bash copy
52+
export ACCESS_TOKEN=your_actual_token_here
53+
```
54+
55+
<Callout type="warning">
56+
Replace `your_actual_token_here` with your actual Pyth Pro access token. If you
57+
don't have one, follow the [access token guide](./acquire-access-token) to
58+
obtain it.
59+
</Callout>
60+
</Step>
61+
<Step>
62+
### Run the Basic WebSocket Example
63+
Now you can run the basic example that demonstrates connecting to Pyth Pro and receiving price updates:
64+
65+
```bash copy
66+
pnpm run start
67+
```
68+
69+
This command will subscribe to Pyth Pro updates for two price feeds, receiving streaming updates.
70+
Each update is then printed to the terminal on receipt.
71+
You should see output similar to the following:
72+
73+
```bash copy
74+
got message: {
75+
type: 'json',
76+
value: {
77+
type: 'streamUpdated',
78+
subscriptionId: 1,
79+
parsed: { timestampUs: '1758034015200000', priceFeeds: [Array] },
80+
solana: {
81+
encoding: 'hex',
82+
data: 'b9011a82036df6ced259a33949ab9b2c48a61a2d3b0b9436cba24c3ef8a600b72767927d14a459fcc3abce280b3f8194e16e8b32f9322ac0b84a9c0b792e19857962a60180efc1f480c5615af3fb673d42287e993da9fbc3506b6e41dfa32950820c2e6c2a0075d3c79300a3fa30ec3e060003020100000001009053802f790a00000200000001004234106d67000000'
83+
}
84+
}
85+
}
86+
stream updated for subscription 1 : [
87+
{ priceFeedId: 1, price: '11515604259728' },
88+
{ priceFeedId: 2, price: '444211409986' }
89+
]
90+
got message: {
91+
type: 'json',
92+
value: {
93+
type: 'streamUpdated',
94+
subscriptionId: 1,
95+
parsed: { timestampUs: '1758034015400000', priceFeeds: [Array] },
96+
solana: {
97+
encoding: 'hex',
98+
data: 'b9011a826f5ff7e25ac4056c4ec3a08c428baf38e7b78c46014296ccbcfd5395c38c9f7bc23865a048401c66788e791f0edc3a6701b0ea4a5399f50ec8b1795757854f0180efc1f480c5615af3fb673d42287e993da9fbc3506b6e41dfa32950820c2e6c2a0075d3c79340b0fd30ec3e060003020100000001005821a32f790a00000200000001004334106d67000000'
99+
}
100+
}
101+
}
102+
stream updated for subscription 1 : [
103+
{ priceFeedId: 1, price: '11515606540632' },
104+
{ priceFeedId: 2, price: '444211409987' }
105+
]
106+
```
107+
108+
</Step>
109+
<Step>
110+
### Understand the Example Code
111+
The main example code in `src/index.ts` demonstrates the core Pyth Pro integration pattern:
112+
113+
```typescript copy
114+
import { PythLazerClient } from "@pythnetwork/pyth-lazer-sdk";
115+
116+
const client = await PythLazerClient.create({
117+
urls: [
118+
"wss://pyth-lazer-0.dourolabs.app/v1/stream",
119+
"wss://pyth-lazer-1.dourolabs.app/v1/stream",
120+
],
121+
token: process.env.ACCESS_TOKEN!,
122+
});
123+
124+
// The message listener is called every time a new message is received.
125+
client.addMessageListener((message) => {
126+
// Add your logic to consume messages here
127+
console.log("got message:", message);
128+
});
129+
130+
// Subscribe to price feeds
131+
client.subscribe({
132+
type: "subscribe",
133+
subscriptionId: 1,
134+
priceFeedIds: [1, 2],
135+
properties: ["price"],
136+
formats: ["solana"],
137+
deliveryFormat: "json",
138+
channel: "fixed_rate@200ms",
139+
jsonBinaryEncoding: "hex",
140+
});
141+
```
142+
143+
NOTE: Every property passed to `client.subscribe` are explained in the [API Reference](https://pyth-lazer.dourolabs.app/docs).
144+
145+
</Step>
146+
</Steps>
147+
148+
## What's Next?
149+
150+
Now that you've successfully run the basic Pyth Pro example, you can explore more advanced integration patterns:
151+
152+
### More Information
153+
154+
Explore additional Pyth Pro capabilities:
155+
156+
- **[Subscribe to Price Updates](./subscribe-price-updates)** - Detailed guide on WebSocket subscriptions and message handling
157+
- **[Price Feed IDs](./price-feed-ids)** - Complete list of available price feeds and their identifiers
158+
159+
### Blockchain Integration
160+
161+
Learn how to integrate Pyth Pro price feeds into your smart contracts:
162+
163+
- **[Solana Integration](./integrate-as-consumer/svm)** - Build SVM smart contracts that consume Pyth Pro price feeds with cryptographic verification
164+
- **[EVM Integration](./integrate-as-consumer/evm)** - Integrate Pyth Pro into Ethereum and other EVM-compatible chains
165+
166+
### Example Applications
167+
168+
Check out more comprehensive examples in the [pyth-examples repository](https://github.com/pyth-network/pyth-examples/tree/main/lazer):
169+
170+
- **Solana Examples** - Post price data to Solana smart contracts with Ed25519 and ECDSA verification
171+
- **EVM Examples** - Smart contract integration for Ethereum-compatible chains
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: How Pyth Pro Works
3+
description: Understand the services that power Pyth Pro’s low-latency price delivery
4+
slug: /price-feeds/pro/how-lazer-works
5+
---
6+
7+
Pyth Pro is a permissioned service that provides ultra-low-latency market data to consumers.
8+
It aggregates data from multiple publishers and distributes it to consumers through a multi-tier architecture.
9+
10+
## System Services
11+
12+
The architecture consists of five main types of services that work together to provide ultra-low-latency data to consumers.
13+
Each service has multiple instances running to ensure high availability and low latency.
14+
15+
### Publishers
16+
17+
Publishers are the entities that provide market data to Pro. They submit updates via authenticated WebSocket connections.
18+
Each publisher is configured with specific permissions defining which feeds they can update.
19+
20+
### Relayers
21+
22+
The Relayer service is the ingestion layer that receives and validates all incoming updates from publishers.
23+
24+
**Key responsibilities:**
25+
26+
- **Authentication**: Validates publisher access tokens and optional Ed25519 signatures.
27+
- **Validation**: Performs sanity checks on incoming updates by examining feed IDs, timestamps, and values to ensure data integrity and proper formatting.
28+
- **Rate limiting**: Enforces configurable limits on publisher updates.
29+
- **Message forwarding**: Publishes validated updates to an internal message queue.
30+
31+
Douro Labs operates the relayer service for the Pyth Pro network. It follows a strict, deterministic processing model:
32+
33+
- **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).
34+
- **FCFS processing**: Updates are processed on a first-come-first-served basis without prioritization.
35+
36+
This ensures reliable, predictable data flow from publishers to consumers.
37+
38+
### Message Queue
39+
40+
The system uses a distributed message queue for pub/sub messaging with stream persistence.
41+
This allows the system to be deployed in a multi-datacenter environment and ensures reliable message delivery between services.
42+
43+
**Message ordering**: The message queue ensures reliable delivery and maintains the exact sequence of messages within each data stream.
44+
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.
45+
This sequential processing is essential for keeping all aggregators synchronized with the same feed state.
46+
47+
### Routers
48+
49+
The Router is the real-time distribution layer that serves data to consumers.
50+
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.
51+
52+
**Key features:**
53+
54+
- **WebSocket streaming**: Provides `/v1/stream` endpoint for real-time price updates
55+
- **HTTP REST API**: Offers `/v1/latest_price` for on-demand price queries
56+
- **Channel types**: Supports real-time and fixed-rate channels (50ms, 200ms, 1s)
57+
- **Multi-chain support**: Generates on-chain payloads for Solana, EVM, and other chains
58+
59+
#### Aggregation logic
60+
61+
Each Router embeds an aggregator component that consumes publisher updates from the Message Queue and computes aggregated data feeds. The aggregator:
62+
63+
- Computes median values resistant to outlier data from individual publishers.
64+
- Calculates confidence intervals using interquartile range to measure data spread.
65+
- Determines best bid/ask values filtered to ensure market consistency.
66+
- Automatically removes stale publisher data based on configurable timeouts.
67+
68+
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.
69+
This ensures that every Router instance maintains identical feed state, providing consistent data to all consumers regardless of which Router they connect to.
70+
71+
### History Service
72+
73+
The History Service provides persistence and historical data queries.
74+
75+
**Key responsibilities:**
76+
77+
- Data persistence: Stores all publisher updates, aggregated data, and transactions.
78+
- Historical queries: Provides REST API for querying historical data.
79+
- OHLC API: Provides Open, High, Low, Close (OHLC) data for charting applications through the history service.

apps/developer-hub/content/docs/price-feeds/pro/index.mdx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
---
22
title: Pyth Pro
3-
description: Introduction to Pyth Pro Price Feeds
3+
description: Explore Pyth Pro's enterprise-grade, customizable price data offering
44
slug: /price-feeds/pro
55
---
66

7-
import { ProductCard } from "../../../../src/components/ProductCard";
8-
import { Key, Lightning, ChartLine } from "@phosphor-icons/react/dist/ssr";
7+
import {
8+
Key,
9+
Lightning,
10+
CurrencyDollarSimple,
11+
} from "@phosphor-icons/react/dist/ssr";
912

10-
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.
13+
import { Callout } from "fumadocs-ui/components/callout";
14+
15+
<Callout type="info">Pyth Pro was previously known as Pyth Lazer.</Callout>
16+
17+
Pyth Pro delivers customizable, enterprise-grade price data directly from first-party publishers.
18+
Subscribers can configure their price feeds, update schedules, and usage rights for display or redistribution.
19+
The service is delivered through standard APIs for seamless integration.
1120

1221
<Cards>
1322
<Card
@@ -21,7 +30,7 @@ Pyth Pro delivers customizable, enterprise-grade price data directly from first-
2130
description="Configure real-time Pyth Pro price delivery."
2231
/>
2332
<Card
24-
icon={<ChartLine size={12.5} />}
33+
icon={<CurrencyDollarSimple size={12.5} />}
2534
title="Pricing"
2635
description="Review subscription tiers and usage-based pricing details."
2736
/>

0 commit comments

Comments
 (0)