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.
To get started, install the package using cargo:
cargo add murray-rs
After installation, import murray-rs
into your project to access the various APIs.
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(())
}
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(())
}
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(())
}
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());
}
Find more examples in the repository to guide your implementation:
Leverage your self-hosted APIs for enhanced control and customization:
Contributions are welcome! For significant changes or enhancements, please open an issue first to discuss your ideas.
Murray-rs is open-sourced software licensed under the MIT license.