You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/data-streams/tutorials/streams-direct/streams-direct-api-rust.mdx
+62-64Lines changed: 62 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,6 @@ In this guide, you'll learn how to use Chainlink Data Streams with the _[Streams
46
46
47
47
## Requirements
48
48
49
-
-**Git**: Make sure you have Git installed. You can check your current version by running <CopyTexttext="git --version"code/> in your terminal and download the latest version from the official [Git website](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) if necessary.
50
49
-**Rust**: Make sure you have Rust installed. You can install Rust by following the instructions on the official [Rust website](https://www.rust-lang.org/tools/install).
51
50
-**API Credentials**: Access to the Streams Direct implementation requires API credentials. If you haven't already, [contact us](https://chainlinkcommunity.typeform.com/datastreams?typeform-source=docs.chain.link#ref_id=docs) to request mainnet or testnet access.
52
51
@@ -68,12 +67,12 @@ You'll start with the set up of your Rust project. Next, you'll fetch and decode
68
67
cargo init
69
68
```
70
69
71
-
1. Add the Data Streams SDK to your `Cargo.toml`:
70
+
1. Add the following dependencies to your `Cargo.toml` file:
@@ -215,7 +213,7 @@ The API client is initialized in two steps:
215
213
- Sets up the REST API endpoint for data retrieval
216
214
- Configures optional settings like TLS verification
217
215
218
-
2.[`Client::new`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/sdk/src/client.rs#L131) creates the HTTP client with your configuration. This client:
216
+
1.[`Client::new`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/sdk/src/client.rs#L131) creates the HTTP client with your configuration. This client:
219
217
- Handles authentication automatically
220
218
- Manages HTTP connections
221
219
- Implements retry logic for failed requests
@@ -230,7 +228,7 @@ The SDK provides several methods to fetch reports through the REST API:
230
228
- Returns a single report with the latest timestamp
231
229
- Useful for applications that need the most current data
232
230
233
-
2. Historical report: [`get_report`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/sdk/src/client.rs#L242) fetches a report at a specific timestamp:
231
+
1. Historical report: [`get_report`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/sdk/src/client.rs#L242) fetches a report at a specific timestamp:
234
232
- Takes both feed ID and timestamp
235
233
- Returns the report closest to the requested timestamp
236
234
- Helpful for historical analysis or verification
@@ -252,13 +250,13 @@ Reports are decoded in three stages:
2. Report separation: [`decode_full_report`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/report/src/report.rs#L77) splits the binary data:
253
+
1. Report separation: [`decode_full_report`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/report/src/report.rs#L77) splits the binary data:
256
254
257
255
- Extracts the report context (metadata)
258
256
- Isolates the report blob (actual data)
259
257
- Validates the report format
260
258
261
-
3. Data extraction: [`ReportDataV3::decode`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/report/src/report/v3.rs#L80) parses the report blob into structured data:
259
+
1. Data extraction: [`ReportDataV3::decode`](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/crates/report/src/report/v3.rs#L80) parses the report blob into structured data:
262
260
- Benchmark price (18 decimal places)
263
261
- Bid and ask prices for [liquidity-weighted pricing](/data-streams/concepts/liquidity-weighted-prices)
264
262
- Fee information for onchain verification
@@ -274,13 +272,13 @@ The example demonstrates Rust's robust error handling:
274
272
- Implements the `Error` trait for proper error propagation
0 commit comments