shyft_rs_sdk/lib.rs
1/*!
2# Shyft Rust SDK
3
4Shyft SDK is a Rust library for interacting with the [Shyft API](https://docs.shyft.to/).
5
6<div class="warning">
7This is not an official SDK. It is a personal project for learning Rust and API development. The included endpoints are primarily for personal use in my own projects and may not cover all features of the Shyft API.
8</div>
9
10## Features
11
12- Configurable retry strategy for API requests.
13- Fetch transaction history for a given account.
14- Retrieve parsed transaction details for a specific transaction signature.
15- Fetch parsed bulk transactions in a single call.
16
17## Configuration
18
19You can configure the retry strategy by providing optional parameters when creating the [`ShyftApi`] instance:
20
21- `min_retry_interval`: Minimum retry interval in milliseconds.
22- `max_retry_interval`: Maximum retry interval in milliseconds.
23- `max_retries`: Maximum number of retries.
24- `network`: Network to interact with(mainnet-beta, devnet, testnet).
25- `commitment`: Commitment level for transactions(confirmed, finalised).
26
27## Usage
28
29### Creating a ShyftApi Instance
30
31```
32use shyft_rs_sdk::ShyftApi;
33
34let api_key = "your_api_key";
35let client = ShyftApi::new(api_key, None, None, None, None, None)
36 .expect("Failed to create ShyftApi");
37```
38
39### Fetching Transaction History
40
41Equivalent to [GET /transaction/history]
42
43[GET /transaction/history]: https://docs.shyft.to/solana-apis/transactions/transaction-apis#get-transaction-history
44
45```no_run
46# #[tokio::main]
47# async fn main() -> Result<(), shyft_rs_sdk::Error> {
48# use shyft_rs_sdk::ShyftApi;
49#
50# let api_key = "your_api_key";
51# let client = ShyftApi::new(api_key, None, None, None, None, None).unwrap();
52let account = "your_account_address";
53let transaction_history = client
54 .get_transaction_history(account, Some(10), None, None, Some(true), None)
55 .await?;
56println!("{:?}", transaction_history);
57# Ok(())
58# }
59```
60
61### Fetching Parsed Transaction Details
62
63Equivalent to [GET /transaction/parsed]
64
65[GET /transaction/parsed]: https://docs.shyft.to/solana-apis/transactions/transaction-apis#parsed-transaction
66
67```no_run
68# #[tokio::main]
69# async fn main() -> Result<(), shyft_rs_sdk::Error> {
70# use shyft_rs_sdk::ShyftApi;
71#
72# let api_key = "your_api_key";
73# let client = ShyftApi::new(api_key, None, None, None, None, None).unwrap();
74let tx_signature = "your_transaction_signature";
75let parsed_transaction_details = client
76 .get_transaction_parsed(tx_signature)
77 .await
78 .expect("Failed to fetch parsed transaction details");
79println!("{:?}", parsed_transaction_details);
80# Ok(())
81# }
82```
83
84### Fetching Parsed Bulk Transactions
85
86Equivalent to [POST /transaction/parse_selected]
87
88[POST /transaction/parse_selected]: https://docs.shyft.to/solana-apis/transactions/transaction-apis#post-transaction-parse_selected
89
90```no_run
91# #[tokio::main]
92# async fn main() -> Result<(), shyft_rs_sdk::Error> {
93# use shyft_rs_sdk::ShyftApi;
94#
95# let api_key = "your_api_key";
96# let client = ShyftApi::new(api_key, None, None, None, None, None).unwrap();
97let tx_signatures = vec![
98 "your_transaction_signature_1".to_owned(),
99 "your_transaction_signature_2".to_owned(),
100];
101let parsed_transactions = client
102 .get_transaction_parse_selected(&tx_signatures, Some(true), Some(true))
103 .await
104 .expect("Failed to fetch parsed bulk transactions");
105println!("{:?}", parsed_transactions);
106# Ok(())
107# }
108```
109 */
110
111#![warn(
112 missing_docs,
113 rustdoc::unescaped_backticks,
114 clippy::missing_errors_doc,
115 clippy::missing_docs_in_private_items
116)]
117
118mod api;
119mod constants;
120mod error;
121mod reqwest_ext;
122
123pub mod models;
124
125pub use api::{Commitment, Network, ShyftApi};
126pub use error::Error;