1 unstable release
0.1.0 | Mar 17, 2024 |
---|
#13 in #mempool
48KB
1K
SLoC
](https://github.com/Guilospanck/murray-rs/actions/workflows/tests.yml)
Murray-rs
Murray-rs is the rust version of the comprehensive NPM package module designed for seamless integration with Murray Rothbot's suite of APIs, including Blockchain, Lightning, and Prices - Murray JS. This powerful library enables developers to quickly incorporate bitcoin data and interactions within their applications.
Installation
To get started, install the package using cargo:
cargo add murray-rs
Usage
After installation, import murray-rs
into your project to access the various APIs.
Blockchain API
use murray_rs::{GetBlockParams, Murray, BlockchainError};
fn main() -> std::result::Result<(), BlockchainError> {
let murray = Murray::default();
let a = murray.blockchain.get_block(GetBlockParams {
hash: None,
height: Some(500000),
})?;
println!("{:?}", a);
Ok(())
}
Lightning API
use murray_rs::{Murray, GetNodeDetailsParams, LightningError};
fn main() -> std::result::Result<(), LightningError> {
let murray = Murray::default();
let a = murray.lightning.get_node_details(GetNodeDetailsParams {
public_key: "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f".to_string(),
})?;
println!("{:?}", a);
Ok(())
}
Prices API
use murray_rs::{Murray, ConvertCurrencyParams, Currency, PriceError};
fn main() -> std::result::Result<(), PriceError> {
let murray = Murray::default();
let a = murray.prices.convert_currency(ConvertCurrencyParams {
currency: Currency::BRL,
value: 100,
})?;
println!("{:?}", a);
Ok(())
}
Custom Endpoints
Customize endpoints for each API to suit your specific needs:
use murray_rs::{Murray, BaseEndpointsParams};
fn main() {
let murray = Murray::new(BaseEndpointsParams {
blockchain_endpoint: Some("https://your-custom-domain.com/".to_string()),
prices_endpoint: Some("https://your-custom-domain.com/".to_string()),
lightning_endpoint: Some("https://your-custom-domain.com/".to_string()),
});
let blockchain = murray.blockchain.get_health();
println!("{:?}", blockchain.unwrap());
let prices = murray.prices.get_health();
println!("{:?}", prices.unwrap());
let lightning = murray.lightning.get_health();
println!("{:?}", lightning.unwrap());
}
Examples
Find more examples in the repository to guide your implementation:
Self Hosted APIs
Leverage your self-hosted APIs for enhanced control and customization:
Contributing
Contributions are welcome! For significant changes or enhancements, please open an issue first to discuss your ideas.
License
Murray-rs is open-sourced software licensed under the MIT license.
Dependencies
~6–21MB
~273K SLoC