Skip to content

Commit 4ee174b

Browse files
committed
updates
1 parent b42aac1 commit 4ee174b

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

pages/lazer/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"type": "separator"
1717
},
1818

19-
"fetch-price-updates": "Fetch Price Updates",
19+
"subscribe-price-updates": "Subscribe to Price Updates",
2020
"integrate-as-consumer": "Integrate as a Consumer",
2121
"integrate-as-publisher": "Integrate as a Publisher",
2222

pages/lazer/fetch-price-updates.mdx

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
11
import { Callout, Steps } from "nextra/components";
22

3-
# How to Fetch Price Updates from Pyth Lazer
3+
# How to Subscribe to Price Updates from Pyth Lazer
44

5-
Pyth Lazer provides a [websocket API (TODO: Prod)](https://pyth-lazer-staging.dourolabs.app/docs) to fetch price updates.
5+
This guide explains how to subscribe to price updates from Pyth Lazer. This guide will also explain various properties and channels that one can use to customize the price updates.
66

7-
This guide explains how to **fetch** price updates, explore various **properties** of these updates, and configure the channel for **update frequency**. (TODO: Rewrite maybe)
8-
9-
Fetching price updates is a three-step process:
7+
Subscribing to price updates is a three-step process:
108

119
1. **Acquire** an access token.
1210
2. **Adjust** subscription parameters.
13-
3. **Subscribe** to the price updates via websocket API.
11+
3. **Subscribe** to the price updates via [websocket API](https://pyth-lazer-staging.dourolabs.app/docs).
1412

15-
The websocket server is available at `wss://pyth-lazer-staging.dourolabs.app/v1/stream`.
16-
TODO: Add the prod URL.
13+
The websocket server is available at `wss://pyth-lazer-staging.dourolabs.app/v1/stream{:bash}`.
1714

1815
<Steps>
1916

2017
### 1. Acquire an access token
2118

2219
Please fill out [this form](https://tally.so/r/nP2lG5) to contact the Pyth team and get the access token.
2320

24-
Use the access token to authenticate the websocket connection as a `Bearer {token}{:bash}`.
21+
Use the access token to authenticate the websocket connection by passing it as an `Authorization{:bash}` header with the value `Bearer {token}{:bash}`.
2522

2623
### 2. Adjust subscription parameters
2724

2825
One can configure the request/subscription parameters to customize the received price updates. A sample request is shown below:
2926

30-
```json
31-
client.send({
32-
type: "subscribe",
33-
subscriptionId: 1,
34-
priceFeedIds: [1, 2],
35-
properties: ["price"],
36-
chains: ["solana"],
37-
channel: "fixed_rate@200ms",
38-
});
27+
```js
28+
client.send({
29+
type: "subscribe",
30+
subscriptionId: 1,
31+
priceFeedIds: [1, 2],
32+
properties: ["price"],
33+
chains: ["solana"],
34+
channel: "fixed_rate@200ms",
35+
});
3936
```
4037

4138
Here:
4239

43-
- `subscriptionId` is an arbitrary numeric identifier one can choose for a subscription. It will eb returned back in response by the server. It doesn not affect the signed payload.
40+
- `subscriptionId` is an arbitrary numeric identifier one can choose for a subscription. It will be returned back in response by the server. It doesn not affect the signed payload.
4441
- `priceFeedIds` is the list of price feeds one like to receive. Data for all price feeds will be present in the signed price updates generated. Refer to the [Price Feed IDs list](./price-feeds.mdx) for the supported price feeds.
45-
- `properties` is the list of properties one can request, such as **price**, **bestBidPrice**, **bestAskPrice**, etc. TODO: Find more properties.
42+
- `properties` is the list of properties one can request, such as **price**, **bestBidPrice**, **bestAskPrice**, etc.
4643
- `chains` is the list of chains for which one need a signed payload, such as **evm**, **solana**, etc.
4744
- `channel` allows to configure the update rate: updates in the **real_time** channel are sent as frequently as possible, while **fixed_rate@200ms** and **fixed_rate@50ms** channels are updated at fixed rates.
4845

@@ -53,7 +50,7 @@ There are also a few other parameters one may use. Refer to the [API documentati
5350
To subscribe to the price updates, one needs to send the request to the websocket server. The server will respond with a signed price update.
5451

5552
1. Pyth Lazer provides a [SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/sdk/js) to seamlessly integrate the websocket API into your application.
56-
It can be installed using the following command:
53+
It can be installed using the following command:
5754

5855
```bash
5956
npm install --save @pythnetwork/pyth-lazer-sdk
@@ -93,7 +90,7 @@ client.addMessageListener((message) => {
9390
});
9491
```
9592

96-
By default, price updates contain the `parsed` field that one can use to easily interpret the update in their backend or frontend, as well as evm and/or solana fields that contain data that one should include in the on-chain transaction:
93+
By default, price updates contain the `parsed` field that one can use to easily interpret the price update in their backend or frontend, as well as `evm` and/or `solana` fields that contain data that one should include in the on-chain transaction:
9794

9895
```json
9996
{
@@ -120,3 +117,17 @@ By default, price updates contain the `parsed` field that one can use to easily
120117
```
121118

122119
</Steps>
120+
121+
122+
123+
## Additional Resources
124+
125+
You may find these additional resources helpful for subscribing to price updates from Pyth Lazer.
126+
127+
### Price Feed IDs
128+
129+
Pyth Lazer supports a wide range of price feeds. Consult the [Price Feed IDs](../price-feeds.mdx) page for a complete list of supported price feeds.
130+
131+
### Examples
132+
133+
[pyth-lazer-example-js](https://github.com/pyth-network/pyth-examples/tree/main/lazer/js) is a simple example for subscribing to the Pyth Lazer websocket.

0 commit comments

Comments
 (0)